Skip to content

Commit

Permalink
TC-47 test cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Jan 9, 2025
1 parent bb4bb8e commit 1fc8384
Showing 1 changed file with 18 additions and 38 deletions.
56 changes: 18 additions & 38 deletions .github/oxid-esales/cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,68 +38,48 @@ EOF
if ! grep -q "networks:" docker-compose.yml; then
echo "$app_network" >> docker-compose.yml
echo "Custom network added to docker-compose.yml."
else
echo "Custom network already exists in docker-compose.yml."
fi

if ! grep -q "cypress:" docker-compose.yml; then
echo "$cypress_service" >> docker-compose.yml
echo "Cypress service added successfully."
else
echo "Cypress service already exists in docker-compose.yml."
fi
else
echo "Error: docker-compose.yml not found."
exit 1
fi
}

function wait_for_service_health() {
local service_name=$1
echo "Waiting for $service_name to be healthy..."
local retries=20
local count=0

while [ $count -lt $retries ]; do
if docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}no_health_check{{end}}' $service_name | grep -q "healthy"; then
echo "$service_name is healthy."
return 0
fi
echo "Waiting for $service_name to be healthy... ($count/$retries)"
count=$((count + 1))
sleep 5
done
function add_network_to_services() {
echo "Injecting custom network into existing services in docker-compose.yml..."

echo "Error: $service_name failed to become healthy."
return 1
if grep -q "apache:" docker-compose.yml && grep -q "php:" docker-compose.yml; then
sed -i '/apache:/,/[^ ]/{s/volumes:/&\n networks:\n - app-network/}' docker-compose.yml
sed -i '/php:/,/[^ ]/{s/volumes:/&\n networks:\n - app-network/}' docker-compose.yml
echo "Custom network injected into existing services."
else
echo "Error: Services apache or php not found in docker-compose.yml."
exit 1
fi
}

function run_docker_compose_up() {
cat docker-compose.yml
echo "Running docker-compose up..."
docker-compose config # Validate the YAML file
docker compose up --build -d apache php

# wait_for_service_health telecash-module-apache-1 || exit 1
echo "Waiting for services to start..."
sleep 10 # Adjust as needed

echo "Curl-ing Apache from Cypress container"
echo "Starting Cypress container..."
docker compose up --build -d cypress
docker ps

echo "Testing connectivity..."
if ! docker exec -it telecash-module-cypress-1 curl -I http://telecash-module-apache-1; then
echo "Error: Unable to reach Apache from Cypress container."
exit 1
fi

docker compose up cypress
}

function add_network_to_services() {
echo "Injecting custom network into existing services in docker-compose.yml..."

if grep -q "services:" docker-compose.yml; then
sed -i '/services:/a \ apache:\n networks:\n - app-network\n php:\n networks:\n - app-network' docker-compose.yml
echo "Custom network injected into services."
else
echo "Error: No services section found in docker-compose.yml."
exit 1
fi
}

export CYPRESS_WORKDIR="$(pwd)/source/vendor/oxid-solution-catalysts/telecash-module/tests/e2e"
Expand Down

0 comments on commit 1fc8384

Please sign in to comment.