forked from LaconicNetwork/kompose
fix: use dyff to check that yaml files are equal
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
parent
115f3862fc
commit
4c203d941e
@ -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 -P 'sort_keys(..)' -o=props $expected_output) <(yq -P 'sort_keys(..)' -o=props $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
|
||||
|
||||
@ -147,7 +147,7 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-c
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml"
|
||||
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml convert --with-kompose-annotation=false --stdout --volumes emptyDir"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os-empty-vols-template.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
# Test that emptyvols works
|
||||
@ -163,7 +163,7 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml conve
|
||||
ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-k8s.yaml"
|
||||
ocp_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$ocp_cmd" "$ocp_output"
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/docker-compos
|
||||
ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/docker-compose.yaml convert --stdout --with-kompose-annotation=false --controller statefulset"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-k8s.yaml"
|
||||
ocp_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$ocp_cmd" "$ocp_output"
|
||||
|
||||
# test specifying volume type using service label
|
||||
@ -210,7 +210,7 @@ os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/env
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-k8s.yaml"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
convert::expect_success_and_warning "$os_cmd" "$os_output"
|
||||
|
||||
# Test single file output feature
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/single-file-output/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
@ -222,7 +222,7 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/docker
|
||||
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-k8s.yaml"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
# Test external traffic policy feature with valid configuration, warning is coming from the network policy.
|
||||
@ -230,7 +230,7 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/d
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml"
|
||||
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/docker-compose-v1.yaml convert --stdout --with-kompose-annotation=false"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-os-v1.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
# Test external traffic policy feature with warning, because we have nodeport with external traffic policy
|
||||
@ -247,7 +247,7 @@ k8s_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-k8s.yaml"
|
||||
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/fsgroup/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success_and_warning "$os_cmd" "$os_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
# Test support for compose.yaml file
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-file-support/compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
@ -271,7 +271,7 @@ convert::expect_success "$os_cmd" "$os_output"
|
||||
# Test support for network policies generation
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-policies/docker-compose.yaml convert --generate-network-policies --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-policies/output-k8s.yaml"
|
||||
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
|
||||
# Test support for namespace generation
|
||||
k8s_cmd="kompose -f ./script/test/fixtures/namespace/docker-compose.yaml convert --stdout --with-kompose-annotation=false -n web"
|
||||
|
||||
@ -5,3 +5,5 @@ services:
|
||||
labels:
|
||||
kompose.image-pull-policy: "${IMAGE_PULL_POLICY:-IfNotPresent}"
|
||||
build: .
|
||||
ports:
|
||||
- 80:80
|
||||
|
||||
@ -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
|
||||
@ -27,6 +47,11 @@ spec:
|
||||
- image: foo
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: foo
|
||||
ports:
|
||||
- containerPort: 80
|
||||
hostPort: 80
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
|
||||
3
script/test/fixtures/env/docker-compose.yml
vendored
3
script/test/fixtures/env/docker-compose.yml
vendored
@ -11,5 +11,8 @@ services:
|
||||
- "8020:8020"
|
||||
another-namenode:
|
||||
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||
ports:
|
||||
- "50070:50070"
|
||||
- "8020:8020"
|
||||
env_file:
|
||||
- hadoop-hive-namenode.env
|
||||
|
||||
28
script/test/fixtures/env/output-k8s.yaml
vendored
28
script/test/fixtures/env/output-k8s.yaml
vendored
@ -1,3 +1,24 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: another-namenode
|
||||
name: another-namenode
|
||||
spec:
|
||||
ports:
|
||||
- name: "50070"
|
||||
port: 50070
|
||||
targetPort: 50070
|
||||
- name: "8020"
|
||||
port: 8020
|
||||
targetPort: 8020
|
||||
selector:
|
||||
io.kompose.service: another-namenode
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@ -54,6 +75,13 @@ spec:
|
||||
name: Users-ahmedgrati-projects-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
||||
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||
name: another-namenode
|
||||
ports:
|
||||
- containerPort: 50070
|
||||
hostPort: 50070
|
||||
protocol: TCP
|
||||
- containerPort: 8020
|
||||
hostPort: 8020
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
28
script/test/fixtures/env/output-os.yaml
vendored
28
script/test/fixtures/env/output-os.yaml
vendored
@ -1,3 +1,24 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: another-namenode
|
||||
name: another-namenode
|
||||
spec:
|
||||
ports:
|
||||
- name: "50070"
|
||||
port: 50070
|
||||
targetPort: 50070
|
||||
- name: "8020"
|
||||
port: 8020
|
||||
targetPort: 8020
|
||||
selector:
|
||||
io.kompose.service: another-namenode
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@ -66,6 +87,13 @@ spec:
|
||||
name: Users-ahmedgrati-projects-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
||||
image: ' '
|
||||
name: another-namenode
|
||||
ports:
|
||||
- containerPort: 50070
|
||||
hostPort: 50070
|
||||
protocol: TCP
|
||||
- containerPort: 8020
|
||||
hostPort: 8020
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
test: false
|
||||
|
||||
@ -6,5 +6,7 @@ networks:
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
networks:
|
||||
ports:
|
||||
- 80:80
|
||||
networks:
|
||||
- web
|
||||
|
||||
@ -1,3 +1,21 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- name: "80"
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
io.kompose.service: nginx
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@ -22,6 +40,10 @@ spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
hostPort: 80
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
4
script/test/fixtures/v2/output-os.yaml
vendored
4
script/test/fixtures/v2/output-os.yaml
vendored
@ -235,7 +235,7 @@ spec:
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
apiVersion: apps.openshift.io/v1
|
||||
kind: DeploymentConfig
|
||||
metadata:
|
||||
annotations:
|
||||
@ -290,7 +290,7 @@ status:
|
||||
updatedReplicas: 0
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
apiVersion: image.openshift.io/v1
|
||||
kind: ImageStream
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
|
||||
Loading…
Reference in New Issue
Block a user