diff --git a/tests/e2e/generate.sh b/tests/e2e/generate.sh index 22d9679a7c..8f2bb65e5a 100755 --- a/tests/e2e/generate.sh +++ b/tests/e2e/generate.sh @@ -7,7 +7,7 @@ apiVersion: v1 kind: Secret metadata: name: aws-credentials-secret - namespace: default + namespace: openshift-machine-api-operator type: Opaque data: awsAccessKeyId: $(echo -n $(aws configure get aws_access_key_id) | base64) diff --git a/tests/e2e/infra.tf b/tests/e2e/infra.tf index c6c989eaa0..4cd7f6f9a0 100644 --- a/tests/e2e/infra.tf +++ b/tests/e2e/infra.tf @@ -27,8 +27,8 @@ module "vpc" { "10.0.103.0/24", ] - enable_nat_gateway = true - single_nat_gateway = true + enable_nat_gateway = false + single_nat_gateway = false public_subnet_tags = { Name = "${var.enviroment_id}-worker-foo" diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 74e3602d0f..7f7605148c 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -14,14 +14,12 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - operatorclient "github.com/coreos-inc/tectonic-operators/operator-client/pkg/client" - operatorclienttypes "github.com/coreos-inc/tectonic-operators/operator-client/pkg/types" "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" appsv1beta2 "k8s.io/api/apps/v1beta2" apiv1 "k8s.io/api/core/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apimachinery/pkg/api/resource" + apiextensionsscheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" @@ -37,7 +35,7 @@ const ( timeoutPoolMachineSetRunningInterval = 10 * time.Minute defaultLogLevel = "info" - targetNamespace = "default" + targetNamespace = "openshift-machine-api-operator" awsCredentialsSecretName = "aws-credentials-secret" region = "us-east-1" machineSetReplicas = 2 @@ -52,7 +50,6 @@ type TestConfig struct { CAPIClient *clientset.Clientset APIExtensionsClient *apiextensionsclientset.Clientset KubeClient *kubernetes.Clientset - OperatorClient operatorclient.Interface AWSClient *AWSClient } @@ -78,16 +75,14 @@ func NewTestConfig(kubeconfig string) *TestConfig { glog.Fatalf("Could not create kubernetes client to talk to the apiserver: %v", err) } - opclient := operatorclient.NewClient(kubeconfig) - return &TestConfig{ CAPIClient: capiclient, APIExtensionsClient: apiextensionsclient, KubeClient: kubeClient, - OperatorClient: opclient, } } +// Kube library func createNamespace(testConfig *TestConfig, namespace string) error { nsObj := &apiv1.Namespace{ ObjectMeta: metav1.ObjectMeta{ @@ -124,41 +119,6 @@ func createCRD(testConfig *TestConfig, crd *apiextensionsv1beta1.CustomResourceD }) } -func createAppVersionCRD(testConfig *TestConfig) error { - appVersion := &operatorclienttypes.AppVersion{ - TypeMeta: metav1.TypeMeta{ - Kind: "AppVersion", - APIVersion: "tco.coreos.com/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "machine-api", - Namespace: "tectonic-system", - Labels: map[string]string{ - "managed-by-channel-operator": "true", - }, - }, - Spec: operatorclienttypes.AppVersionSpec{ - DesiredVersion: "", - Paused: false, - }, - Status: operatorclienttypes.AppVersionStatus{ - CurrentVersion: "1", - Paused: false, - }, - UpgradeReq: 1, - UpgradeComp: 0, - } - - log.Infof("Creating %q AppVersion...", strings.Join([]string{appVersion.Namespace, appVersion.Name}, "/")) - if _, err := testConfig.OperatorClient.GetAppVersion("tectonic-system", "machine-api"); err != nil { - if _, err := testConfig.OperatorClient.CreateAppVersion(appVersion); err != nil { - return fmt.Errorf("unable to create AppVersion: %v", err) - } - } - - return nil -} - func createConfigMap(testConfig *TestConfig, configMap *apiv1.ConfigMap) error { log.Infof("Creating %q ConfigMap...", strings.Join([]string{configMap.Namespace, configMap.Name}, "/")) if _, err := testConfig.KubeClient.CoreV1().ConfigMaps(configMap.Namespace).Get(configMap.Name, metav1.GetOptions{}); err != nil { @@ -193,6 +153,7 @@ func createDeployment(testConfig *TestConfig, deployment *appsv1beta2.Deployment return nil } +// binary runner func cmdRun(assetsDir string, binaryPath string, args ...string) error { cmd := exec.Command(binaryPath, args...) cmd.Stdin = os.Stdin @@ -242,38 +203,32 @@ var rootCmd = &cobra.Command{ } // generate assumed namespaces - if err := createNamespace(testConfig, "tectonic-system"); err != nil { + if err := createNamespace(testConfig, targetNamespace); err != nil { return err } - // create appVersion - crd := &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "appversions.tco.coreos.com", - }, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "tco.coreos.com", - Version: "v1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "appversions", - Kind: "AppVersion", - }, - }, - } - - if err := createCRD(testConfig, crd); err != nil { - return err - } + // create status CRD + apiextensionsscheme.AddToScheme(scheme.Scheme) + decode := scheme.Codecs.UniversalDeserializer().Decode + if statusCRD, err := ioutil.ReadFile(filepath.Join(assetsPath, "manifests/status-crd.yaml")); err != nil { + glog.Fatalf("Error reading %#v", err) + } else { + CRDObj, _, err := decode([]byte(statusCRD), nil, nil) + if err != nil { + glog.Fatalf("Error decoding %#v", err) + } + CRD := CRDObj.(*apiextensionsv1beta1.CustomResourceDefinition) - if err := createAppVersionCRD(testConfig); err != nil { - return err + if err := createCRD(testConfig, CRD); err != nil { + return err + } } + // genereate mao config maoConfigTemplateData, err := ioutil.ReadFile(filepath.Join(assetsPath, "manifests/mao-config.yaml")) if err != nil { glog.Fatalf("Error reading %#v", err) } - configValues := &render.OperatorConfig{ AWS: &render.AWSConfig{ ClusterID: clusterID, @@ -281,14 +236,13 @@ var rootCmd = &cobra.Command{ Region: region, }, } - maoConfigPopulatedData, err := render.Manifests(configValues, maoConfigTemplateData) if err != nil { glog.Fatalf("Unable to render manifests %q: %v", maoConfigTemplateData, err) } else { mapConfigMap := &apiv1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: "mao-config-v1", + Name: "cluster-config-v1", Namespace: "kube-system", }, Data: map[string]string{ @@ -302,7 +256,6 @@ var rootCmd = &cobra.Command{ // secrets // create cluster api server secrets - decode := scheme.Codecs.UniversalDeserializer().Decode if secretData, err := ioutil.ReadFile(filepath.Join(assetsPath, "manifests/clusterapi-apiserver-certs.yaml")); err != nil { glog.Fatalf("Error reading %#v", err) } else { @@ -351,112 +304,30 @@ var rootCmd = &cobra.Command{ } testConfig.AWSClient = awsClient - // create operator - var replicas int32 = 1 - runAsNonRoot := true - var runAsUser int64 = 65534 - - maoManifest := &appsv1beta2.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "machine-api-operator", - Namespace: "kube-system", - Labels: map[string]string{ - "k8s-app": "machine-api-operator", - "managed-by-channel-operator": "true", - }, - }, - Spec: appsv1beta2.DeploymentSpec{ - Replicas: &replicas, - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "k8s-app": "machine-api-operator", - }, - }, - Template: apiv1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - "k8s-app": "machine-api-operator", - "managed-by-channel-operator": "true", - }, - }, - Spec: apiv1.PodSpec{ - Containers: []apiv1.Container{ - { - Name: "machine-api-operator", - Image: maoImage, - Command: []string{ - "/machine-api-operator", - }, - Args: []string{ - "-v=4", - }, - Resources: apiv1.ResourceRequirements{ - Limits: apiv1.ResourceList{ - "cpu": resource.MustParse("20m"), - "memory": resource.MustParse("50Mi"), - }, - Requests: apiv1.ResourceList{ - "cpu": resource.MustParse("20m"), - "memory": resource.MustParse("50Mi"), - }, - }, - VolumeMounts: []apiv1.VolumeMount{ - { - Name: "mao-config", - MountPath: "/etc/mao-config", - }, - }, - }, - }, - ImagePullSecrets: []apiv1.LocalObjectReference{ - { - Name: "coreos-pull-secret", - }, - }, - NodeSelector: map[string]string{ - "node-role.kubernetes.io/master": "", - }, - RestartPolicy: "Always", - SecurityContext: &apiv1.PodSecurityContext{ - RunAsNonRoot: &runAsNonRoot, - RunAsUser: &runAsUser, - }, - Tolerations: []apiv1.Toleration{ - { - Key: "node-role.kubernetes.io/master", - Operator: "Exists", - Effect: "NoSchedule", - }, - }, - Volumes: []apiv1.Volume{ - { - Name: "mao-config", - VolumeSource: apiv1.VolumeSource{ - ConfigMap: &apiv1.ConfigMapVolumeSource{ - LocalObjectReference: apiv1.LocalObjectReference{ - Name: "mao-config-v1", - }, - Items: []apiv1.KeyToPath{ - { - Key: "mao-config", - Path: "config", - }, - }, - }, - }, - }, - }, - }, - }, - }, + // create operator deployment + type deploymentValues struct { + Image string } - - if err := createDeployment(testConfig, maoManifest); err != nil { - return err + dv := deploymentValues{ + Image: maoImage, + } + if deploymentData, err := RenderTemplateFromFile(dv, filepath.Join(assetsPath, "manifests/operator-deployment.yaml")); err != nil { + glog.Fatalf("Error reading %#v", err) + } else { + deploymentObj, _, err := decode([]byte(deploymentData), nil, nil) + if err != nil { + glog.Fatalf("Error decoding %#v", err) + } + deployment := deploymentObj.(*appsv1beta2.Deployment) + if err := createDeployment(testConfig, deployment); err != nil { + return err + } } + // TESTS + // verify the cluster-api is running err = wait.Poll(pollInterval, timeoutPoolClusterAPIDeploymentInterval, func() (bool, error) { - if clusterAPIDeployment, err := testConfig.KubeClient.AppsV1beta2().Deployments("default").Get("clusterapi-apiserver", metav1.GetOptions{}); err == nil { + if clusterAPIDeployment, err := testConfig.KubeClient.AppsV1beta2().Deployments(targetNamespace).Get("clusterapi-apiserver", metav1.GetOptions{}); err == nil { // Check all the pods are running log.Infof("Waiting for all cluster-api deployment pods to be ready, have %v, expecting 1", clusterAPIDeployment.Status.ReadyReplicas) if clusterAPIDeployment.Status.ReadyReplicas < 1 { @@ -507,6 +378,7 @@ var rootCmd = &cobra.Command{ log.Info("The cluster-api stack is ready") log.Info("The cluster, the machineSet and the machines have been deployed") + // verify aws instances are running err = wait.Poll(pollInterval, timeoutPoolAWSInterval, func() (bool, error) { log.Info("Waiting for aws instances to come up") runningInstances, err := testConfig.AWSClient.GetRunningInstances(clusterID) diff --git a/tests/e2e/manifests/clusterapi-apiserver-certs.yaml b/tests/e2e/manifests/clusterapi-apiserver-certs.yaml index 13f2530c6d..41d547b695 100644 --- a/tests/e2e/manifests/clusterapi-apiserver-certs.yaml +++ b/tests/e2e/manifests/clusterapi-apiserver-certs.yaml @@ -3,11 +3,11 @@ kind: Secret type: kubernetes.io/tls metadata: name: cluster-apiserver-certs - namespace: default + namespace: openshift-machine-api-operator labels: api: clusterapi apiserver: "true" data: - tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURZRENDQWtpZ0F3SUJBZ0lJVld0dEpOQWI0YzB3RFFZSktvWklodmNOQVFFTEJRQXdLekVwTUNjR0ExVUUKQXhNZ1kyeDFjM1JsY21Gd2FTMWpaWEowYVdacFkyRjBaUzFoZFhSb2IzSnBkSGt3SGhjTk1UZ3dOekV3TURnegpPRFE0V2hjTk1Ua3dOekV3TURnek9EUTVXakFoTVI4d0hRWURWUVFERXhaamJIVnpkR1Z5WVhCcExtUmxabUYxCmJIUXVjM1pqTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF5NG9mZkw5aVR2c0EKeEEraWVDcndnMVZmQTA0S2FVcEF6ODNPWVE5dUtxVXMxQWRQdTBtd2ljcXkzcW1EaHNic3QyOW1peFJ2MTNZbgpUYjFGcGNITTFteitzWjE1UDlBRGtKWnFNdXJ6RC80N1dBVXBwWERqNlJxd2xmTk55MmN1bzJiYTNxc1ZrM051CmJJK1prMFhYMFJjT3o0dXo5a1IxYk5nL3BGTU5lcDBJQ25sNDg0SVpKRUs2QldnU1l3M25pSFRjbU1CVXg5MWEKZ1NxUHJFZkN1TDBJZGMwbGk0Y1d0UUVpb0NOSUdpV3pjb2ZEU01hcUU0SUZ3Sjc0ZVlENDIzckdjVGhyUCt0MApxbW1Qa2ZSRXltUlFHeG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TldiSUVhUmROZkJuVzV6QmtaQ3VEZzRhc0k1VG9oMi94Q0VyT3JaMUVpCjJPQU82cUN3ZDBhKzBqZG1jRTd2QUNFNlMvL1lVNkViN09CdGJhSVNmdVlQZTU5N0xxYnRpS2VqVXdzTTFkNFoKa240YjFXYjRRQ2ZWQThMR3JmNm5xVlpZMUVsK0ZkM3hTUERZMjRoNFV2VUJHK3d1WHd6SkNpQXlCUUtCZ0ZTMwpDSUlZd0EyN08yYXJVcFcxSTF4TVAzZ2xPbHZub0JpbHNBQXk1cUdOazU5WFdJRmdkR0hQWXBHVVBubi9UZDJuCjlPVHEyYXZsUklwVVBuZ2pCZWo3em11MTQ4YWJacDNLRXQyV01pTmoyaVJ6N1M5R3dkTUtjdmJNUzVlT0h2RWIKNzRzNGVRZFhjM3VYNUFydFgwNENWdldmNGhnYmRadTFjZjJVcDBQdEFvR0FmaXFHNzNXSFcrZGc5VzJLRkpDcQpEY0RDVGRSeUpXRUpsdG14dVpIK3AwdlNHc1F6T0ZUczUrYmp3SCtPZ21DbmJFT3o0aWFFbTZvbXp0OTlkT1dXCkZpNWVvNmFPT01LS1d4bG51WXNDVU5rYXJSY0F5dHlYRlA1RklGd2Ntb3Vwa3Z4K3VzZ0o4c0YyYzZIOGNvYmMKRHh6RGZMRVB6WWs4UVZraytaM01jcms9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K # TODO: generate this dynamically diff --git a/tests/e2e/manifests/ign-config.yaml b/tests/e2e/manifests/ign-config.yaml index 2e453e245d..2d803790a0 100644 --- a/tests/e2e/manifests/ign-config.yaml +++ b/tests/e2e/manifests/ign-config.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: ignition-worker - namespace: default + namespace: openshift-machine-api-operator type: Opaque data: userData: "" \ No newline at end of file diff --git a/tests/e2e/manifests/mao-config.yaml b/tests/e2e/manifests/mao-config.yaml index eba0d6f8ea..cea1af2a3d 100644 --- a/tests/e2e/manifests/mao-config.yaml +++ b/tests/e2e/manifests/mao-config.yaml @@ -11,23 +11,25 @@ aws: WithCreds: true kind: machineAPIOperatorConfig provider: aws -targetNamespace: default +targetNamespace: openshift-machine-api-operator apiServiceCA: | -----BEGIN CERTIFICATE----- - MIIC9DCCAdygAwIBAgIBADANBgkqhkiG9w0BAQsFADArMSkwJwYDVQQDEyBjbHVz - dGVyYXBpLWNlcnRpZmljYXRlLWF1dGhvcml0eTAeFw0xODA3MTAwODM4NDhaFw0y - ODA3MDcwODM4NDhaMCsxKTAnBgNVBAMTIGNsdXN0ZXJhcGktY2VydGlmaWNhdGUt - YXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuTwLdz6R - m5qSm04/DKV7eEufqkBhtKMFds70k0iEUZ9JqjMIa8pSdSgLsuVAspnEYbbqq1Tp - uQTGnzh6tPSilFzk9ee8U//GCBe978Myywzh2pPzZ0FhFG31eiSrr4+FU1DZOTb0 - AnqOPC54BjT8VSr/ZfoNfAhNoa+TqxKxw7Cp6LnaKVi3Gu5JZ0K1U+Vvlkzj8VPi - Snzk32T2Be6DCC0MHXEyQEwhXUkM89y3G16mTmvgBbHz0SazV78PM6oITu/Grh// - vE5haGNq1tEV4M4O0dy+i6wMkeOoWz520968/CUf0rwsfU0l1X/X+TaNi+2n0xHu - BjIaylFZ3z1mTQIDAQABoyMwITAOBgNVHQ8BAf8EBAMCAqQwDwYDVR0TAQH/BAUw - AwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAhTZLJkNkAbl18orDsfcxSyLN424D9Ym/ - WYZ5wTi47sPwapo22zd1qt7GCkC3rBknCLnv/87BZ7+ZhWGBkc/126QRWpMGhco7 - N3Ehp6i98J74F6QY3FXUFOa5e047FRFT8fv7dKB4z6n97NXXOYx2HgwzGj34ibLa - eK7JJ+LE//pOOHzmQyP6VvE8jOu00W5m1LjlOLlo6y1zsj5ysao3y+QOtJ5/UF55 - wqeVEmn9SqY6DzjwechzU78am7R6zwug35Ejta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+ Iy5TsNd2vSB/LGTtOzA8UcKWi0+ZL5cbpHg5V7MCXHNFiVYd6F0xQ1amxNSW9jE+ + 1FNeIJs9Wvu3uxPE0uxzwbJu+Tng+GbRgWBL2bQr+O5HV9TbMYoAQoOeTnUi+/YW + vH5db3eOntbMQENHIFnODB7wyiILvNb/NFq+xeVdjnsMtK0o -----END CERTIFICATE----- diff --git a/tests/e2e/manifests/operator-deployment.yaml b/tests/e2e/manifests/operator-deployment.yaml new file mode 100644 index 0000000000..a9a1925224 --- /dev/null +++ b/tests/e2e/manifests/operator-deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: machine-api-operator + namespace: kube-system + labels: + k8s-app: machine-api-operator + managed-by-channel-operator: "true" +spec: + replicas: 1 + selector: + matchLabels: + k8s-app: machine-api-operator + template: + metadata: + labels: + k8s-app: machine-api-operator + tectonic-app-version-name: machine-api + spec: + containers: + - name: machine-api-operator + image: {{ .Image }} + command: + - "/machine-api-operator" + args: + - "start" + resources: + limits: + cpu: 20m + memory: 50Mi + requests: + cpu: 20m + memory: 50Mi + volumeMounts: + - name: cluster-config + mountPath: /etc/mao-config + imagePullSecrets: + - name: coreos-pull-secret + nodeSelector: + node-role.kubernetes.io/master: "" + restartPolicy: Always + securityContext: + runAsNonRoot: true + runAsUser: 65534 + tolerations: + - key: "node-role.kubernetes.io/master" + operator: "Exists" + effect: "NoSchedule" + volumes: + - name: cluster-config + configMap: + name: cluster-config-v1 + items: + - key: mao-config + path: config diff --git a/tests/e2e/manifests/status-crd.yaml b/tests/e2e/manifests/status-crd.yaml new file mode 100644 index 0000000000..4f2d5345b6 --- /dev/null +++ b/tests/e2e/manifests/status-crd.yaml @@ -0,0 +1,27 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + # name must match the spec fields below, and be in the form: . + name: operatorstatuses.operatorstatus.openshift.io +spec: + # TODO: remove this version: "v1" field and match version used by installer + version: "v1" + # group name to use for REST API: /apis// + group: operatorstatus.openshift.io + # list of versions supported by this CustomResourceDefinition + versions: + - name: v1 + # Each version can be enabled/disabled by Served flag. + served: true + # One and only one version must be marked as the storage version. + storage: true + # either Namespaced or Cluster + scope: Namespaced + names: + # plural name to be used in the URL: /apis/// + plural: operatorstatuses + # singular name to be used as an alias on the CLI and for display + singular: operatorstatus + # kind is normally the CamelCased singular type. Your resource manifests use this. + kind: OperatorStatus + diff --git a/tests/e2e/util.go b/tests/e2e/util.go new file mode 100644 index 0000000000..580d4148ae --- /dev/null +++ b/tests/e2e/util.go @@ -0,0 +1,39 @@ +package main + +import ( + "bytes" + "io/ioutil" + "text/template" + + "github.com/golang/glog" +) + +func renderTemplate(tmplData interface{}, data []byte) ([]byte, error) { + buf := new(bytes.Buffer) + + tmpl, err := template.New("").Option("missingkey=error").Parse(string(data)) + if err != nil { + return nil, err + } + + if err := tmpl.Execute(buf, tmplData); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +// RenderTemplateFromFile takes the config object, and uses that to render the templated manifest +func RenderTemplateFromFile(config interface{}, path string) ([]byte, error) { + + data, err := ioutil.ReadFile(path) + if err != nil { + glog.Fatalf("Error reading %#v", err) + } + + populatedData, err := renderTemplate(config, data) + if err != nil { + glog.Fatalf("Unable to render manifests %q: %v", data, err) + } + return populatedData, nil +}