Skip to content

Commit

Permalink
test: centralize zeebe image value
Browse files Browse the repository at this point in the history
  • Loading branch information
megglos committed Sep 10, 2024
1 parent 3b7da4d commit 5a026ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand Down
3 changes: 1 addition & 2 deletions cmd/zbctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
7 changes: 3 additions & 4 deletions internal/containersuite/containerSuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"google.golang.org/grpc/status"
)

const dockerImageName = "camunda/zeebe:8.6.0-alpha5"

type zeebeWaitStrategy struct {
waitTime time.Duration
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down
8 changes: 2 additions & 6 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
},
})
}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 5a026ce

Please sign in to comment.