Skip to content

Commit 6470a6a

Browse files
committed
add test for post-start hook
Signed-off-by: Osama Rabea <[email protected]>
1 parent 6f4bc37 commit 6470a6a

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

e2e-network/docker/test-02-v2-raft-2orgs.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ networkUp() {
2424
expectCommand "cat \"$TEST_TMP/fablo-target/fabric-config/configtx.yaml\"" "MaxMessageCount: 1$"
2525

2626
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up)
27+
28+
local container_logs
29+
container_logs=$(find "$TEST_TMP/fablo-target" -name 'container-list-*.log' | head -1)
30+
if [ -z "$container_logs" ]; then
31+
echo "Error: Container list log file not found in fablo-target directory"
32+
exit 1
33+
fi
34+
35+
echo "Found container list log at: $container_logs"
36+
37+
local expected_containers=(
38+
"peer0.org1.example.com"
39+
"peer0.org2.example.com"
40+
"orderer"
41+
"ca.org1.example.com"
42+
"ca.org2.example.com"
43+
)
44+
45+
for container in "${expected_containers[@]}"; do
46+
if ! grep -q "$container" "$container_logs"; then
47+
echo "Error: Expected container '$container' not found in container list"
48+
echo "Container list content:"
49+
cat "$container_logs"
50+
exit 1
51+
fi
52+
echo "✓ Found container: $container"
53+
done
54+
55+
echo "✅ All expected containers found in the log"
2756
}
2857

2958
dumpLogs() {

e2e/__snapshots__/extendConfig.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5883,7 +5883,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`]
58835883
},
58845884
"hooks": {
58855885
"postGenerate": "perl -i -pe 's/MaxMessageCount: 10/MaxMessageCount: 1/g' "./fablo-target/fabric-config/configtx.yaml"",
5886-
"postStart": "",
5886+
"postStart": "echo 'Network started' && docker ps --format 'table {{.Names}} {{.Status}} {{.Ports}}' > ./fablo-target/container-list-$(date +%Y%m%d_%H%M%S).log 2>&1 && echo 'Container list saved into fablo-target directory'",
58875887
},
58885888
"orderedHeadsDistinct": [
58895889
{

e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6372,6 +6372,8 @@ exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml should create pro
63726372
63736373
# The code from this file is called after Fablo starts the Hyperledger Fabric network (after 'up' or 'start')
63746374
echo "Executing post-start hook"
6375+
6376+
echo 'Network started' && docker ps --format 'table {{.Names}} {{.Status}} {{.Ports}}' >./fablo-target/container-list-$(date +%Y%m%d_%H%M%S).log 2>&1 && echo 'Container list saved into fablo-target directory'
63756377
"
63766378
`;
63776379

e2e/__snapshots__/fabloCommands.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,7 @@ Validation warnings count: 0
24672467
],
24682468
"hooks": {
24692469
"postGenerate": "perl -i -pe 's/MaxMessageCount: 10/MaxMessageCount: 1/g' \\"./fablo-target/fabric-config/configtx.yaml\\"",
2470-
"postStart": ""
2470+
"postStart": "echo 'Network started' && docker ps --format 'table {{.Names}}\\t{{.Status}}\\t{{.Ports}}' > ./fablo-target/container-list-$(date +%Y%m%d_%H%M%S).log 2>&1 && echo 'Container list saved into fablo-target directory'"
24712471
}
24722472
}
24732473

samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ chaincodes:
7979
hooks:
8080
# changes MaxMessageCount to 1
8181
postGenerate: "perl -i -pe 's/MaxMessageCount: 10/MaxMessageCount: 1/g' \"./fablo-target/fabric-config/configtx.yaml\""
82+
postStart: "echo 'Network started' && docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' > ./fablo-target/container-list-$(date +%Y%m%d_%H%M%S).log 2>&1 && echo 'Container list saved into fablo-target directory'"
83+

0 commit comments

Comments
 (0)