PromucFlow_constructor/app/client/cypress/setup-test-ci.sh
Shrikant Sharat Kandula d0c2d40c7b
chore: Logs and potential fix for CI startup flakiness (#34461)
The `tlog` command isn't predictably getting the executable permission,
so we're explicitly setting that up in `Dockerfile` here.

As well as in the setup script for Cypress, if we get a 502 even after
90 seconds, we print the logs of the `appsmith` container, so we're not
guessing the causes. This should provide us more information next time
we see such flakiness.

**/test sanity**



<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9658565348>
> Commit: 96c777dd9a1bd8c28477bf1dcd1d4748ced0022e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9658565348&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`

<!-- end of auto-generated comment: Cypress test results  -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated Dockerfile to ensure custom command-scripts in `/opt/bin/`
have executable permissions.
- Enhanced `setup-test-ci.sh` script to output `appsmith` logs when the
server connection fails.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-25 14:03:56 +05:30

49 lines
1.5 KiB
Bash

#! /bin/sh
# This script is responsible for setting up the local Nginx server for running E2E Cypress tests
# on our CI/CD system. Currently the script is geared towards Github Actions
echo "Starting the setup for test framework"
sudo echo "127.0.0.1 localhost" | sudo tee -a /etc/hosts
sleep 10
echo "Checking if the containers have started"
sudo docker ps -a
for fcid in $(sudo docker ps -a | awk '/Exited/ { print $1 }'); do
echo "Logs for container '$fcid'."
docker logs "$fcid"
done
if sudo docker ps -a | grep -q Exited; then
echo "One or more containers failed to start." >&2
exit 1
fi
echo "Checking if the server has started"
status_code=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost/api/v1/users)
retry_count=1
while [ "$retry_count" -le "3" -a "$status_code" -eq "502" ]; do
echo "Hit 502.Server not started retrying..."
retry_count=$((1 + $retry_count))
sleep 30
status_code=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost/api/v1/users)
done
echo "Checking if client and server have started"
ps -ef |grep java 2>&1
ps -ef |grep serve 2>&1
echo "status code: $status_code"
if [ "$status_code" -eq "502" ]; then
echo "Unable to connect to server"
docker logs appsmith
exit 1
fi
# DEBUG=cypress:* $(npm bin)/cypress version
# sed -i -e "s|api_url:.*$|api_url: $CYPRESS_URL|g" /github/home/.cache/Cypress/4.1.0/Cypress/resources/app/packages/server/config/app.yml
# cat /github/home/.cache/Cypress/4.1.0/Cypress/resources/app/packages/server/config/app.yml