Skip to content

Commit ff6550e

Browse files
committed
test(simulation): skip replication simulation without docker harness
1 parent d2c8a7a commit ff6550e

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

simulation/replication/replication_simulation_test.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ import (
3636
"encoding/json"
3737
"flag"
3838
"fmt"
39+
"net"
3940
"net/http"
41+
"os"
4042
"reflect"
4143
"sort"
4244
"strings"
@@ -54,15 +56,34 @@ import (
5456
func TestReplicationSimulation(t *testing.T) {
5557
flag.Parse()
5658

57-
simTypes.Logf(t, "Starting Replication Simulation")
59+
// This is a docker-compose based integration test. It expects the Cadence clusters to be reachable via the
60+
// docker network aliases defined in `docker/github_actions/docker-compose-local-replication-simulation.yml`.
61+
// For local runs, use `./simulation/replication/run.sh --scenario <scenario>`.
62+
if os.Getenv("REPLICATION_SIMULATION_CONFIG") == "" {
63+
t.Skip("replication simulation requires docker-compose; run ./simulation/replication/run.sh --scenario <scenario>")
64+
}
5865

59-
simTypes.Logf(t, "Sleeping for 30 seconds to allow services to start/warmup")
60-
time.Sleep(30 * time.Second)
66+
simTypes.Logf(t, "Starting Replication Simulation")
6167

6268
// load config
6369
simCfg, err := simTypes.LoadConfig()
6470
require.NoError(t, err, "failed to load config")
6571

72+
// Fast-fail with a helpful message if the cluster endpoints are not resolvable (common when running outside
73+
// of the docker compose network).
74+
for clusterName, clusterCfg := range simCfg.Clusters {
75+
host, _, err := net.SplitHostPort(clusterCfg.GRPCEndpoint)
76+
if err != nil {
77+
t.Fatalf("invalid grpcEndpoint for cluster %s: %q: %v", clusterName, clusterCfg.GRPCEndpoint, err)
78+
}
79+
if _, err := net.LookupHost(host); err != nil {
80+
t.Skipf("cluster endpoint %q is not resolvable (%v); run ./simulation/replication/run.sh --scenario <scenario>", clusterCfg.GRPCEndpoint, err)
81+
}
82+
}
83+
84+
simTypes.Logf(t, "Sleeping for 30 seconds to allow services to start/warmup")
85+
time.Sleep(30 * time.Second)
86+
6687
// initialize replication simulation
6788
sim := simTypes.NewReplicationSimulation()
6889

0 commit comments

Comments
 (0)