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 #3293

Signed-off-by: adrianbatuto <[email protected]>
  • Loading branch information
adrianbatuto committed Jun 18, 2024
1 parent 393c141 commit bf0f92a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export interface ICordaV5TestLedgerConstructorOptions {
* Provides default options for Corda container
*/
const DEFAULTS = Object.freeze({
imageVersion: "38c5858",
imageName: "ghcr.io/hyperledger/cactus-corda-5-all-in-one-alpha-2024-05-22",
imageVersion: "2024-06-18-issue3293-3e1660df4",
imageName: "ghcr.io/hyperledger/cacti-corda-5-all-in-one",
publicPort: 8888,
postgresPort: 5431,
rpcPortA: 10008,
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 bf0f92a

Please sign in to comment.