Skip to content

Commit

Permalink
Update scripts...
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLichtenberger committed Jul 13, 2024
1 parent 798892e commit ff5ce16
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
env:
GITHUB_ACTIONS: true
steps:
- uses: actions/checkout@v2
- name: setup python
Expand Down
11 changes: 9 additions & 2 deletions tests/resources/create-sirix-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ USERNAME="admin"
PASSWORD="admin"
ROLES="create,modify,delete,view"

# Determine if running in GitHub Actions or locally
if [ "$GITHUB_ACTIONS" == "true" ]; then
KEYCLOAK_HOST="keycloak"
else
KEYCLOAK_HOST="localhost"
fi

user_exists() {
$KEYCLOAK_HOME/bin/kcadm.sh get users -r "$REALM" -q "username=$USERNAME" --fields username | grep -q "\"username\" : \"$USERNAME\""
}

$KEYCLOAK_HOME/bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user "$USERNAME" --password "$PASSWORD"
$KEYCLOAK_HOME/bin/kcadm.sh config credentials --server http://$KEYCLOAK_HOST:8080 --realm master --user "$USERNAME" --password "$PASSWORD"

if user_exists; then
echo "User '$USERNAME' already exists in realm '$REALM'."
Expand All @@ -25,4 +32,4 @@ else
echo "Failed to add user '$USERNAME' to realm '$REALM'."
exit 1
fi
fi
fi
9 changes: 4 additions & 5 deletions tests/resources/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.4'
services:
keycloak:
build: .
Expand All @@ -22,10 +21,10 @@ services:
networks:
- auth-network
healthcheck:
test: "curl -f http://localhost:8080/ || exit 1"
timeout: 3s
start_period: 10s
retries: 20
test: [ "CMD", "curl", "-f", "http://keycloak:8080/realms/master" ]
interval: 60s
timeout: 20s
retries: 10
server:
image: sirixdb/sirix
ports:
Expand Down
11 changes: 9 additions & 2 deletions tests/resources/wait-for-keycloak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
# Start Keycloak in the background
/opt/keycloak/bin/kc.sh "$@" &

# Determine if running in GitHub Actions or locally
if [ "$GITHUB_ACTIONS" == "true" ]; then
KEYCLOAK_HOST="keycloak"
else
KEYCLOAK_HOST="localhost"
fi

# Wait for Keycloak to be ready
until curl -sf http://localhost:8080 > /dev/null; do
until curl -sf http://$KEYCLOAK_HOST:8080 > /dev/null; do
echo "Waiting for Keycloak to be ready..."
sleep 5
done
Expand All @@ -13,4 +20,4 @@ done
/opt/keycloak/scripts/create-sirix-users.sh

# Keep the container running
wait
wait

0 comments on commit ff5ce16

Please sign in to comment.