From df1f19ed959b8c82aa17ac3cf12c343305789149 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Mon, 2 May 2022 16:58:43 +0200 Subject: [PATCH] Switch to using 'uri' Kubernetes components in test Devfiles This seems to be a much more realistic case when referencing external Kubernetes manifests. Notes: Some tests, like for `odo deploy`, still test 'Inlined' manifests. --- pkg/component/delete/delete_test.go | 12 ++-- ...l => devfile-deploy-with-k8s-inlined.yaml} | 23 ++++++- ...evfile-deploy-with-multiple-resources.yaml | 4 ++ .../devfiles/nodejs/devfile-deploy.yaml | 23 +------ ...roject_source-in-docker-build-context.yaml | 38 +---------- .../devfiles/nodejs/devfile-with-link.yaml | 65 +------------------ .../devfiles/nodejs/devfile-with-pod.yaml | 25 +------ .../devfile-with-two-deploy-commands.yaml | 23 +------ ...h-image-component-and-no-buildContext.yaml | 37 +---------- .../outerloop-deploy.yaml} | 2 +- .../outerloop-deploy.yaml | 18 +++++ .../outerloop-service.yaml | 15 +++++ .../kubernetes/devfile-with-link/myredis.yaml | 41 ++++++++++++ .../devfile-with-link/redis-link.yaml | 20 ++++++ .../devfile-with-pod/etcdcluster.yaml | 9 +++ .../kubernetes/devfile-with-pod/nginx.yaml | 12 ++++ .../outerloop-deploy.yaml | 21 ++++++ .../outerloop-deploy.yaml | 18 +++++ .../outerloop-service.yaml | 15 +++++ .../devfile/cmd_devfile_build_images_test.go | 7 ++ .../devfile/cmd_devfile_deploy_test.go | 34 ++++++---- .../devfile/cmd_devfile_init_test.go | 2 + .../devfile/cmd_devfile_list_test.go | 2 + 23 files changed, 245 insertions(+), 221 deletions(-) rename tests/examples/source/devfiles/nodejs/{devfile-deploy-with-k8s-uri.yaml => devfile-deploy-with-k8s-inlined.yaml} (77%) rename tests/examples/source/devfiles/nodejs/project/kubernetes/{outerloop-deployment.yaml => devfile-deploy/outerloop-deploy.yaml} (95%) create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-deploy.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-service.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/myredis.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/redis-link.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/etcdcluster.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/nginx.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-two-deploy-commands/outerloop-deploy.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-deploy.yaml create mode 100644 tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-service.yaml diff --git a/pkg/component/delete/delete_test.go b/pkg/component/delete/delete_test.go index f1548d35ef6..637be50f825 100644 --- a/pkg/component/delete/delete_test.go +++ b/pkg/component/delete/delete_test.go @@ -324,7 +324,7 @@ func TestDeleteComponentClient_ListResourcesToDeleteFromDevfile(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantIsInnerLoopDeployed: true, @@ -371,7 +371,7 @@ func TestDeleteComponentClient_ListResourcesToDeleteFromDevfile(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantIsInnerLoopDeployed: false, @@ -388,7 +388,7 @@ func TestDeleteComponentClient_ListResourcesToDeleteFromDevfile(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantIsInnerLoopDeployed: false, @@ -406,7 +406,7 @@ func TestDeleteComponentClient_ListResourcesToDeleteFromDevfile(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantIsInnerLoopDeployed: true, @@ -427,7 +427,7 @@ func TestDeleteComponentClient_ListResourcesToDeleteFromDevfile(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantIsInnerLoopDeployed: true, @@ -487,7 +487,7 @@ func TestDeleteComponentClient_ExecutePreStopEvents(t *testing.T) { }, }, args: args{ - devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy.yaml"), + devfileObj: odoTestingUtil.GetTestDevfileObjFromFile("devfile-deploy-with-k8s-inlined.yaml"), appName: appName, }, wantErr: false, diff --git a/tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-uri.yaml b/tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-inlined.yaml similarity index 77% rename from tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-uri.yaml rename to tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-inlined.yaml index 54eb4d90f59..8cf0f27dd47 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-uri.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-deploy-with-k8s-inlined.yaml @@ -86,4 +86,25 @@ components: uri: ./Dockerfile - name: outerloop-deploy kubernetes: - uri: 'kubernetes/outerloop-deployment.yaml' + inlined: | + kind: Deployment + apiVersion: apps/v1 + metadata: + name: my-component + spec: + replicas: 1 + selector: + matchLabels: + app: node-app + template: + metadata: + labels: + app: node-app + spec: + containers: + - name: main + image: {{CONTAINER_IMAGE}} + resources: + limits: + memory: "128Mi" + cpu: "500m" diff --git a/tests/examples/source/devfiles/nodejs/devfile-deploy-with-multiple-resources.yaml b/tests/examples/source/devfiles/nodejs/devfile-deploy-with-multiple-resources.yaml index 870a49e3dbc..5fbab94291f 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-deploy-with-multiple-resources.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-deploy-with-multiple-resources.yaml @@ -69,6 +69,8 @@ components: - name: outerloop-deploy kubernetes: + # TODO(rm3l): Move this as a URI by default once https://github.com/redhat-developer/odo/issues/5637 is fixed + # Also consider keeping an "Inlined" version for testing inlined: | kind: Deployment apiVersion: apps/v1 @@ -93,6 +95,8 @@ components: cpu: "500m" - name: outerloop-deploy-2 kubernetes: + # TODO(rm3l): Move this as a URI by default once https://github.com/redhat-developer/odo/issues/5637 is fixed + # Also consider keeping an "Inlined" version for testing inlined: | apiVersion: v1 kind: Service diff --git a/tests/examples/source/devfiles/nodejs/devfile-deploy.yaml b/tests/examples/source/devfiles/nodejs/devfile-deploy.yaml index ada31e2b5ca..d8424156eb3 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-deploy.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-deploy.yaml @@ -65,28 +65,7 @@ components: - name: outerloop-deploy kubernetes: - inlined: | - kind: Deployment - apiVersion: apps/v1 - metadata: - name: my-component - spec: - replicas: 1 - selector: - matchLabels: - app: node-app - template: - metadata: - labels: - app: node-app - spec: - containers: - - name: main - image: {{CONTAINER_IMAGE}} - resources: - limits: - memory: "128Mi" - cpu: "500m" + uri: kubernetes/devfile-deploy/outerloop-deploy.yaml metadata: description: Stack with Node.js 14 displayName: Node.js Runtime diff --git a/tests/examples/source/devfiles/nodejs/devfile-outerloop-project_source-in-docker-build-context.yaml b/tests/examples/source/devfiles/nodejs/devfile-outerloop-project_source-in-docker-build-context.yaml index 71bd0b76cf9..2b5a004a34f 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-outerloop-project_source-in-docker-build-context.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-outerloop-project_source-in-docker-build-context.yaml @@ -58,41 +58,7 @@ components: buildContext: ${PROJECT_SOURCE} - name: outerloop-deploy kubernetes: - inlined: | - kind: Deployment - apiVersion: apps/v1 - metadata: - name: devfile-nodejs-deploy - spec: - replicas: 1 - selector: - matchLabels: - app: devfile-nodejs-deploy - template: - metadata: - labels: - app: devfile-nodejs-deploy - spec: - containers: - - name: main - image: "{{CONTAINER_IMAGE}}" - resources: {} + uri: kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-deploy.yaml - name: outerloop-service kubernetes: - inlined: | - apiVersion: v1 - kind: Service - metadata: - labels: - app: devfile-nodejs-deploy - name: devfile-nodejs-deploy - spec: - ports: - - name: http-3000 - port: 3000 - protocol: TCP - targetPort: 3000 - selector: - app: devfile-nodejs-deploy - type: LoadBalancer - + uri: kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-service.yaml diff --git a/tests/examples/source/devfiles/nodejs/devfile-with-link.yaml b/tests/examples/source/devfiles/nodejs/devfile-with-link.yaml index 6e7cae607ca..2079621ba3c 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-with-link.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-with-link.yaml @@ -42,71 +42,10 @@ components: sourceMapping: /project name: runtime - kubernetes: - inlined: | - apiVersion: redis.redis.opstreelabs.in/v1beta1 - kind: Redis - metadata: - name: myredis - annotations: - service.binding/name: path={.metadata.name} - spec: - redisExporter: - enabled: true - image: 'quay.io/opstree/redis-exporter:1.0' - imagePullPolicy: Always - resources: - requests: - cpu: 100m - memory: 128Mi - limits: - cpu: 100m - memory: 128Mi - kubernetesConfig: - image: 'quay.io/opstree/redis:v6.2' - imagePullPolicy: IfNotPresent - resources: - requests: - cpu: 101m - memory: 128Mi - limits: - cpu: 101m - memory: 128Mi - redisSecret: - name: redis-secret - key: password - serviceType: LoadBalancer - redisConfig: {} - storage: - volumeClaimTemplate: - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1Gi + uri: kubernetes/devfile-with-link/myredis.yaml name: myredis - kubernetes: - inlined: | - apiVersion: binding.operators.coreos.com/v1alpha1 - kind: ServiceBinding - metadata: - creationTimestamp: null - name: redis-link - spec: - application: - group: apps - name: api-app - resource: deployments - version: v1 - bindAsFiles: true - detectBindingResources: true - services: - - group: redis.redis.opstreelabs.in - kind: Redis - name: myredis - version: v1beta1 - status: - secret: "" + uri: kubernetes/devfile-with-link/redis-link.yaml name: redis-link metadata: description: Stack with Node.js 14 diff --git a/tests/examples/source/devfiles/nodejs/devfile-with-pod.yaml b/tests/examples/source/devfiles/nodejs/devfile-with-pod.yaml index dd6409a6a1d..f704739b523 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-with-pod.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-with-pod.yaml @@ -24,31 +24,10 @@ components: sourceMapping: /project name: runtime - kubernetes: - inlined: | - apiVersion: etcd.database.coreos.com/v1beta2 - kind: EtcdCluster - metadata: - annotations: - etcd.database.coreos.com/scope: clusterwide - name: etcdcluster - spec: - size: 3 - version: 3.2.13 + uri: kubernetes/devfile-with-pod/etcdcluster.yaml name: etcdcluster - kubernetes: - inlined: | - apiVersion: v1 - kind: Pod - metadata: - labels: - name: nginx - name: nginx - spec: - containers: - - image: quay.io/bitnami/nginx - name: nginx - ports: - - containerPort: 80 + uri: kubernetes/devfile-with-pod/nginx.yaml name: nginx commands: - exec: diff --git a/tests/examples/source/devfiles/nodejs/devfile-with-two-deploy-commands.yaml b/tests/examples/source/devfiles/nodejs/devfile-with-two-deploy-commands.yaml index ec4b66c45ec..09a8e348618 100644 --- a/tests/examples/source/devfiles/nodejs/devfile-with-two-deploy-commands.yaml +++ b/tests/examples/source/devfiles/nodejs/devfile-with-two-deploy-commands.yaml @@ -72,28 +72,7 @@ components: - name: outerloop-deploy kubernetes: - inlined: | - kind: Deployment - apiVersion: apps/v1 - metadata: - name: my-component - spec: - replicas: 1 - selector: - matchLabels: - app: node-app - template: - metadata: - labels: - app: node-app - spec: - containers: - - name: main - image: {{CONTAINER_IMAGE}} - resources: - limits: - memory: "128Mi" - cpu: "500m" + uri: kubernetes/devfile-with-two-deploy-commands/outerloop-deploy.yaml metadata: description: Stack with Node.js 14 displayName: Node.js Runtime diff --git a/tests/examples/source/devfiles/nodejs/issue-5600-devfile-with-image-component-and-no-buildContext.yaml b/tests/examples/source/devfiles/nodejs/issue-5600-devfile-with-image-component-and-no-buildContext.yaml index bd00d831918..559a0301e7d 100644 --- a/tests/examples/source/devfiles/nodejs/issue-5600-devfile-with-image-component-and-no-buildContext.yaml +++ b/tests/examples/source/devfiles/nodejs/issue-5600-devfile-with-image-component-and-no-buildContext.yaml @@ -48,43 +48,10 @@ components: imageName: localhost:5000/devfile-nodejs-deploy:0.1.0 name: prod-image - kubernetes: - inlined: | - kind: Deployment - apiVersion: apps/v1 - metadata: - name: devfile-nodejs-deploy - spec: - replicas: 1 - selector: - matchLabels: - app: devfile-nodejs-deploy - template: - metadata: - labels: - app: devfile-nodejs-deploy - spec: - containers: - - name: main - image: "localhost:5000/devfile-nodejs-deploy:0.1.0" - resources: {} + uri: kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-deploy.yaml name: outerloop-deploy - kubernetes: - inlined: | - apiVersion: v1 - kind: Service - metadata: - labels: - app: devfile-nodejs-deploy - name: devfile-nodejs-deploy - spec: - ports: - - name: http-3000 - port: 3000 - protocol: TCP - targetPort: 3000 - selector: - app: devfile-nodejs-deploy - type: LoadBalancer + uri: kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-service.yaml name: outerloop-service metadata: language: javascript diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/outerloop-deployment.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-deploy/outerloop-deploy.yaml similarity index 95% rename from tests/examples/source/devfiles/nodejs/project/kubernetes/outerloop-deployment.yaml rename to tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-deploy/outerloop-deploy.yaml index 2a155d1a780..5ac9de29bbc 100644 --- a/tests/examples/source/devfiles/nodejs/project/kubernetes/outerloop-deployment.yaml +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-deploy/outerloop-deploy.yaml @@ -20,4 +20,4 @@ spec: resources: limits: memory: "128Mi" - cpu: "500m" + cpu: "500m" \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-deploy.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-deploy.yaml new file mode 100644 index 00000000000..c73a309e8e0 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-deploy.yaml @@ -0,0 +1,18 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: devfile-nodejs-deploy +spec: + replicas: 1 + selector: + matchLabels: + app: devfile-nodejs-deploy + template: + metadata: + labels: + app: devfile-nodejs-deploy + spec: + containers: + - name: main + image: "{{CONTAINER_IMAGE}}" + resources: {} \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-service.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-service.yaml new file mode 100644 index 00000000000..4c6ec53b676 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-outerloop-project_source-in-docker-build-context/outerloop-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: devfile-nodejs-deploy + name: devfile-nodejs-deploy +spec: + ports: + - name: http-3000 + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: devfile-nodejs-deploy + type: LoadBalancer \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/myredis.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/myredis.yaml new file mode 100644 index 00000000000..46f6251385f --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/myredis.yaml @@ -0,0 +1,41 @@ +apiVersion: redis.redis.opstreelabs.in/v1beta1 +kind: Redis +metadata: + name: myredis + annotations: + service.binding/name: path={.metadata.name} +spec: + redisExporter: + enabled: true + image: 'quay.io/opstree/redis-exporter:1.0' + imagePullPolicy: Always + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 100m + memory: 128Mi + kubernetesConfig: + image: 'quay.io/opstree/redis:v6.2' + imagePullPolicy: IfNotPresent + resources: + requests: + cpu: 101m + memory: 128Mi + limits: + cpu: 101m + memory: 128Mi + redisSecret: + name: redis-secret + key: password + serviceType: LoadBalancer + redisConfig: {} + storage: + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/redis-link.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/redis-link.yaml new file mode 100644 index 00000000000..c4868d07b93 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-link/redis-link.yaml @@ -0,0 +1,20 @@ +apiVersion: binding.operators.coreos.com/v1alpha1 +kind: ServiceBinding +metadata: + creationTimestamp: null + name: redis-link +spec: + application: + group: apps + name: api-app + resource: deployments + version: v1 + bindAsFiles: true + detectBindingResources: true + services: + - group: redis.redis.opstreelabs.in + kind: Redis + name: myredis + version: v1beta1 +status: + secret: "" \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/etcdcluster.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/etcdcluster.yaml new file mode 100644 index 00000000000..68aef654216 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/etcdcluster.yaml @@ -0,0 +1,9 @@ +apiVersion: etcd.database.coreos.com/v1beta2 +kind: EtcdCluster +metadata: + annotations: + etcd.database.coreos.com/scope: clusterwide + name: etcdcluster +spec: + size: 3 + version: 3.2.13 \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/nginx.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/nginx.yaml new file mode 100644 index 00000000000..67239bd5025 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-pod/nginx.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + name: nginx + name: nginx +spec: + containers: + - image: quay.io/bitnami/nginx + name: nginx + ports: + - containerPort: 80 \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-two-deploy-commands/outerloop-deploy.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-two-deploy-commands/outerloop-deploy.yaml new file mode 100644 index 00000000000..68b4e32eccb --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/devfile-with-two-deploy-commands/outerloop-deploy.yaml @@ -0,0 +1,21 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: my-component +spec: + replicas: 1 + selector: + matchLabels: + app: node-app + template: + metadata: + labels: + app: node-app + spec: + containers: + - name: main + image: {{CONTAINER_IMAGE}} + resources: + limits: + memory: "128Mi" + cpu: "500m" \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-deploy.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-deploy.yaml new file mode 100644 index 00000000000..bfa919341c8 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-deploy.yaml @@ -0,0 +1,18 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: devfile-nodejs-deploy +spec: + replicas: 1 + selector: + matchLabels: + app: devfile-nodejs-deploy + template: + metadata: + labels: + app: devfile-nodejs-deploy + spec: + containers: + - name: main + image: "localhost:5000/devfile-nodejs-deploy:0.1.0" + resources: {} \ No newline at end of file diff --git a/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-service.yaml b/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-service.yaml new file mode 100644 index 00000000000..4c6ec53b676 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/project/kubernetes/issue-5600-devfile-with-image-component-and-no-buildContext/outerloop-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: devfile-nodejs-deploy + name: devfile-nodejs-deploy +spec: + ports: + - name: http-3000 + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: devfile-nodejs-deploy + type: LoadBalancer \ No newline at end of file diff --git a/tests/integration/devfile/cmd_devfile_build_images_test.go b/tests/integration/devfile/cmd_devfile_build_images_test.go index c49b2537de5..29d785a6da2 100644 --- a/tests/integration/devfile/cmd_devfile_build_images_test.go +++ b/tests/integration/devfile/cmd_devfile_build_images_test.go @@ -79,6 +79,9 @@ var _ = Describe("odo devfile build-images command tests", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", + "devfile-outerloop-project_source-in-docker-build-context"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-outerloop-project_source-in-docker-build-context")) helper.Cmd("odo", "init", "--name", "aname", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", @@ -121,6 +124,10 @@ var _ = Describe("odo devfile build-images command tests", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", + "issue-5600-devfile-with-image-component-and-no-buildContext"), + filepath.Join(commonVar.Context, "kubernetes", + "issue-5600-devfile-with-image-component-and-no-buildContext")) helper.CopyExampleDevFile( filepath.Join("source", "devfiles", "nodejs", "issue-5600-devfile-with-image-component-and-no-buildContext.yaml"), diff --git a/tests/integration/devfile/cmd_devfile_deploy_test.go b/tests/integration/devfile/cmd_devfile_deploy_test.go index 5be778a2673..2bb71328ef3 100644 --- a/tests/integration/devfile/cmd_devfile_deploy_test.go +++ b/tests/integration/devfile/cmd_devfile_deploy_test.go @@ -40,7 +40,7 @@ var _ = Describe("odo devfile deploy command tests", func() { }) }) - for _, ctx := range []struct { + for _, testCtx := range []struct { title string devfileName string setupFunc func() @@ -48,28 +48,27 @@ var _ = Describe("odo devfile deploy command tests", func() { { title: "using a devfile.yaml containing a deploy command", devfileName: "devfile-deploy.yaml", - setupFunc: nil, - }, - { - title: "using a devfile.yaml containing an outer-loop Kubernetes component referenced via an URI", - devfileName: "devfile-deploy-with-k8s-uri.yaml", setupFunc: func() { - helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes"), - filepath.Join(commonVar.Context, "kubernetes")) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", "devfile-deploy"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-deploy")) }, }, + { + title: "using a devfile.yaml containing an outer-loop Kubernetes component inlined", + devfileName: "devfile-deploy-with-k8s-inlined.yaml", + }, } { - When(ctx.title, func() { + When(testCtx.title, func() { // from devfile cmpName := "nodejs-prj1-api-abhz" deploymentName := "my-component" BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) - helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", ctx.devfileName), + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", testCtx.devfileName), path.Join(commonVar.Context, "devfile.yaml")) - if ctx.setupFunc != nil { - ctx.setupFunc() + if testCtx.setupFunc != nil { + testCtx.setupFunc() } }) @@ -135,6 +134,8 @@ var _ = Describe("odo devfile deploy command tests", func() { When("using a devfile.yaml containing two deploy commands", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", "devfile-with-two-deploy-commands"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-with-two-deploy-commands")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-with-two-deploy-commands.yaml"), path.Join(commonVar.Context, "devfile.yaml")) }) It("should run odo deploy", func() { @@ -153,6 +154,8 @@ var _ = Describe("odo devfile deploy command tests", func() { When("recording telemetry data", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", "devfile-deploy"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-deploy")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) helper.EnableTelemetryDebug() helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass() @@ -176,6 +179,9 @@ var _ = Describe("odo devfile deploy command tests", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", + "devfile-outerloop-project_source-in-docker-build-context"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-outerloop-project_source-in-docker-build-context")) helper.Cmd("odo", "init", "--name", "aname", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", @@ -220,6 +226,10 @@ var _ = Describe("odo devfile deploy command tests", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", + "issue-5600-devfile-with-image-component-and-no-buildContext"), + filepath.Join(commonVar.Context, "kubernetes", + "issue-5600-devfile-with-image-component-and-no-buildContext")) helper.CopyExampleDevFile( filepath.Join("source", "devfiles", "nodejs", "issue-5600-devfile-with-image-component-and-no-buildContext.yaml"), diff --git a/tests/integration/devfile/cmd_devfile_init_test.go b/tests/integration/devfile/cmd_devfile_init_test.go index 482ac1e655e..49985e7b284 100644 --- a/tests/integration/devfile/cmd_devfile_init_test.go +++ b/tests/integration/devfile/cmd_devfile_init_test.go @@ -268,6 +268,8 @@ var _ = Describe("odo devfile init command tests", func() { var out string BeforeEach(func() { helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), devfilePath) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", "devfile-deploy"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-deploy")) out = helper.Cmd("odo", "init", "--name", "aname", "--devfile-path", devfilePath).ShouldPass().Out() }) It("should show information about both `odo dev`, and `odo deploy`", func() { diff --git a/tests/integration/devfile/cmd_devfile_list_test.go b/tests/integration/devfile/cmd_devfile_list_test.go index 6e8b28fefcb..618d8365f1a 100644 --- a/tests/integration/devfile/cmd_devfile_list_test.go +++ b/tests/integration/devfile/cmd_devfile_list_test.go @@ -32,6 +32,8 @@ var _ = Describe("odo list with devfile", func() { BeforeEach(func() { helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project", "kubernetes", "devfile-deploy"), + filepath.Join(commonVar.Context, "kubernetes", "devfile-deploy")) helper.Chdir(commonVar.Context) var err error devSession, _, _, _, err = helper.StartDevMode()