From 8a1bdc68538adbff302b0755f0afe9afcc07e5b8 Mon Sep 17 00:00:00 2001 From: "Meggle (Sebastian Bathke)" Date: Mon, 9 Sep 2024 08:25:00 +0200 Subject: [PATCH 1/4] docs: updated readme Removed deprecation notice from camunda repo. Removed now invalid parts like gateway protocol generation and docker image build. --- README.md | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4e05ac76..3f6ab774 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,16 @@ # Zeebe Go Client -> [!WARNING] -> The Zeebe Go Client will be officially deprecated with 8.6 release as part of our efforts to streamline the Camunda 8 API experience. This client will not get released with Camunda 8.6, thus no longer receive new features and will be transitioned to a community-maintained status. - -### Why This Change? - -The decision to deprecate the Go Client aligns with our broader API strategy and resource allocation priorities. The Go Client has seen limited adoption. Moving forward, we are focusing our efforts on the Camunda 8 REST API, which offers a unified, more widely-supported approach for interacting with Zeebe and other Camunda services. - -### What Does This Mean for Users? - -* No New Features or Updates: Starting with Camunda 8.6, the Go Client will no longer receive new features, updates, or official support from Camunda. -* The official Go client and zbctl will only remain available and maintained for supported minor versions up to Camunda 8.5. -* Community Maintenance: The Go Client will be moved to [Camunda Community Hub](https://github.com/camunda-community-hub) and can be maintained by the community. We encourage contributions from users who wish to continue using and improving this client. -* Transition to REST API: We recommend users transition to the Camunda 8 REST API for all future development. The REST API provides comprehensive functionality and is supported by tools such as cURL, Postman, and OpenAPI. - -### Future Considerations - -We value feedback from our community. Based on user input, we may explore developing a new client for the Camunda 8 REST API, based on a different technology that aligns with our strategic goals and internal expertise. -For more information on the deprecation and our API strategy, please refer to the official [Camunda blog](https://camunda.com/blog/). +The Zeebe Go client is a Go wrapper implementation around the GRPC (https://github.com/grpc/grpc) generated Zeebe client. It makes it possible to communicate with Zeebe Broker via the GRPC protocol, see the [Zeebe documentation](https://docs.zeebe.io/) for more information about the Zeebe project. # Development If we had a gateway-protocol change we need to make sure that we regenerate the protobuf file, which is used by the go client. -In order to do this please follow [this guide](../../gateway-protocol-impl/README.md). ## Testing ### gRPC Mock -To regenerate the gateway mock `internal/mock_pb/mock_gateway.go` run [`mockgen`](https://github.com/golang/mock#installation) from the root of this module (`clients/go`): +To regenerate the gateway mock `internal/mock_pb/mock_gateway.go` run [`mockgen`](https://github.com/golang/mock#installation) from the root of this project: ``` mockgen -source=pkg/pb/gateway.pb.go GatewayClient,Gateway_ActivateJobsClient > internal/mock_pb/mock_gateway.go @@ -36,13 +18,6 @@ mockgen -source=pkg/pb/gateway.pb.go GatewayClient,Gateway_ActivateJobsClient > ### Integration tests -To run the integration tests, a Docker image for Zeebe must be built with the tag 'current-test'. -To do that you can run the following command from the root of this repository: - -``` -docker build --build-arg DIST=build -t camunda/zeebe:current-test . -``` - 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: ``` From 7b8994a0578af144879f919579cfeaaa971a7e81 Mon Sep 17 00:00:00 2001 From: "Meggle (Sebastian Bathke)" Date: Sun, 8 Sep 2024 09:44:40 +0200 Subject: [PATCH 2/4] test: use zeebe 8.6.0-alpha5 for tests --- cmd/zbctl/main_test.go | 2 +- internal/containersuite/containerSuite.go | 23 +---------------------- test/integration_test.go | 2 +- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/cmd/zbctl/main_test.go b/cmd/zbctl/main_test.go index 8179d69a..1618e73a 100644 --- a/cmd/zbctl/main_test.go +++ b/cmd/zbctl/main_test.go @@ -252,7 +252,7 @@ func TestZbctlWithInsecureGateway(t *testing.T) { &integrationTestSuite{ ContainerSuite: &containersuite.ContainerSuite{ WaitTime: time.Second, - ContainerImage: "camunda/zeebe:current-test", + ContainerImage: "camunda/zeebe:8.6.0-alpha5", Env: map[string]string{ "ZEEBE_BROKER_GATEWAY_LONGPOLLING_ENABLED": "false", }, diff --git a/internal/containersuite/containerSuite.go b/internal/containersuite/containerSuite.go index 03711990..c44adb11 100644 --- a/internal/containersuite/containerSuite.go +++ b/internal/containersuite/containerSuite.go @@ -25,7 +25,6 @@ import ( "github.com/camunda/camunda/clients/go/v8/internal/utils" "github.com/camunda/camunda/clients/go/v8/pkg/pb" "github.com/camunda/camunda/clients/go/v8/pkg/zbc" - "github.com/docker/docker/client" "github.com/docker/go-connections/nat" "github.com/stretchr/testify/suite" "github.com/testcontainers/testcontainers-go" @@ -206,6 +205,7 @@ func (s *ContainerSuite) SetupSuite() { "ZEEBE_BROKER_NETWORK_HOST": "0.0.0.0", "ZEEBE_BROKER_NETWORK_ADVERTISEDHOST": "0.0.0.0", }, + AlwaysPullImage: true, }, Started: true, } @@ -216,10 +216,6 @@ func (s *ContainerSuite) SetupSuite() { } ctx := context.Background() - err = validateImageExists(ctx, s.ContainerImage) - if err != nil { - s.T().Fatal(err) - } s.container, err = testcontainers.GenericContainer(ctx, req) if err != nil { @@ -258,20 +254,3 @@ func (s *ContainerSuite) TearDownSuite() { s.T().Fatal(err) } } - -func validateImageExists(ctx context.Context, image string) error { - dockerClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) - if err != nil { - return fmt.Errorf("failed creating docker client: %w", err) - } - - _, _, err = dockerClient.ImageInspectWithRaw(ctx, image) - if err != nil { - if client.IsErrNotFound(err) { - return fmt.Errorf("a Docker image containing Zeebe must be built and named '%s'", image) - } - - return err - } - return nil -} diff --git a/test/integration_test.go b/test/integration_test.go index 78d00291..1278359f 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -32,7 +32,7 @@ import ( "github.com/stretchr/testify/suite" ) -const dockerImageName = "camunda/zeebe:current-test" +const dockerImageName = "camunda/zeebe:8.6.0-alpha5" type integrationTestSuite struct { *containersuite.ContainerSuite From 3b7da4d25e3140ddfdc3da949432d3030ff1fe0a Mon Sep 17 00:00:00 2001 From: "Meggle (Sebastian Bathke)" Date: Sun, 8 Sep 2024 09:45:02 +0200 Subject: [PATCH 3/4] ci: add ci workflow --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b233a3a2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: Go Client CI +on: + push: + branches: main + pull_request: { } + workflow_dispatch: { } +jobs: + go-client: + name: Go client tests + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + - name: Build Go + shell: bash + id: build-go + working-directory: cmd/zbctl + run: ./build.sh + - name: Run Go tests + working-directory: . + run: go test -mod=vendor -v ./... + go-lint: + name: Go linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + # fixed to avoid triggering false positive; see https://github.com/golangci/golangci-lint-action/issues/535 + version: v1.55.2 + # caching issues, see: https://github.com/golangci/golangci-lint-action/issues/244#issuecomment-1052190775 + skip-pkg-cache: true + skip-build-cache: true + working-directory: . + go-apidiff: + if: github.event_name == 'pull_request' + name: Go Backwards Compatibility + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + - uses: joelanford/go-apidiff@main From 5a026ce06d1acf794d6103e90760be91e21f5259 Mon Sep 17 00:00:00 2001 From: "Meggle (Sebastian Bathke)" Date: Tue, 10 Sep 2024 15:30:34 +0200 Subject: [PATCH 4/4] 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",