Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Koperator end to end tests #987

Merged
merged 22 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
Expand All @@ -96,7 +96,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
Expand All @@ -112,7 +112,7 @@ require (
github.com/wayneashleyberry/terminal-dimensions v1.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sys v0.6.0 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY=
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down Expand Up @@ -369,8 +369,9 @@ github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/pavlo-v-chernykh/keystore-go/v4 v4.4.1 h1:FyBdsRqqHH4LctMLL+BL2oGO+ONcIPwn96ctofCVtNE=
github.com/pavlo-v-chernykh/keystore-go/v4 v4.4.1/go.mod h1:lAVhWwbNaveeJmxrxuSTxMgKpF6DjnuVpn6T8WiBwYQ=
github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -493,8 +494,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
167 changes: 83 additions & 84 deletions tests/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,95 +14,94 @@

package e2e

// HelmDescriptors.
var (
// certManagerHelmDescriptor describes the cert-manager Helm component.
certManagerHelmDescriptor = helmDescriptor{
Repository: "https://charts.jetstack.io",
ChartName: "cert-manager",
ChartVersion: "v1.11.0",
ReleaseName: "cert-manager",
Namespace: "cert-manager",
SetValues: map[string]string{
"installCRDs": "true",
},
RemoteCRDPathVersionTemplate: "https://github.com/jetstack/cert-manager/releases/download/v%s/cert-manager.crds.yaml",
}
import "time"

// koperatorLocalHelmDescriptor describes the Koperator Helm component with
// a local chart and version.
koperatorLocalHelmDescriptor = helmDescriptor{
Repository: "../../charts/kafka-operator",
ChartVersion: LocalVersion,
ReleaseName: "kafka-operator",
Namespace: "kafka",
SetValues: map[string]string{
"crd.enabled": "true",
},
LocalCRDSubpaths: []string{"templates/crds.yaml"},
LocalCRDTemplateRenderValues: map[string]string{
"crd.enabled": "true",
},
}
const (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really somewhat unsure if we should handle these consts like this. Instead I'd think it would be better to have them locally where they are relevant. Like for example we keep this file for stuff that we use everywhere, like default timeouts, some templates, that sort of thing. We also move all of the other stuff to where they are relevant, like kcat to the listener tests or zookeeper kind to the zookeeper tests.

What do others think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I better like this. I dont have to find const variables in different places especially when they can be used in other test files. Im not sure yet which const variable will be not used in another tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Im working and dont know have we got const variable for this so far or not then it is better to just check the const.go and use if there is. I dont like to waste time for searching in multiple files.


// koperatorLocalHelmDescriptor describes the Koperator Helm component with
// a remote latest chart and version.
koperatorRemoteLatestHelmDescriptor = helmDescriptor{ //nolint:unused // Note: intentional possibly needed in the future for upgrade test.
Repository: "https://kubernetes-charts.banzaicloud.com",
ChartName: "kafka-operator",
ChartVersion: "", // Note: empty string translates to latest final version.
ReleaseName: "kafka-operator",
Namespace: "kafka",
SetValues: map[string]string{
"crd.enabled": "true",
},
RemoteCRDPathVersionTemplate: "https://github.com/banzaicloud/koperator/releases/download/%s/kafka-operator.crds.yaml",
}
// LocalVersion means using the files in the local repository snapshot.
LocalVersion Version = "local"

kubectlArgGoTemplateName = `-o=go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'`
kubectlArgGoTemplateKindNameNamespace = `-o=go-template='{{range .items}}{{.kind}}{{"/"}}{{.metadata.name}}{{if .metadata.namespace}}{{"."}}{{.metadata.namespace}}{{end}}{{"\n"}}{{end}}'`
kubectlArgGoTemplateInternalListenersName = `-o=go-template='{{range $key,$value := .status.listenerStatuses.internalListeners}}{{$key}}{{"\n"}}{{end}}`
kubectlArgGoTemplateInternalListenerAddressesTemplate = `-o=go-template='{{range .status.listenerStatuses.internalListeners.%s}}{{.address}}{{"\n"}}{{end}}`
// kubectlArgGoTemplateExternalListenersName = `-o=go-template='{{range $key,$value := .status.listenerStatuses.externallListeners}}{{$key}}{{"\n"}}{{end}}`
// kubectlArgGoTemplateExternalListenerAddressesTemplate = `-o=go-template='{{range .status.listenerStatuses.externalListeners.%s}}{{.address}}{{"\n"}}{{end}}`

crdKind = "customresourcedefinitions.apiextensions.k8s.io"
kafkaKind = "kafkaclusters.kafka.banzaicloud.io"
kafkaTopicKind = "kafkatopics.kafka.banzaicloud.io"
kafkaClusterName = "kafka"
testTopicName = "topic-test"
kcatPodName = "kcat"
zookeeperKind = "zookeeperclusters.zookeeper.pravega.io"
zookeeperClusterName = "zookeeper-server"
managedByHelmLabelTemplate = "app.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=%s"

defaultDeletionTimeout = 20 * time.Second
defaultPodReadinessWaitTime = 10 * time.Second
defaultTopicCreationWaitTime = 10 * time.Second
kafkaClusterResourceCleanupTimeout = 30 * time.Second
zookeeperClusterResourceCleanupTimeout = 60 * time.Second
externalConsumerTimeout = 5 * time.Second
externalProducerTimeout = 5 * time.Second

kcatPodTemplate = "templates/kcat.yaml.tmpl"
kafkaTopicTemplate = "templates/topic.yaml.tmpl"

// prometheusOperatorHelmDescriptor describes the prometheus-operator Helm
// component.
prometheusOperatorHelmDescriptor = helmDescriptor{
Repository: "https://prometheus-community.github.io/helm-charts",
ChartName: "kube-prometheus-stack",
ChartVersion: "42.0.1",
ReleaseName: "prometheus-operator",
Namespace: "prometheus",
SetValues: map[string]string{
"prometheusOperator.createCustomResource": "true",
"defaultRules.enabled": "false",
"alertmanager.enabled": "false",
"grafana.enabled": "false",
"kubeApiServer.enabled": "false",
"kubelet.enabled": "false",
"kubeControllerManager.enabled": "false",
"coreDNS.enabled": "false",
"kubeEtcd.enabled": "false",
"kubeScheduler.enabled": "false",
"kubeProxy.enabled": "false",
"kubeStateMetrics.enabled": "false",
"nodeExporter.enabled": "false",
"prometheus.enabled": "false",
},
kubectlNotFoundErrorMsg = "NotFound"
)

func apiGroupKoperatorDependencies() map[string]string {
return map[string]string{
"cert-manager": "cert-manager.io",
"zookeeper": "zookeeper.pravega.io",
"prometheus": "monitoring.coreos.com",
}
}

// zookeeperOperatorHelmDescriptor describes the zookeeper-operator Helm
// component.
zookeeperOperatorHelmDescriptor = helmDescriptor{
Repository: "https://charts.pravega.io",
ChartName: "zookeeper-operator",
ChartVersion: "0.2.14",
ReleaseName: "zookeeper-operator",
Namespace: "zookeeper",
SetValues: map[string]string{
"crd.create": "true",
},
func basicK8sResourceKinds() []string {
return []string{
"pods",
"services",
"deployments.apps",
pregnor marked this conversation as resolved.
Show resolved Hide resolved
"daemonset.apps",
"replicasets.apps",
"statefulsets.apps",
"secrets",
"serviceaccounts",
"configmaps",
"mutatingwebhookconfigurations.admissionregistration.k8s.io",
"validatingwebhookconfigurations.admissionregistration.k8s.io",
"jobs.batch",
"cronjobs.batch",
"poddisruptionbudgets.policy",
"podsecuritypolicies.policy",
"persistentvolumeclaims",
"persistentvolumes",
}
)
}

// Versions.
type Version = string
func koperatorCRDs() []string {
return []string{
"kafkatopics.kafka.banzaicloud.io",
"kafkaclusters.kafka.banzaicloud.io",
"kafkausers.kafka.banzaicloud.io",
"cruisecontroloperations.kafka.banzaicloud.io",
}
}

const (
// LocalVersion means using the files in the local repository snapshot.
LocalVersion Version = "local"
)
func koperatorRelatedResourceKinds() []string {
return []string{
"nodepoollabelsets.labels.banzaicloud.io",
"kafkatopics.kafka.banzaicloud.io",
"kafkaclusters.kafka.banzaicloud.io",
"kafkausers.kafka.banzaicloud.io",
"cruisecontroloperations.kafka.banzaicloud.io",
"istiomeshgateways.servicemesh.cisco.com",
"virtualservices.networking.istio.io",
"gateways.networking.istio.io",
"clusterissuers.cert-manager.io",
"servicemonitors.monitoring.coreos.com",
}
}
111 changes: 111 additions & 0 deletions tests/e2e/global.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright © 2023 Cisco Systems, Inc. and/or its affiliates
//
// Licensed 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 e2e

import (
"errors"
)

// HelmDescriptors.
var (
// certManagerHelmDescriptor describes the cert-manager Helm component.
certManagerHelmDescriptor = helmDescriptor{
Repository: "https://charts.jetstack.io",
ChartName: "cert-manager",
ChartVersion: "v1.11.0",
ReleaseName: "cert-manager",
Namespace: "cert-manager",
SetValues: map[string]string{
"installCRDs": "true",
},
RemoteCRDPathVersionTemplate: "https://github.com/jetstack/cert-manager/releases/download/v%s/cert-manager.crds.yaml",
}

// koperatorLocalHelmDescriptor describes the Koperator Helm component with
// a local chart and version.
koperatorLocalHelmDescriptor = helmDescriptor{
Repository: "../../charts/kafka-operator",
ChartVersion: LocalVersion,
ReleaseName: "kafka-operator",
Namespace: "kafka",
SetValues: map[string]string{
"crd.enabled": "true",
},
LocalCRDSubpaths: []string{"templates/crds.yaml"},
LocalCRDTemplateRenderValues: map[string]string{
"crd.enabled": "true",
},
}

// koperatorLocalHelmDescriptor describes the Koperator Helm component with
// a remote latest chart and version.
koperatorRemoteLatestHelmDescriptor = helmDescriptor{ //nolint:unused // Note: intentional possibly needed in the future for upgrade test.
Repository: "https://kubernetes-charts.banzaicloud.com",
ChartName: "kafka-operator",
ChartVersion: "", // Note: empty string translates to latest final version.
ReleaseName: "kafka-operator",
Namespace: "kafka",
SetValues: map[string]string{
"crd.enabled": "true",
},
RemoteCRDPathVersionTemplate: "https://github.com/banzaicloud/koperator/releases/download/%s/kafka-operator.crds.yaml",
}

// prometheusOperatorHelmDescriptor describes the prometheus-operator Helm
// component.
prometheusOperatorHelmDescriptor = helmDescriptor{
Repository: "https://prometheus-community.github.io/helm-charts",
ChartName: "kube-prometheus-stack",
ChartVersion: "42.0.1",
ReleaseName: "prometheus-operator",
Namespace: "prometheus",
SetValues: map[string]string{
"prometheusOperator.createCustomResource": "true",
"defaultRules.enabled": "false",
"alertmanager.enabled": "false",
"grafana.enabled": "false",
"kubeApiServer.enabled": "false",
"kubelet.enabled": "false",
"kubeControllerManager.enabled": "false",
"coreDNS.enabled": "false",
"kubeEtcd.enabled": "false",
"kubeScheduler.enabled": "false",
"kubeProxy.enabled": "false",
"kubeStateMetrics.enabled": "false",
"nodeExporter.enabled": "false",
"prometheus.enabled": "false",
},
}

// zookeeperOperatorHelmDescriptor describes the zookeeper-operator Helm
// component.
zookeeperOperatorHelmDescriptor = helmDescriptor{
Repository: "https://charts.pravega.io",
ChartName: "zookeeper-operator",
ChartVersion: "0.2.14",
ReleaseName: "zookeeper-operator",
Namespace: "zookeeper",
SetValues: map[string]string{
"crd.create": "true",
},
}

// dependencyCRDs storing the Koperator dependencies CRDs name
// It should be initialized once with the Initialize() member function
dependencyCRDs dependencyCRDsType

// ErrorNotFound is for handling that error case when resource is not found
ErrorNotFound = errors.New("not found")
)
6 changes: 6 additions & 0 deletions tests/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ require (
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
Expand All @@ -38,13 +41,16 @@ require (
github.com/gruntwork-io/go-commons v0.8.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
Loading