aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml16
-rw-r--r--Dockerfile1
-rw-r--r--Dockerfile.env4
-rw-r--r--docker-compose.testing.yml2
-rw-r--r--storage_test.go14
-rwxr-xr-xtravis_tests.sh18
6 files changed, 48 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..801a37f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+language: bash
+
+sudo: required
+services:
+ - docker
+
+before_script:
+ - docker pull eciavatta/caronte-env
+ - docker-compose -f docker-compose.testing.yml up -d --build
+
+script:
+ - docker logs -f caronte_caronte_1 | grep "travis" | (read status; if $status -eq "travis_tests_fails"; then exit 1; fi)
+
+after_script:
+ - docker logs caronte_caronte_1
+ - docker-compose down
diff --git a/Dockerfile b/Dockerfile
index 2a1ffc8..0c6f4f7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,4 +7,3 @@ WORKDIR /caronte
RUN go mod download && go build
CMD ./caronte
-
diff --git a/Dockerfile.env b/Dockerfile.env
index 844be8e..5c00d32 100644
--- a/Dockerfile.env
+++ b/Dockerfile.env
@@ -29,7 +29,8 @@ RUN wget https://github.com/intel/hyperscan/archive/v$HYPERSCAN_VERSION.tar.gz -
cmake -G "Unix Makefiles" -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_STATIC_AND_SHARED=1 \
-DBOOST_ROOT=/tmp/boost_1_72_0 .. && \
make && \
- make install
+ make install && \
+ ln -s /usr/local/lib/libhs.so.5 /usr/lib/libhs.so.5
# Get GoLang and install it
RUN wget https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz -P /tmp && \
@@ -39,4 +40,3 @@ RUN wget https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz -P /tmp && \
RUN rm -rf /tmp/*
CMD /bin/bash
-
diff --git a/docker-compose.testing.yml b/docker-compose.testing.yml
index c4eff8e..019628c 100644
--- a/docker-compose.testing.yml
+++ b/docker-compose.testing.yml
@@ -18,7 +18,7 @@ services:
- mongo
networks:
- caronte-net
- command: "./caronte"
+ command: "./travis_tests.sh"
environment:
MONGO_HOST: mongo
MONGO_PORT: 27017
diff --git a/storage_test.go b/storage_test.go
index 5356596..32a10a6 100644
--- a/storage_test.go
+++ b/storage_test.go
@@ -94,16 +94,24 @@ func testFindOne(t *testing.T) {
}
}
-
-
func TestBasicOperations(t *testing.T) {
t.Run("testInsert", testInsert)
t.Run("testFindOne", testFindOne)
}
func TestMain(m *testing.M) {
+ mongoHost, ok := os.LookupEnv("MONGO_HOST")
+ if !ok {
+ mongoHost = "localhost"
+ }
+ mongoPort, ok := os.LookupEnv("MONGO_PORT")
+ if !ok {
+ mongoHost = "27017"
+ }
+
uniqueDatabaseName := sha256.Sum256([]byte(time.Now().String()))
- client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
+
+ client, err := mongo.NewClient(options.Client().ApplyURI(fmt.Sprintf("mongodb://%s:%v", mongoHost, mongoPort)))
if err != nil {
panic("failed to create mongo client")
}
diff --git a/travis_tests.sh b/travis_tests.sh
new file mode 100755
index 0000000..cb4363c
--- /dev/null
+++ b/travis_tests.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# wait mongodb server
+sleep 10
+
+# run tests
+go test -v
+
+RET_CODE=$?
+
+#
+if [ $RET_CODE -eq 0 ]; then
+ echo "travis_tests_success"
+else
+ echo "travis_tests_fails"
+fi
+
+exit $RET_CODE