Modify tests to present expected data in unsorted order.

Modify all `build` tests to use the raw,
non-sorted output of build.  This makes every test
provide coverage for how kustomize re-orders (or
doesn't reorder) resources during processing.

Going forward, the ordering of resources in
_expected_ output should match the depth-first
ordering specified in the `resources:` field used
in the test's kustomization file.

The only exception to this rule would be tests
that actually confirmed some other output
ordering, e.g. the test of the
`LegacyOrderTransformer` plugin.

Fixes #756
Related #821
This commit is contained in:
Jeffrey Regan
2019-06-17 14:41:43 -07:00
parent ed21e77fb1
commit 0b555e1b2c
21 changed files with 613 additions and 582 deletions

View File

@@ -99,7 +99,7 @@ name: pruneCM
namespace: default
`, content)
th.AssertActualEqualsExpected(rm, inv+"---"+content)
th.AssertActualEqualsExpected(rm, content+"---"+inv)
}
func TestInventoryTransformerDefaultPolicy(t *testing.T) {
@@ -120,5 +120,5 @@ name: pruneCM
namespace: default
`, content)
th.AssertActualEqualsExpected(rm, inv+"---"+content)
th.AssertActualEqualsExpected(rm, content+"---"+inv)
}

View File

@@ -80,15 +80,22 @@ metadata:
th.AssertActualEqualsExpected(rm, `
apiVersion: v1
kind: ConfigMap
metadata:
name: cm1
namespace: test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cm2
namespace: test
---
apiVersion: v1
kind: Namespace
metadata:
name: ns1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: crd
---
apiVersion: v1
kind: ServiceAccount
metadata:
@@ -116,17 +123,10 @@ subjects:
name: another
namespace: random
---
apiVersion: v1
kind: ConfigMap
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: cm1
namespace: test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cm2
namespace: test
name: crd
`)
}

View File

@@ -48,6 +48,14 @@ metadata:
`)
th.AssertActualEqualsExpected(rm, `
apiVersion: v1
kind: Service
metadata:
name: baked-apple-pie
spec:
ports:
- port: 7002
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
@@ -57,13 +65,5 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: baked-cm-pie
---
apiVersion: v1
kind: Service
metadata:
name: baked-apple-pie
spec:
ports:
- port: 7002
`)
}

View File

@@ -109,16 +109,16 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
name: otherapp
spec:
replicas: 23
replicas: 5
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: otherapp
name: myapp
spec:
replicas: 5
replicas: 23
---
apiVersion: apps/v1
kind: StatefulSet

View File

@@ -49,6 +49,24 @@ metadata:
type: Opaque
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
labels:
@@ -66,23 +84,5 @@ spec:
selector:
app: release-name-minecraft
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
`)
}