<commit_before>#!/bin/sh

if [ ! $TEST_PG_PW ]
then
  echo "TEST_PG_PW not set. Enter Postgres password:"
  read -s TEST_PG_PW
fi

netName=transicator-tests-$$
dbName=transicator-test-pg-$$
testName=transicator-test-$$
ssName=snapshot-test-$$
csName=changeserver-test-$$
slotName=changeserver_test_slot

# Need a network for our tests
docker network create --driver bridge ${netName}

# Build postgresql image
docker build --tag ${dbName} ./pgoutput

# Launch it
docker run -d -P \
  --network ${netName} \
  --name ${dbName} \
  -e POSTGRES_PASSWORD=${<PASSWORD>} \
  ${dbName}

# Build a test container
docker build --tag ${testName} -f ./test/Dockerfile .

# Run the unit tests in it
docker run --rm -it \
  --network ${netName} \
  -e PGPASSWORD=${<PASSWORD>} \
  -e DBHOST=${dbName} \
  ${testName} \
  /go/src/github.com/30x/transicator/test/container_test_script.sh

# Build changeserver and snapshot server images
docker build --tag ${ssName} -f ./snapshotserver/Dockerfile.snapshotserver .
docker build --tag ${csName} -f ./changeserver/Dockerfile.changeserver .

# Launch them
docker run -d \
  --name ${csName} \
  -P --network ${netName} \
  ${csName} \
  -s ${slotName} -u postgres://postgres:${TEST_PG_PW}@${dbName}/postgres

docker run -d \
  --name ${ssName} \
  -P --network ${netName} \
  ${ssName} \
  -u postgres://postgres:${TEST_PG_PW}@${dbName}/postgres

# Run tests of the combined servers and Postgres
docker run --rm -it \
  --network ${netName} \
  -e PGPASSWORD=${TEST_<PASSWORD>} \
  -e DBHOST=${dbName} \
  -e CHANGE_HOST=${csName} \
  -e SNAPSHOT_HOST=${ssName} \
  -e CHANGE_PORT=9000 \
  -e SNAPSHOT_PORT=9001 \
  ${testName} \
  /go/src/github.com/30x/transicator/test/combined_test_script.sh

echo "*** changeserver logs ***"
docker logs ${csName}
echo "*** snapshotserver logs ***"
docker logs ${ssName}

# Clean up
docker rm -f ${csName}
docker rm -f ${ssName}

#docker logs ${dbName}
docker rm -f ${dbName}

docker network rm ${netName}

RMOPT=--no-prune
docker rmi $(RMOPT) ${testName} ${ssName} ${csName} ${dbName}<commit_msg>Switch from Docker advanced networking to "old" links. That way we can run tests on older Docker versions.<commit_after>#!/bin/sh

if [ ! $TEST_PG_PW ]
then
  echo "TEST_PG_PW not set. Enter Postgres password:"
  read -s TEST_PG_PW
fi

netName=transicator-tests-$$
dbName=transicator-test-pg-$$
testName=transicator-test-$$
ssName=snapshot-test-$$
csName=changeserver-test-$$
slotName=changeserver_test_slot

# Build postgresql image
docker build --tag ${dbName} ./pgoutput

# Launch it
docker run -d \
  --name ${dbName} \
  -e POSTGRES_PASSWORD=${TEST_<PASSWORD>} \
  ${dbName}

# Build a test container
docker build --tag ${testName} -f ./test/Dockerfile .

# Run the unit tests in it
docker run --rm -it \
  --link ${dbName}:postgres \
  -e PGPASSWORD=${<PASSWORD>} \
  -e DBHOST=postgres \
  ${testName} \
  /go/src/github.com/30x/transicator/test/container_test_script.sh

# Build changeserver and snapshot server images
docker build --tag ${ssName} -f ./snapshotserver/Dockerfile.snapshotserver .
docker build --tag ${csName} -f ./changeserver/Dockerfile.changeserver .

# Launch them
docker run -d \
  --name ${csName} \
  --link ${dbName}:postgres \
  ${csName} \
  -s ${slotName} -u postgres://postgres:${TEST_PG_PW}@${dbName}/postgres

docker run -d \
  --name ${ssName} \
  --link ${dbName}:postgres \
  ${ssName} \
  -u postgres://postgres:${TEST_PG_PW}@${dbName}/postgres

# Run tests of the combined servers and Postgres
docker run --rm -it \
  --link ${dbName}:postgres \
  --link ${csName}:changeserver \
  --link ${ssName}:snapshotserver \
  -e PGPASSWORD=${<PASSWORD>} \
  -e DBHOST=postgres \
  -e CHANGE_HOST=changeserver \
  -e SNAPSHOT_HOST=snapshotserver \
  -e CHANGE_PORT=9000 \
  -e SNAPSHOT_PORT=9001 \
  ${testName} \
  /go/src/github.com/30x/transicator/test/combined_test_script.sh

echo "*** changeserver logs ***"
docker logs ${csName}
echo "*** snapshotserver logs ***"
docker logs ${ssName}

# Clean up
docker rm -f ${csName}
docker rm -f ${ssName}

#docker logs ${dbName}
docker rm -f ${dbName}

# --no-prune here will leave intermediate images around, which speeds
# up rebuild on a developer box
RMOPT=--no-prune
if [ $1 == "fullcleanup" ]
then
  RMOPT=
fi
docker rmi $(RMOPT) ${testName} ${ssName} ${csName} ${dbName}
{'fraction_non_alphanumeric': 0.15964831096714485, 'fraction_numerical': 0.005784359093012495, 'mean_word_length': 3.6284796573875804, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2180431', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1587, 'n_words': 410}