Skip to content

Commit

Permalink
test(connector-corda): fix flaky corda-v5-flow.test.ts
Browse files Browse the repository at this point in the history
Fixes hyperledger-cacti#3293

Signed-off-by: adrianbatuto <[email protected]>
  • Loading branch information
adrianbatuto committed Jun 8, 2024
1 parent 393c141 commit 3e1660d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ describe("Corda Test Case", () => {
const timeout = 180000; // 3 minutes
const cwd = "/CSDE-cordapp-template-kotlin";
shortHashID = await Containers.exec(container, cmd, timeout, logLevel, cwd);
// TODO: Remove the timeout below. This is a temporary fix to the flakiness of the test.
// Will do further investigation on this issue
await new Promise((resolve) => setTimeout(resolve, 60000));
});

describe("Endpoint Testing", () => {
Expand Down
35 changes: 29 additions & 6 deletions tools/docker/corda-all-in-one/corda-v5/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# #!/bin/bash
#!/bin/bash
set -e

# Function to check if all nodes are up and running
gradleOutput=""

# Check if all nodes are up and running
checkNodesStatus() {
local gradleOutput
# Run Gradle task and get the output
# Run Gradle task and capture the output
cd /CSDE-cordapp-template-kotlin/
gradleOutput=$(./gradlew listVNodes)
echo "gradleOutput: $gradleOutput"
Expand All @@ -14,12 +15,34 @@ checkNodesStatus() {
# Check if all 5 nodes are up and running
if [ "$upAndRunningCount" -eq 5 ]; then
echo "All 5 nodes are up and running."
exit 0
else
echo "Waiting for all nodes to be up and running..."
sleep 5
checkNodesStatus
fi
}

checkNodesStatus
# Check if request is successful
checkCurlSuccess() {
echo "Executing checkCurlSuccess function..."
local holding_identity_shorthash_test
holding_identity_shorthash_test=$(echo "$gradleOutput" | grep -oE '\b[0-9A-F]{12}\b' | tail -n 1)
local response_code
response_code=$(curl -k -s -o /dev/null -w "%{http_code}" -u admin:admin "https://localhost:8888/api/v1/members/$holding_identity_shorthash_test/group-parameters")
if [ "$response_code" -eq 200 ]; then
echo "CURL request successful."
else
echo "CURL request failed with response code: $response_code"
exit 1
fi
}

checkNodesStatus

checkCurlSuccess

WAIT_TIME=30
echo "Waiting for $WAIT_TIME seconds to ensure stability before exiting with status code 0..."
sleep $WAIT_TIME

exit 0

0 comments on commit 3e1660d

Please sign in to comment.