Skip to content

Commit

Permalink
Review container setup (#25)
Browse files Browse the repository at this point in the history
* Sleepers replaced

* Fixed to ensure that superuser is created

* Override wait time for superuser setup delay to 0

* Removed override of credentials requirements for GitHub actions

container

* Fix mistake test.yml

* Removed unused properties and relocated and renamed

---------

Co-authored-by: pablo <[email protected]>
  • Loading branch information
suarezgpablo and pablo authored Apr 24, 2024
1 parent b96d696 commit a95d923
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ jobs:
docker run --name test-cassandra -d -p 9042:9042 \
-v ${GITHUB_WORKSPACE}/modevo-script/dat/inp/creationSchema.cql:/creationSchema.cql \
cassandra:3.11
sleep 3
docker exec test-cassandra sh -c "sed 's/authenticator:.*/authenticator: PasswordAuthenticator/' /etc/cassandra/cassandra.yaml > /etc/cassandra/cassandra_temp.yaml && mv /etc/cassandra/cassandra_temp.yaml /etc/cassandra/cassandra.yaml"
docker exec test-cassandra sh -c "sed 's/authorizer:.*/authorizer: CassandraAuthorizer/' /etc/cassandra/cassandra.yaml > /etc/cassandra/cassandra_temp.yaml && mv /etc/cassandra/cassandra_temp.yaml /etc/cassandra/cassandra.yaml"
docker exec test-cassandra nodetool flush
docker restart test-cassandra
sleep 15
docker exec test-cassandra cqlsh localhost 9042 -u cassandra -p cassandra -e "CREATE ROLE usercassandra WITH PASSWORD = 'passwordcassandra' AND LOGIN = true;"
docker exec test-cassandra cqlsh localhost 9042 -u cassandra -p cassandra -e "GRANT ALL PERMISSIONS on ALL KEYSPACES to usercassandra;"
chmod u+x setup/wait-container-ready.sh && ./setup/wait-container-ready.sh test-cassandra 1 "Created default superuser role"
docker exec test-cassandra cqlsh localhost 9042 -u cassandra -p cassandra -f creationSchema.cql
- name: Test and aggregate surefire report
run: mvn test -Daggregate=true -Dmaven.test.failure.ignore=true -U --no-transfer-progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


public class TestExecutionScript {
private static final String PROPERTIES = "modevo.properties";
private static final String PROPERTIES = "src/test/resources/dbconnection.properties";
private static CassandraConnection connection;
private static final String bmkPath = "dat/bmk/";
private static final String outputPath = "dat/out/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Needs to be customized
ip=localhost
port=9042
user=usercassandra
password=passwordcassandra
user=user
password=password
4 changes: 0 additions & 4 deletions modevo.properties

This file was deleted.

11 changes: 7 additions & 4 deletions setup/wait-container-ready.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
#Sample approach to wait until a container is ready
#by looking for a string in container log
container=$1
target=$2
countertarget=$2
target=$3

attempt=0
while [ $attempt -le 60 ]; do
attempt=$(( $attempt + 1 ))
echo "Waiting for container ready (attempt: $attempt)..."
result=$(docker logs $container)
if grep -q "$target" <<< $result ; then
echo "Container is ready!"
exit 0
count=$(grep -o "$target" <<< "$result" | wc -l)
if [ $count -eq $countertarget ]; then
echo "Container is ready!"
exit 0
fi

sleep 1
done
echo "ERROR: Container is not ready after maximum number of attempts"
Expand Down

0 comments on commit a95d923

Please sign in to comment.