Skip to content

Commit

Permalink
Add e2e tests for support to Prometheus by Operator
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Oct 12, 2019
1 parent 937688e commit c4294c6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/e2e/utils/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
)

const certmanagerVersion = "v0.10.1"
const prometheusOperatorVersion= "0.33"

// KBTestContext specified to run e2e tests
type KBTestContext struct {
Expand Down Expand Up @@ -94,6 +95,19 @@ func (kc *KBTestContext) InstallCertManager() error {
return err
}

// InstallPrometheusOperManager installs the prometheus manager bundle.
func (kc *KBTestContext) InstallPrometheusOperManager() error {
_, err := kc.Kubectl.Apply(false, "-f", fmt.Sprintf("https://raw.githubusercontent.com/coreos/prometheus-operator/release-%s/bundle.yaml", prometheusOperatorVersion))
return err
}

// UninstallPrometheusOperManager uninstalls the prometheus manager bundle.
func (kc *KBTestContext) UninstallPrometheusOperManager() {
if _, err := kc.Kubectl.Delete(false, "-f", fmt.Sprintf("https://github.com/coreos/prometheus-operator/blob/release-%s/bundle.yaml", prometheusOperatorVersion)); err != nil {
fmt.Fprintf(GinkgoWriter, "error when running kubectl delete during cleaning up prometheus bundle: %v\n", err)
}
}

// UninstallCertManager uninstalls the cert manager bundle.
func (kc *KBTestContext) UninstallCertManager() {
if _, err := kc.Kubectl.Delete(false, "-f", fmt.Sprintf("https://github.com/jetstack/cert-manager/releases/download/%s/cert-manager.yaml", certmanagerVersion)); err != nil {
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/v2/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ var _ = Describe("kubebuilder", func() {

By("installing cert manager bundle")
Expect(kbc.InstallCertManager()).To(Succeed())

By("installing prometheus operator")
Expect(kbc.InstallPrometheusOperManager()).To(Succeed())
})

AfterEach(func() {
By("clean up created API objects during test process")
kbc.CleanupManifests(filepath.Join("config", "default"))

By("uninstalling prometheus manager bundle")
kbc.UninstallPrometheusOperManager()

By("uninstalling cert manager bundle")
kbc.UninstallCertManager()

Expand Down Expand Up @@ -104,6 +110,9 @@ var _ = Describe("kubebuilder", func() {
Expect(utils.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../certmanager", "#")).To(Succeed())
Expect(utils.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../prometheus", "#")).To(Succeed())
Expect(utils.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- manager_webhook_patch.yaml", "#")).To(Succeed())
Expand Down Expand Up @@ -189,6 +198,20 @@ var _ = Describe("kubebuilder", func() {
return err
}, time.Minute, time.Second).Should(Succeed())

By("validate prometheus manager has provisioned the Service")
Eventually(func() error {
_, err := kbc.Kubectl.Get(
false,
"Service", "prometheus-operator")
return err
}, time.Minute, time.Second).Should(Succeed())

By("validate Service Monitor for Prometheus is applied in the namespace")
_, err = kbc.Kubectl.Get(
true,
"ServiceMonitor")
Expect(err).NotTo(HaveOccurred())

By("validate the mutating|validating webhooks have the CA injected")
verifyCAInjection := func() error {
mwhOutput, err := kbc.Kubectl.Get(
Expand Down

0 comments on commit c4294c6

Please sign in to comment.