From 5a026ce06d1acf794d6103e90760be91e21f5259 Mon Sep 17 00:00:00 2001 From: "Meggle (Sebastian Bathke)" Date: Tue, 10 Sep 2024 15:30:34 +0200 Subject: [PATCH] test: centralize zeebe image value --- README.md | 3 +++ cmd/zbctl/main_test.go | 3 +-- internal/containersuite/containerSuite.go | 7 +++---- test/integration_test.go | 8 ++------ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3f6ab774..3ab8551e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ mockgen -source=pkg/pb/gateway.pb.go GatewayClient,Gateway_ActivateJobsClient > ### Integration tests +Integration tests run zeebe in a container to test the client against. The version of Zeebe used is managed via +a constant in [`internal/containersuite/containerSuite.go`](internal/containersuite/containerSuite.go#L36). + To add new zbctl tests, you must generate a golden file with the expected output of the command you are testing. The tests ignore numbers so you can leave any keys or timestamps in your golden file, even though these will most likely be different from test command's output. However, non-numeric variables are not ignored. For instance, the help menu contains: ``` diff --git a/cmd/zbctl/main_test.go b/cmd/zbctl/main_test.go index 1618e73a..940c677c 100644 --- a/cmd/zbctl/main_test.go +++ b/cmd/zbctl/main_test.go @@ -251,8 +251,7 @@ func TestZbctlWithInsecureGateway(t *testing.T) { suite.Run(t, &integrationTestSuite{ ContainerSuite: &containersuite.ContainerSuite{ - WaitTime: time.Second, - ContainerImage: "camunda/zeebe:8.6.0-alpha5", + WaitTime: time.Second, Env: map[string]string{ "ZEEBE_BROKER_GATEWAY_LONGPOLLING_ENABLED": "false", }, diff --git a/internal/containersuite/containerSuite.go b/internal/containersuite/containerSuite.go index c44adb11..3578970c 100644 --- a/internal/containersuite/containerSuite.go +++ b/internal/containersuite/containerSuite.go @@ -33,6 +33,8 @@ import ( "google.golang.org/grpc/status" ) +const dockerImageName = "camunda/zeebe:8.6.0-alpha5" + type zeebeWaitStrategy struct { waitTime time.Duration } @@ -152,8 +154,6 @@ func isStable(res *pb.TopologyResponse) bool { type ContainerSuite struct { // WaitTime specifies the wait period before checking if the container is up WaitTime time.Duration - // ContainerImage is the ID of docker image to be used - ContainerImage string // GatewayAddress is the contact point of the spawned Zeebe container specified in the format 'host:port' GatewayAddress string GatewayHost string @@ -198,14 +198,13 @@ func (s *ContainerSuite) SetupSuite() { var err error req := testcontainers.GenericContainerRequest{ ContainerRequest: testcontainers.ContainerRequest{ - Image: s.ContainerImage, + Image: dockerImageName, ExposedPorts: []string{"26500/tcp", "9600/tcp"}, WaitingFor: zeebeWaitStrategy{waitTime: s.WaitTime}, Env: map[string]string{ "ZEEBE_BROKER_NETWORK_HOST": "0.0.0.0", "ZEEBE_BROKER_NETWORK_ADVERTISEDHOST": "0.0.0.0", }, - AlwaysPullImage: true, }, Started: true, } diff --git a/test/integration_test.go b/test/integration_test.go index 1278359f..a676470a 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -32,8 +32,6 @@ import ( "github.com/stretchr/testify/suite" ) -const dockerImageName = "camunda/zeebe:8.6.0-alpha5" - type integrationTestSuite struct { *containersuite.ContainerSuite client zbc.Client @@ -42,8 +40,7 @@ type integrationTestSuite struct { func TestIntegration(t *testing.T) { suite.Run(t, &integrationTestSuite{ ContainerSuite: &containersuite.ContainerSuite{ - WaitTime: time.Second, - ContainerImage: dockerImageName, + WaitTime: time.Second, }, }) } @@ -451,8 +448,7 @@ func TestSlowWorker(t *testing.T) { suite.Run(t, &slowWorkerSuite{ integrationTestSuite: &integrationTestSuite{ ContainerSuite: &containersuite.ContainerSuite{ - WaitTime: time.Second, - ContainerImage: dockerImageName, + WaitTime: time.Second, Env: map[string]string{ "ZEEBE_DEBUG": "true", "ZEEBE_LOG_LEVEL": "debug",