-
Notifications
You must be signed in to change notification settings - Fork 198
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
Changes from 1 commit
6df5501
bd41f3b
bdce649
d9331f2
b796dcd
9d78d96
2cd5d0d
5dd0266
46b2d71
16f2904
2b05149
c315b37
1d66fe3
d68b2ca
53694b9
cc6b1fc
63ed2cd
3addfae
3efc5f9
abea29c
b6683a2
917afad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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") | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,17 @@ func testUninstall() bool { | |
var kubectlOptions k8s.KubectlOptions | ||
var err error | ||
|
||
It("Acquiring K8s config and context", func() { | ||
kubectlOptions, err = kubectlOptionsForCurrentContext() | ||
Expect(err).NotTo(HaveOccurred()) | ||
When("Initializing", func() { | ||
It("Acquiring K8s config and context", func() { | ||
kubectlOptions, err = kubectlOptionsForCurrentContext() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("Setting globals", func() { | ||
err := dependencyCRDs.Initialize(kubectlOptions) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
Comment on lines
+34
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This needs to be moved to the per case before once we handle that ticket. Nothing to do now. |
||
|
||
}) | ||
|
||
requireUninstallingKoperator(k8s.KubectlOptions{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package e2e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (For some reason my file level commend does not work this morning.) Optional: IMO this other than the version type which I commented, the rest of the file would fit into I'm fine to leave this here if others agree it's more clear this way, but it's weird for me. |
||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gruntwork-io/terratest/modules/k8s" | ||
) | ||
|
||
// Versions. | ||
type Version = string | ||
pregnor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type dependencyCRDsType struct { | ||
zookeeper []string | ||
prometheus []string | ||
certManager []string | ||
} | ||
|
||
func (c *dependencyCRDsType) Zookeeper() []string { | ||
return c.zookeeper | ||
} | ||
func (c *dependencyCRDsType) Prometheus() []string { | ||
return c.prometheus | ||
} | ||
func (c *dependencyCRDsType) CertManager() []string { | ||
return c.certManager | ||
} | ||
|
||
func (c *dependencyCRDsType) Initialize(kubectlOptions k8s.KubectlOptions) error { | ||
var err error | ||
c.certManager, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["cert-manager"]) | ||
if len(c.certManager) == 0 { | ||
if err != nil { | ||
return fmt.Errorf("initialize Cert-manager CRDs error: %w", err) | ||
} | ||
return fmt.Errorf("Cert-manager CRDs %w", ErrorNotFound) | ||
} | ||
c.prometheus, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["prometheus"]) | ||
if len(c.prometheus) == 0 { | ||
if err != nil { | ||
return fmt.Errorf("initialize Prometheus CRDs error: %w", err) | ||
} | ||
return fmt.Errorf("Prometheus CRDs %w", ErrorNotFound) | ||
} | ||
c.zookeeper, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["zookeeper"]) | ||
if len(c.zookeeper) == 0 { | ||
if err != nil { | ||
return fmt.Errorf("initialize Zookeeper CRDs error: %w", err) | ||
} | ||
return fmt.Errorf("Zookeeper CRDs %w", ErrorNotFound) | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.