1
0
mirror of synced 2026-02-13 21:16:57 +00:00

Use shared envTest for unit tests

Speed up unit tests by using a shared envTest. This requires each
test to use its own namespace to avoid clobbering objects for
other tests. Tests previously took around 8 seconds each, and now
the initial test takes 2 seconds with follow up tests taking less
than a second each.

Also update existing tests that use a fixed namespace to use a
generated namespace.

Share gold file template function with yaml files.

Remove the testClusterMode, and instead rely on MainTest to do
the appropriate test setup and rootArgs flag setup. Move the
rootArg flag setup out of NewTestEnvKubeManager to avoid
side effects.

A follow up change can be to push the individual setups
from NewTestEnvKubeManager() into their respective TestMain since
the harness share little code.

Signed-off-by: Allen Porter <allen@thebends.org>
This commit is contained in:
Allen Porter
2021-08-23 14:17:41 -07:00
parent def92e14ee
commit d45501a129
22 changed files with 165 additions and 122 deletions

View File

@@ -2,21 +2,21 @@
apiVersion: v1
kind: Namespace
metadata:
name: flux-system
name: {{ .fluxns }}
---
apiVersion: v1
kind: Namespace
metadata:
name: podinfo
name: {{ .ns }}
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
labels:
kustomize.toolkit.fluxcd.io/name: infrastructure
kustomize.toolkit.fluxcd.io/namespace: flux-system
kustomize.toolkit.fluxcd.io/namespace: {{ .fluxns }}
name: podinfo
namespace: podinfo
namespace: {{ .ns }}
spec:
chart:
spec:
@@ -24,7 +24,7 @@ spec:
sourceRef:
kind: HelmRepository
name: podinfo
namespace: flux-system
namespace: {{ .fluxns }}
interval: 5m
status:
conditions:
@@ -33,7 +33,7 @@ status:
reason: ReconciliationSucceeded
status: "True"
type: Ready
helmChart: flux-system/podinfo-podinfo
helmChart: {{ .fluxns }}/podinfo-podinfo
lastAppliedRevision: 6.0.0
lastAttemptedRevision: 6.0.0
lastAttemptedValuesChecksum: c31db75d05b7515eba2eef47bd71038c74b2e531
@@ -42,7 +42,7 @@ apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: infrastructure
namespace: flux-system
namespace: {{ .fluxns }}
spec:
path: ./infrastructure
sourceRef:
@@ -65,9 +65,9 @@ kind: GitRepository
metadata:
labels:
kustomize.toolkit.fluxcd.io/name: flux-system
kustomize.toolkit.fluxcd.io/namespace: flux-system
kustomize.toolkit.fluxcd.io/namespace: {{ .fluxns }}
name: flux-system
namespace: flux-system
namespace: {{ .fluxns }}
spec:
gitImplementation: go-git
ref: