Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(addon): move strimzi into core
Browse files Browse the repository at this point in the history
Ref #5787
squakez committed Oct 27, 2024
1 parent e1d4854 commit 14dd7b1
Showing 38 changed files with 666 additions and 145 deletions.
1 change: 0 additions & 1 deletion .github/actions/automatic-updates/action.yml
Original file line number Diff line number Diff line change
@@ -64,7 +64,6 @@ runs:
# Remove mock and generated code from account
grep -v "github.com/apache/camel-k/v2/pkg/client" coverage.out \
| grep -v "zz_generated" \
| grep -v "github.com/apache/camel-k/v2/addons/strimzi/duck/" \
| grep -v "github.com/apache/camel-k/v2/addons/keda/duck/" \
| grep -v "github.com/apache/camel-k/v2/cmd/util" > coverage.mod.out
go tool cover -func=coverage.mod.out -o=coverage.mod.out
2 changes: 0 additions & 2 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -56,7 +56,6 @@ runs:
# Remove mock and generated code from account
grep -v "github.com/apache/camel-k/v2/pkg/client" coverage.out \
| grep -v "zz_generated" \
| grep -v "github.com/apache/camel-k/v2/addons/strimzi/duck/" \
| grep -v "github.com/apache/camel-k/v2/addons/keda/duck/" \
| grep -v "github.com/apache/camel-k/v2/cmd/util" > coverage.mod.out
go tool cover -func=coverage.mod.out -o=coverage.mod.out
@@ -79,7 +78,6 @@ runs:
# Remove mock and generated code from account
grep -v "github.com/apache/camel-k/v2/pkg/client" coverage.out \
| grep -v "zz_generated" \
| grep -v "github.com/apache/camel-k/v2/addons/strimzi/duck/" \
| grep -v "github.com/apache/camel-k/v2/addons/keda/duck/" \
| grep -v "github.com/apache/camel-k/v2/cmd/util" > coverage.mod.out
go tool cover -func=coverage.mod.out -o=coverage.mod.out
85 changes: 85 additions & 0 deletions .github/workflows/kafka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

name: kafka

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
pull_request:
branches:
- main
- "release-*"
paths-ignore:
- 'docs/**'
- 'java/**'
- 'proposals/**'
- '**.adoc'
- '**.md'
- 'KEYS'
- 'LICENSE'
- 'NOTICE'
push:
branches:
- main
- "release-*"
paths-ignore:
- 'docs/**'
- 'java/**'
- 'proposals/**'
- '**.adoc'
- '**.md'
- 'KEYS'
- 'LICENSE'
- 'NOTICE'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
kafka-test:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive

- name: Infra setting
uses: ./.github/actions/infra-setting

- name: Install Kafka
shell: bash
run: |
./e2e/kafka/setup/setup.sh
- name: Install operator
shell: bash
run: |
kubectl create ns camel-k
make install-k8s-global
kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=60s
- name: Run test
shell: bash
run: |
DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-kafka
28 changes: 0 additions & 28 deletions addons/register_strimzi.go

This file was deleted.

45 changes: 18 additions & 27 deletions script/gen_client_strimzi.sh → e2e/kafka/files/kafka-to-log.yaml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
#!/bin/sh

# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

location=$(dirname $0)
rootdir=$location/..

GO111MODULE=on

echo "Generating Go client code for Strimzi addon..."

cd $rootdir

$(go env GOPATH)/bin/client-gen \
-h script/headers/default.txt \
--input duck/v1beta2 \
--input-base=github.com/apache/camel-k/v2/addons/strimzi \
--output-base=. \
--output-package=github.com/apache/camel-k/v2/addons/strimzi/duck/client

rm -r ./addons/strimzi/duck/client || true

mv github.com/apache/camel-k/v2/addons/strimzi/duck/client ./addons/strimzi/duck/

rm -r ./github.com
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: kafka-to-log
namespace: kafka
spec:
sink:
uri: log:info
source:
ref:
kind: Kafka
apiVersion: kafka.strimzi.io/v1beta2
name: my-cluster
properties:
topic: my-topic-autogen
29 changes: 29 additions & 0 deletions e2e/kafka/files/kafkatopic-to-log.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: kafkatopic-to-log
namespace: kafka
spec:
sink:
uri: log:info
source:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta2
name: my-topic
31 changes: 31 additions & 0 deletions e2e/kafka/files/timer-to-kafka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: timer-to-kafka
namespace: kafka
spec:
source:
uri: timer:foo
sink:
ref:
kind: Kafka
apiVersion: kafka.strimzi.io/v1beta2
name: my-cluster
properties:
topic: my-topic-autogen
29 changes: 29 additions & 0 deletions e2e/kafka/files/timer-to-kafkatopic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: timer-to-kafkatopic
namespace: kafka
spec:
source:
uri: timer:foo
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta2
name: my-topic
66 changes: 66 additions & 0 deletions e2e/kafka/kafka_binding_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//go:build integration
// +build integration

// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"

/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kafka

import (
"context"
"testing"

. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
)

func TestKafka(t *testing.T) {
WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
// NOTE: all resources are local to kafka namespace
t.Run("Strimzi Kafka resource", func(t *testing.T) {
ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/timer-to-kafka.yaml"))
// Wait for the readiness of the Integration
g.Eventually(IntegrationConditionStatus(t, ctx, "kafka", "timer-to-kafka", v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))
ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/kafka-to-log.yaml"))
g.Eventually(IntegrationConditionStatus(t, ctx, "kafka", "kafka-to-log", v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))
// Verify we are consuming some record (the body is null as the timer is pushing nothing)
g.Eventually(IntegrationLogs(t, ctx, "kafka", "kafka-to-log")).Should(ContainSubstring("Body is null"))
})

t.Run("Strimzi KafkaTopic resource", func(t *testing.T) {
ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/timer-to-kafkatopic.yaml"))
// Wait for the readiness of the Integration
g.Eventually(IntegrationConditionStatus(t, ctx, "kafka", "timer-to-kafkatopic", v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))
ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/kafkatopic-to-log.yaml"))
g.Eventually(IntegrationConditionStatus(t, ctx, "kafka", "kafkatopic-to-log", v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))
// Verify we are consuming some record (the body is null as the timer is pushing nothing)
g.Eventually(IntegrationLogs(t, ctx, "kafka", "kafkatopic-to-log")).Should(ContainSubstring("Body is null"))
})

// Clean Kafka namespace, where all reasource are statically set
ExpectExecSucceed(t, g, Kubectl("delete", "namespace", "kafka"))
})
}
Loading

0 comments on commit 14dd7b1

Please sign in to comment.