Skip to content

Commit

Permalink
Merge pull request #1737 from AhmedGrati/fix-e2e-test
Browse files Browse the repository at this point in the history
fix e2e test
  • Loading branch information
k8s-ci-robot authored Oct 17, 2023
2 parents 1f4b069 + 37a1dc2 commit f722bfb
Show file tree
Hide file tree
Showing 57 changed files with 246 additions and 389 deletions.
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
- name: Build
run: make bin


- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Install dyff
run: go install github.com/homeport/dyff/cmd/dyff@v1.5.8
- name: Run tests
run: make test
- name: Perform cross compile
Expand All @@ -34,6 +36,8 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Install dyff
run: go install github.com/homeport/dyff/cmd/dyff@v1.5.8
- name: Create .coverprofile for each targeted directory by re:running tests
run: make test
- name: Collect all .coverprofile files and save it to one file gover.coverprofile
Expand Down
4 changes: 3 additions & 1 deletion pkg/transformer/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
// sort all object so Services are first
o.SortServicesFirst(&allobjects)
o.RemoveDupObjects(&allobjects)
transformer.AssignNamespaceToObjects(&allobjects, komposeObject.Namespace)
if komposeObject.Namespace != "" {
transformer.AssignNamespaceToObjects(&allobjects, komposeObject.Namespace)
}
// o.FixWorkloadVersion(&allobjects)

return allobjects, nil
Expand Down
8 changes: 4 additions & 4 deletions script/test/cmd/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ function convert::match_output() {
convert::run_cmd $cmd
exit_status=$?
if [ $exit_status -ne 0 ]; then FAIL_MSGS=$FAIL_MSGS"exit status: $exit_status\n"; return $exit_status; fi
match=$(diff <(yq ea '[.] | sort_by(.metadata.name) | .[] | splitDoc' $expected_output) <(yq ea '[.] | sort_by(.metadata.name) | .[] | splitDoc' $TEMP_STDOUT))
echo "$match" > /tmp/diff
if [ "$match" == "" ]; then SUCCESS_MSGS=$SUCCESS_MSGS"converted output matches\n"; return 0;
else FAIL_MSGS=$FAIL_MSGS"converted output does not match\n"; cat /tmp/diff; rm /tmp/diff; return 1;

match=$(dyff between --ignore-order-changes --set-exit-code $expected_output $TEMP_STDOUT)
if [ $? -eq 0 ]; then SUCCESS_MSGS=$SUCCESS_MSGS"converted output matches\n"; return 0;
else FAIL_MSGS=$FAIL_MSGS"converted output does not match\n"; echo $match; return 1;
fi
}
readonly -f convert::match_output
Expand Down
105 changes: 50 additions & 55 deletions script/test/cmd/tests_new.sh

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
clusterIP: None
ports:
Expand All @@ -28,7 +27,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
ports:
- name: "5000"
Expand All @@ -49,7 +47,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -80,7 +77,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down
4 changes: 0 additions & 4 deletions script/test/fixtures/change-in-volume/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
clusterIP: None
ports:
Expand All @@ -28,7 +27,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
ports:
- name: "5000"
Expand All @@ -49,7 +47,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -80,7 +77,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
clusterIP: None
ports:
Expand All @@ -28,7 +27,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
ports:
- name: "5000"
Expand All @@ -49,7 +47,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -95,7 +92,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
lookupPolicy:
local: false
Expand All @@ -120,7 +116,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -180,7 +175,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
lookupPolicy:
local: false
Expand Down
6 changes: 0 additions & 6 deletions script/test/fixtures/change-in-volume/output-os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
clusterIP: None
ports:
Expand All @@ -28,7 +27,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
ports:
- name: "5000"
Expand All @@ -49,7 +47,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -95,7 +92,6 @@ metadata:
labels:
io.kompose.service: redis
name: redis
namespace: default
spec:
lookupPolicy:
local: false
Expand All @@ -120,7 +116,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -180,7 +175,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
lookupPolicy:
local: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ services:
labels:
kompose.image-pull-policy: "${IMAGE_PULL_POLICY:-IfNotPresent}"
build: .
ports:
- 80:80
40 changes: 24 additions & 16 deletions script/test/fixtures/compose-env-interpolation/output-k8s.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
---
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.image-pull-policy: IfNotPresent
creationTimestamp: null
labels:
io.kompose.service: foo
name: foo
spec:
ports:
- name: "80"
port: 80
targetPort: 80
selector:
io.kompose.service: foo
status:
loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -27,23 +47,11 @@ spec:
- image: foo
imagePullPolicy: IfNotPresent
name: foo
ports:
- containerPort: 80
hostPort: 80
protocol: TCP
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
creationTimestamp: null
name: compose-env-interpolation-default
spec:
ingress:
- from:
- podSelector:
matchLabels:
io.kompose.network/compose-env-interpolation-default: "true"
podSelector:
matchLabels:
io.kompose.network/compose-env-interpolation-default: "true"

2 changes: 0 additions & 2 deletions script/test/fixtures/compose-file-support/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
ports:
- name: "80"
Expand All @@ -25,7 +24,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ metadata:
labels:
io.kompose.service: db
name: db
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -55,7 +54,6 @@ metadata:
labels:
io.kompose.service: db
name: db-cm0
namespace: default

---
apiVersion: apps/v1
Expand All @@ -67,7 +65,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -118,7 +115,6 @@ metadata:
labels:
io.kompose.service: web
name: web-cm0
namespace: default

---
apiVersion: v1
Expand All @@ -132,5 +128,4 @@ metadata:
labels:
io.kompose.service: web
name: web-cm1
namespace: default

5 changes: 0 additions & 5 deletions script/test/fixtures/configmap-volume/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
labels:
io.kompose.service: db
name: db
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -51,7 +50,6 @@ metadata:
labels:
io.kompose.service: db
name: db-cm0
namespace: default

---
apiVersion: apps/v1
Expand All @@ -61,7 +59,6 @@ metadata:
labels:
io.kompose.service: web
name: web
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -110,7 +107,6 @@ metadata:
labels:
io.kompose.service: web
name: web-cm0
namespace: default

---
apiVersion: v1
Expand All @@ -124,5 +120,4 @@ metadata:
labels:
io.kompose.service: web
name: web-cm1
namespace: default

Loading

0 comments on commit f722bfb

Please sign in to comment.