Skip to content

Commit

Permalink
change tests
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Sep 20, 2024
1 parent 3a047bc commit e4ed64c
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 421 deletions.
270 changes: 176 additions & 94 deletions src/internal/bigbang/bigbang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,88 @@ func TestAddBigBangManifests(t *testing.T) {

func TestCreate(t *testing.T) {
t.Parallel()
bbHealthChecks := []v1alpha1.NamespacedObjectKindReference{
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "grafana"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "istio"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "istio-operator"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kiali"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno-policies"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno-reporter"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "loki"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "monitoring"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "neuvector"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "promtail"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "tempo"},
}
bbImages := []string{
"registry1.dso.mil/ironbank/big-bang/grafana/grafana-plugins:11.1.4",
"registry1.dso.mil/ironbank/kiwigrid/k8s-sidecar:1.27.5",
"registry1.dso.mil/ironbank/big-bang/base:2.1.0",
"registry1.dso.mil/ironbank/opensource/istio/pilot:1.22.4",
"registry1.dso.mil/ironbank/opensource/istio/proxyv2:1.22.4",
"registry1.dso.mil/ironbank/opensource/istio/operator:1.22.4",
"registry1.dso.mil/ironbank/opensource/kiali/kiali:v1.89.0",
"registry1.dso.mil/ironbank/opensource/kiali/kiali-operator:v1.89.1",
"registry1.dso.mil/ironbank/opensource/kyverno:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyvernopre:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.7",
"registry1.dso.mil/ironbank/redhat/ubi/ubi9-minimal:9.4",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/reports-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/background-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/cleanup-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyvernocli:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/policy-reporter:2.20.1",
"registry1.dso.mil/ironbank/opensource/grafana/loki:3.1.1",
"registry1.dso.mil/ironbank/opensource/kubernetes-sigs/metrics-server:v0.7.1",
"registry1.dso.mil/ironbank/opensource/prometheus/alertmanager:v0.27.0",
"registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.6",
"registry1.dso.mil/ironbank/opensource/kubernetes/kube-state-metrics:v2.12.0",
"registry1.dso.mil/ironbank/opensource/ingress-nginx/kube-webhook-certgen:v1.3.0",
"registry1.dso.mil/ironbank/opensource/prometheus/prometheus:v2.53.0",
"registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-config-reloader:v0.75.0",
"registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-operator:v0.75.0",
"registry1.dso.mil/ironbank/opensource/prometheus/node-exporter:v1.8.1",
"registry1.dso.mil/ironbank/opensource/thanos/thanos:v0.35.1",
"registry1.dso.mil/ironbank/neuvector/neuvector/controller:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/enforcer:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/manager:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/scanner:5",
"registry1.dso.mil/ironbank/neuvector/neuvector/prometheus-exporter:5.3.2",
"registry1.dso.mil/ironbank/opensource/grafana/promtail:v3.0.0",
"registry1.dso.mil/ironbank/opensource/grafana/tempo:2.5.0",
"registry1.dso.mil/ironbank/opensource/grafana/tempo-query:2.5.0",
}
bbRepos := []string{
"https://repo1.dso.mil/big-bang/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
}
tests := []struct {
name string
airgap bool
version string
repo string
skipFlux bool
pkg v1alpha1.ZarfPackage
expectedPackage string
name string
airgap bool
version string
repo string
skipFlux bool
pkg v1alpha1.ZarfPackage
}{
{
name: "default BB install",
airgap: true,
version: "2.35.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
skipFlux: false,
expectedPackage: filepath.Join("testdata", "create", "default.yaml"),
name: "default BB install",
airgap: true,
version: "2.35.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
skipFlux: false,
pkg: v1alpha1.ZarfPackage{
APIVersion: "zarf.dev/v1alpha1",
Kind: v1alpha1.ZarfPackageConfig,
Expand Down Expand Up @@ -314,60 +380,52 @@ func TestCreate(t *testing.T) {
},
},
},
Images: []string{
"registry1.dso.mil/ironbank/big-bang/grafana/grafana-plugins:11.1.4",
"registry1.dso.mil/ironbank/kiwigrid/k8s-sidecar:1.27.5",
"registry1.dso.mil/ironbank/big-bang/base:2.1.0",
"registry1.dso.mil/ironbank/opensource/istio/pilot:1.22.4",
"registry1.dso.mil/ironbank/opensource/istio/proxyv2:1.22.4",
"registry1.dso.mil/ironbank/opensource/istio/operator:1.22.4",
"registry1.dso.mil/ironbank/opensource/kiali/kiali:v1.89.0",
"registry1.dso.mil/ironbank/opensource/kiali/kiali-operator:v1.89.1",
"registry1.dso.mil/ironbank/opensource/kyverno:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyvernopre:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.7",
"registry1.dso.mil/ironbank/redhat/ubi/ubi9-minimal:9.4",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/reports-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/background-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyverno/cleanup-controller:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/kyvernocli:v1.12.5",
"registry1.dso.mil/ironbank/opensource/kyverno/policy-reporter:2.20.1",
"registry1.dso.mil/ironbank/opensource/grafana/loki:3.1.1",
"registry1.dso.mil/ironbank/opensource/kubernetes-sigs/metrics-server:v0.7.1",
"registry1.dso.mil/ironbank/opensource/prometheus/alertmanager:v0.27.0",
"registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.6",
"registry1.dso.mil/ironbank/opensource/kubernetes/kube-state-metrics:v2.12.0",
"registry1.dso.mil/ironbank/opensource/ingress-nginx/kube-webhook-certgen:v1.3.0",
"registry1.dso.mil/ironbank/opensource/prometheus/prometheus:v2.53.0",
"registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-config-reloader:v0.75.0",
"registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-operator:v0.75.0",
"registry1.dso.mil/ironbank/opensource/prometheus/node-exporter:v1.8.1",
"registry1.dso.mil/ironbank/opensource/thanos/thanos:v0.35.1",
"registry1.dso.mil/ironbank/neuvector/neuvector/controller:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/enforcer:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/manager:5.3.4",
"registry1.dso.mil/ironbank/neuvector/neuvector/scanner:5",
"registry1.dso.mil/ironbank/neuvector/neuvector/prometheus-exporter:5.3.2",
"registry1.dso.mil/ironbank/opensource/grafana/promtail:v3.0.0",
"registry1.dso.mil/ironbank/opensource/grafana/tempo:2.5.0",
"registry1.dso.mil/ironbank/opensource/grafana/tempo-query:2.5.0",
Images: bbImages,
Repos: bbRepos,
Actions: v1alpha1.ZarfComponentActions{
OnRemove: v1alpha1.ZarfComponentActionSet{
Before: []v1alpha1.ZarfComponentAction{
{
Cmd: "./zarf tools kubectl patch helmrelease -n bigbang bigbang --type=merge -p '{\"spec\":{\"suspend\":true}}'",
Description: "Suspend Big Bang HelmReleases to prevent reconciliation during removal.",
},
},
},
},
Repos: []string{
"https://repo1.dso.mil/big-bang/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
"https://repo1.dso.mil/big-bang/product/packages/[email protected]",
HealthChecks: bbHealthChecks,
},
},
},
},
{
name: "skip flux",
airgap: true,
version: "2.35.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
skipFlux: true,
pkg: v1alpha1.ZarfPackage{
APIVersion: "zarf.dev/v1alpha1",
Kind: v1alpha1.ZarfPackageConfig,
Metadata: v1alpha1.ZarfMetadata{
Name: "bigbang",
},
Components: []v1alpha1.ZarfComponent{
{
Name: "bigbang",
Required: helpers.BoolPtr(true),
Manifests: []v1alpha1.ZarfManifest{
{
Name: "bigbang",
Namespace: "bigbang",
Files: []string{
"manifests/bb-gitrepository.yaml",
"manifests/bb-zarf-credentials.yaml",
"manifests/bb-helmrelease.yaml",
},
},
},
Images: bbImages,
Repos: bbRepos,
Actions: v1alpha1.ZarfComponentActions{
OnRemove: v1alpha1.ZarfComponentActionSet{
Before: []v1alpha1.ZarfComponentAction{
Expand All @@ -378,40 +436,64 @@ func TestCreate(t *testing.T) {
},
},
},
HealthChecks: []v1alpha1.NamespacedObjectKindReference{
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "grafana"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "istio"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "istio-operator"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kiali"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno-policies"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "kyverno-reporter"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "loki"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "monitoring"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "neuvector"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "promtail"},
{APIVersion: "helm.toolkit.fluxcd.io/v2", Kind: "HelmRelease", Namespace: "bigbang", Name: "tempo"},
HealthChecks: bbHealthChecks,
},
},
},
},
{
name: "Not air gapped",
airgap: false,
version: "2.35.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
skipFlux: false,
pkg: v1alpha1.ZarfPackage{
APIVersion: "zarf.dev/v1alpha1",
Kind: v1alpha1.ZarfPackageConfig,
Metadata: v1alpha1.ZarfMetadata{
YOLO: true,
Name: "bigbang",
},
Components: []v1alpha1.ZarfComponent{
{
Name: "flux",
Required: helpers.BoolPtr(true),
Manifests: []v1alpha1.ZarfManifest{
{
Name: "flux-system",
Namespace: "flux-system",
Files: []string{"flux/bb-flux.yaml"},
},
},
},
{
Name: "bigbang",
Required: helpers.BoolPtr(true),
Manifests: []v1alpha1.ZarfManifest{
{
Name: "bigbang",
Namespace: "bigbang",
Files: []string{
"manifests/bb-gitrepository.yaml",
"manifests/bb-helmrelease.yaml",
},
},
},
Actions: v1alpha1.ZarfComponentActions{
OnRemove: v1alpha1.ZarfComponentActionSet{
Before: []v1alpha1.ZarfComponentAction{
{
Cmd: "./zarf tools kubectl patch helmrelease -n bigbang bigbang --type=merge -p '{\"spec\":{\"suspend\":true}}'",
Description: "Suspend Big Bang HelmReleases to prevent reconciliation during removal.",
},
},
},
},
HealthChecks: bbHealthChecks,
},
},
},
},
// {
// name: "skip flux",
// airgap: true,
// version: "2.35.0",
// repo: "https://repo1.dso.mil/big-bang/bigbang",
// skipFlux: true,
// expectedPackage: filepath.Join("testdata", "create", "skip_flux.yaml"),
// },
// {
// name: "Not air gapped",
// airgap: false,
// version: "2.35.0",
// repo: "https://repo1.dso.mil/big-bang/bigbang",
// skipFlux: false,
// expectedPackage: filepath.Join("testdata", "create", "not_airgap.yaml"),
// },
}

for _, tt := range tests {
Expand Down
Loading

0 comments on commit e4ed64c

Please sign in to comment.