From 546d4a7631313fc244b15ccd1ad96e89847cdcd1 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 25 Oct 2023 22:27:45 +0200 Subject: [PATCH] test on single container --- .travis.yml | 8 +-- Scripts/docker_entrypoint.sh | 53 ------------------- .../FluentBenchmarkTests.swift | 6 --- 3 files changed, 4 insertions(+), 63 deletions(-) delete mode 100755 Scripts/docker_entrypoint.sh diff --git a/.travis.yml b/.travis.yml index 71e624a..e2496b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ jobs: script: - docker pull ${SWIFT_DOCKER_IMAGE} - docker pull ${MONGO_DOCKER_IMAGE} - - docker run -d -p 27001:27001 -p 27002:27002 -p 27003:27003 -v $(pwd)/Scripts:/scripts:ro --entrypoint /scripts/docker_entrypoint.sh --restart=always ${MONGO_DOCKER_IMAGE} + - docker run -d -p 27017:27017 --restart=always ${MONGO_DOCKER_IMAGE} - args="apt-get update && apt-get -y install cmake libssl-dev libsasl2-dev - && swift build --enable-test-discovery -c debug - && swift build --enable-test-discovery -c release - && swift test --enable-test-discovery -c debug --sanitize=thread"; + && swift build -c debug + && swift build -c release + && swift test -c debug --sanitize=thread"; - docker run --rm --net=host -v $(pwd):/app --workdir /app ${SWIFT_DOCKER_IMAGE} bash -c "${args}" - stage: test diff --git a/Scripts/docker_entrypoint.sh b/Scripts/docker_entrypoint.sh deleted file mode 100755 index 3221d10..0000000 --- a/Scripts/docker_entrypoint.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -set -e - -REPLICA_SET_NAME=${REPLICA_SET_NAME:=rs0} - -function waitForMongo { - port=$1 - n=0 - until [ $n -ge 20 ] - do - mongo admin --quiet --port $port --eval "db" && break - n=$[$n+1] - sleep 2 - done -} - -if [ ! "$(ls -A /data/db1)" ]; then - mkdir /data/db1 - mkdir /data/db2 - mkdir /data/db3 -fi - -echo "STARTING CLUSTER" - -mongod --port 27003 --dbpath /data/db3 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB3_PID=$! -mongod --port 27002 --dbpath /data/db2 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB2_PID=$! -mongod --port 27001 --dbpath /data/db1 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB1_PID=$! - -waitForMongo 27001 -waitForMongo 27002 -waitForMongo 27003 - -echo "CONFIGURING REPLICA SET" -CONFIG="{ _id: '$REPLICA_SET_NAME', members: [{_id: 0, host: 'localhost:27001', priority: 2 }, { _id: 1, host: 'localhost:27002' }, { _id: 2, host: 'localhost:27003' } ]}" -mongo admin --port 27001 --eval "db.runCommand({ replSetInitiate: $CONFIG })" - -waitForMongo 27002 -waitForMongo 27003 - -mongo admin --port 27001 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" -mongo admin --port 27002 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" -mongo admin --port 27003 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" - -echo "REPLICA SET ONLINE" - -trap 'echo "KILLING"; kill $DB1_PID $DB2_PID $DB3_PID; wait $DB1_PID; wait $DB2_PID; wait $DB3_PID' SIGINT SIGTERM EXIT - -wait $DB1_PID -wait $DB2_PID -wait $DB3_PID \ No newline at end of file diff --git a/Tests/FluentMongoTests/FluentBenchmarkTests.swift b/Tests/FluentMongoTests/FluentBenchmarkTests.swift index 485f8e5..f4c1543 100644 --- a/Tests/FluentMongoTests/FluentBenchmarkTests.swift +++ b/Tests/FluentMongoTests/FluentBenchmarkTests.swift @@ -93,13 +93,7 @@ func env(_ name: String) -> String? { } let mongoConnectionString: String = { - #if os(Linux) - - return "mongodb://localhost:27001,localhost:27002,localhost:27003" - #else - return "mongodb://localhost:27017" - #endif }() func clearDatabase(_ connectionString: String, on eventLoopGroup: EventLoopGroup) throws {