Skip to content

Commit

Permalink
Switch to using 'uri' Kubernetes components in test Devfiles
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rm3l committed May 2, 2022
1 parent fc5aeb2 commit df1f19e
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 221 deletions.
12 changes: 6 additions & 6 deletions pkg/component/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 1 addition & 22 deletions tests/examples/source/devfiles/nodejs/devfile-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
65 changes: 2 additions & 63 deletions tests/examples/source/devfiles/nodejs/devfile-with-link.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 2 additions & 23 deletions tests/examples/source/devfiles/nodejs/devfile-with-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ spec:
resources:
limits:
memory: "128Mi"
cpu: "500m"
cpu: "500m"
Original file line number Diff line number Diff line change
@@ -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: {}
Loading

0 comments on commit df1f19e

Please sign in to comment.