diff --git a/Makefile b/Makefile index 3b6dce3c6..525810c2e 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ container: docker build -t $(REPO):$(TAG) . e2e-test: - go test -timeout 20m -v ./test/migration/ $(TEST_RUN_ARGS) --kubeconfig "$(HOME)/.kube/config" --operator-image=$(REPO):$(TAG) --namespace=$(NAMESPACE) --cluster-ip=$(CLUSTER_IP) + go test -timeout 20m -v ./test/migration/ $(TEST_RUN_ARGS) --kubeconfig=$(KUBECONFIG) --operator-image=$(REPO):$(TAG) --namespace=$(NAMESPACE) go test -timeout 20m -v ./test/e2e/ $(TEST_RUN_ARGS) --kubeconfig=$(KUBECONFIG) --operator-image=$(REPO):$(TAG) --namespace=$(NAMESPACE) e2e-status: diff --git a/test/e2e/alertmanager_test.go b/test/e2e/alertmanager_test.go index e9ccb7f92..b9a88bd89 100644 --- a/test/e2e/alertmanager_test.go +++ b/test/e2e/alertmanager_test.go @@ -23,7 +23,7 @@ import ( "k8s.io/client-go/pkg/api/v1" "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1alpha1" - testFramework "github.com/coreos/prometheus-operator/test/e2e/framework" + testFramework "github.com/coreos/prometheus-operator/test/framework" ) func TestAlertmanagerCreateDeleteCluster(t *testing.T) { diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 1be8b16d4..725502b28 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -20,7 +20,7 @@ import ( "os" "testing" - operatorFramework "github.com/coreos/prometheus-operator/test/e2e/framework" + operatorFramework "github.com/coreos/prometheus-operator/test/framework" ) var framework *operatorFramework.Framework diff --git a/test/e2e/prometheus_test.go b/test/e2e/prometheus_test.go index a7ee6061b..1103c3f5b 100644 --- a/test/e2e/prometheus_test.go +++ b/test/e2e/prometheus_test.go @@ -1,4 +1,4 @@ -// Copyright 2016 The prometheus-operator Authors +/// Copyright 2016 The prometheus-operator Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import ( "github.com/coreos/prometheus-operator/pkg/alertmanager" "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1alpha1" "github.com/coreos/prometheus-operator/pkg/prometheus" - testFramework "github.com/coreos/prometheus-operator/test/e2e/framework" + testFramework "github.com/coreos/prometheus-operator/test/framework" "github.com/pkg/errors" ) diff --git a/test/e2e/framework/alertmanager.go b/test/framework/alertmanager.go similarity index 100% rename from test/e2e/framework/alertmanager.go rename to test/framework/alertmanager.go diff --git a/test/e2e/framework/cluster_role.go b/test/framework/cluster_role.go similarity index 100% rename from test/e2e/framework/cluster_role.go rename to test/framework/cluster_role.go diff --git a/test/e2e/framework/cluster_role_binding.go b/test/framework/cluster_role_binding.go similarity index 100% rename from test/e2e/framework/cluster_role_binding.go rename to test/framework/cluster_role_binding.go diff --git a/test/e2e/framework/context.go b/test/framework/context.go similarity index 100% rename from test/e2e/framework/context.go rename to test/framework/context.go diff --git a/test/e2e/framework/deployment.go b/test/framework/deployment.go similarity index 100% rename from test/e2e/framework/deployment.go rename to test/framework/deployment.go diff --git a/test/e2e/framework/framework.go b/test/framework/framework.go similarity index 92% rename from test/e2e/framework/framework.go rename to test/framework/framework.go index f1d13f2d1..d951ec331 100644 --- a/test/e2e/framework/framework.go +++ b/test/framework/framework.go @@ -19,6 +19,7 @@ import ( "testing" "time" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/client-go/kubernetes" @@ -93,19 +94,19 @@ func (f *Framework) Setup(opImage string) error { } func (f *Framework) setupPrometheusOperator(opImage string) error { - if _, err := CreateServiceAccount(f.KubeClient, f.Namespace.Name, "../../example/rbac/prometheus-operator/prometheus-operator-service-account.yaml"); err != nil { + if _, err := CreateServiceAccount(f.KubeClient, f.Namespace.Name, "../../example/rbac/prometheus-operator/prometheus-operator-service-account.yaml"); err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "failed to create prometheus operator service account") } - if err := CreateClusterRole(f.KubeClient, "../../example/rbac/prometheus-operator/prometheus-operator-cluster-role.yaml"); err != nil { + if err := CreateClusterRole(f.KubeClient, "../../example/rbac/prometheus-operator/prometheus-operator-cluster-role.yaml"); err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "failed to create prometheus cluster role") } - if _, err := CreateClusterRoleBinding(f.KubeClient, f.Namespace.Name, "../../example/rbac/prometheus-operator/prometheus-operator-cluster-role-binding.yaml"); err != nil { + if _, err := CreateClusterRoleBinding(f.KubeClient, f.Namespace.Name, "../../example/rbac/prometheus-operator/prometheus-operator-cluster-role-binding.yaml"); err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "failed to create prometheus cluster role binding") } - if err := CreateClusterRole(f.KubeClient, "../../example/rbac/prometheus/prometheus-cluster-role.yaml"); err != nil { + if err := CreateClusterRole(f.KubeClient, "../../example/rbac/prometheus/prometheus-cluster-role.yaml"); err != nil && !apierrors.IsAlreadyExists(err) { return errors.Wrap(err, "failed to create prometheus cluster role") } @@ -156,7 +157,7 @@ func (ctx *TestCtx) SetupPrometheusRBAC(t *testing.T, ns string, kubeClient kube ctx.AddFinalizerFn(finalizerFn) } - if finalizerFn, err := CreateRoleBinding(kubeClient, ns, "framework/ressources/prometheus-role-binding.yml"); err != nil { + if finalizerFn, err := CreateRoleBinding(kubeClient, ns, "../framework/ressources/prometheus-role-binding.yml"); err != nil { t.Fatal(errors.Wrap(err, "failed to create prometheus role binding")) } else { ctx.AddFinalizerFn(finalizerFn) diff --git a/test/e2e/framework/helpers.go b/test/framework/helpers.go similarity index 100% rename from test/e2e/framework/helpers.go rename to test/framework/helpers.go diff --git a/test/e2e/framework/ingress.go b/test/framework/ingress.go similarity index 100% rename from test/e2e/framework/ingress.go rename to test/framework/ingress.go diff --git a/test/e2e/framework/namespace.go b/test/framework/namespace.go similarity index 100% rename from test/e2e/framework/namespace.go rename to test/framework/namespace.go diff --git a/test/e2e/framework/prometheus.go b/test/framework/prometheus.go similarity index 100% rename from test/e2e/framework/prometheus.go rename to test/framework/prometheus.go diff --git a/test/e2e/framework/replication-controller.go b/test/framework/replication-controller.go similarity index 100% rename from test/e2e/framework/replication-controller.go rename to test/framework/replication-controller.go diff --git a/test/e2e/framework/ressources/default-http-backend-service.yml b/test/framework/ressources/default-http-backend-service.yml similarity index 100% rename from test/e2e/framework/ressources/default-http-backend-service.yml rename to test/framework/ressources/default-http-backend-service.yml diff --git a/test/e2e/framework/ressources/default-http-backend.yml b/test/framework/ressources/default-http-backend.yml similarity index 100% rename from test/e2e/framework/ressources/default-http-backend.yml rename to test/framework/ressources/default-http-backend.yml diff --git a/test/e2e/framework/ressources/nxginx-ingress-controller.yml b/test/framework/ressources/nxginx-ingress-controller.yml similarity index 100% rename from test/e2e/framework/ressources/nxginx-ingress-controller.yml rename to test/framework/ressources/nxginx-ingress-controller.yml diff --git a/test/e2e/framework/ressources/prometheus-role-binding.yml b/test/framework/ressources/prometheus-role-binding.yml similarity index 100% rename from test/e2e/framework/ressources/prometheus-role-binding.yml rename to test/framework/ressources/prometheus-role-binding.yml diff --git a/test/e2e/framework/role-binding.go b/test/framework/role-binding.go similarity index 100% rename from test/e2e/framework/role-binding.go rename to test/framework/role-binding.go diff --git a/test/e2e/framework/service.go b/test/framework/service.go similarity index 100% rename from test/e2e/framework/service.go rename to test/framework/service.go diff --git a/test/e2e/framework/service_account.go b/test/framework/service_account.go similarity index 100% rename from test/e2e/framework/service_account.go rename to test/framework/service_account.go diff --git a/test/e2e/framework/third_party_ressource.go b/test/framework/third_party_ressource.go similarity index 100% rename from test/e2e/framework/third_party_ressource.go rename to test/framework/third_party_ressource.go diff --git a/test/migration/migration_test.go b/test/migration/migration_test.go index 14c8a8fef..f960be32f 100644 --- a/test/migration/migration_test.go +++ b/test/migration/migration_test.go @@ -10,7 +10,7 @@ import ( "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1alpha1" "github.com/coreos/prometheus-operator/pkg/k8sutil" - operatorFramework "github.com/coreos/prometheus-operator/test/e2e/framework" + operatorFramework "github.com/coreos/prometheus-operator/test/framework" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -24,7 +24,6 @@ func TestMain(m *testing.M) { kubeconfig = flag.String("kubeconfig", "", "kube config path, e.g. $HOME/.kube/config") opImage = flag.String("operator-image", "", "operator image, e.g. quay.io/coreos/prometheus-operator") ns = flag.String("namespace", "prometheus-operator-e2e-tests", "e2e test namespace") - ip = flag.String("cluster-ip", "", "ip of the kubernetes cluster to use for external requests") flag.Parse() os.Exit(m.Run()) @@ -68,7 +67,6 @@ func TestMigration(t *testing.T) { *ns, *kubeconfig, "quay.io/coreos/prometheus-operator:v0.10.2", - *ip, ); err != nil { log.Printf("failed to setup framework: %v\n", err) t.Fatal(err) @@ -77,6 +75,7 @@ func TestMigration(t *testing.T) { ctx := framework.NewTestCtx(t) defer ctx.Cleanup(t) ns2 := ctx.CreateNamespace(t, framework.KubeClient) + ctx.SetupPrometheusRBAC(t, ns2, framework.KubeClient) // Launch the objects. name := "test"