Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions e2e/helm-charts/redis-app/templates/preflight.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.preflight.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "redis-app.fullname" . }}-preflight
labels:
{{- include "redis-app.labels" . | nindent 4 }}
data:
preflight.yaml: |
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: redis-app-preflight
spec:
collectors:
- nodeResources: {}
analyzers:
- nodeResources:
checkName: Node status check
outcomes:
- fail:
when: "nodeCondition(Ready) == False"
message: "Not all nodes are online."
- fail:
when: "nodeCondition(Ready) == Unknown"
message: "Not all nodes are online."
- pass:
message: "All nodes are online."
{{- end }}
9 changes: 7 additions & 2 deletions e2e/helm-charts/redis-app/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Default values for redis-app
global:
labels: {}

# Preflight checks configuration
preflight:
enabled: false

# Server (Redis) configuration
server:
replicaCount: 1
Expand Down Expand Up @@ -29,7 +34,7 @@ client:
repository: redis
pullPolicy: IfNotPresent
tag: "7.2"
intervalSeconds: 30 # Make a request every 30 seconds
intervalSeconds: 30 # Make a request every 30 seconds
resources:
limits:
cpu: 100m
Expand Down Expand Up @@ -66,4 +71,4 @@ nodeSelector: {}

tolerations: []

affinity: {}
affinity: {}
27 changes: 22 additions & 5 deletions tests/dryrun/assets/kotskinds-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ spec:
port: 80
replicaCount: 1
imagePullSecrets:
- name: '{{repl ImagePullSecretName }}'
- name: "{{repl ImagePullSecretName }}"
env:
- name: PRIVATE_CA_CONFIGMAP
value: 'repl{{ PrivateCACert }}'
value: "repl{{ PrivateCACert }}"
- name: SSL_CERT_DIR
value: "/etc/ssl/certs"
client:
Expand All @@ -31,14 +31,14 @@ spec:
replicaCount: 1
intervalSeconds: 60
imagePullSecrets:
- name: '{{repl ImagePullSecretName }}'
- name: "{{repl ImagePullSecretName }}"
replicated:
enabled: true
image:
registry: repl{{ HasLocalRegistry | ternary LocalRegistryHost "ec-e2e-proxy.testcluster.net" }}
repository: repl{{ HasLocalRegistry | ternary LocalRegistryNamespace "anonymous/registry.replicated.com/library" }}/replicated-sdk-image
imagePullSecrets:
- name: '{{repl ImagePullSecretName }}'
- name: "{{repl ImagePullSecretName }}"
configItemsConfigMapData:
text_required: repl{{ ConfigOption "text_required" }}

Expand All @@ -54,8 +54,25 @@ spec:
volumes:
- name: ca-certs
configMap:
name: 'repl{{ PrivateCACert }}'
name: "repl{{ PrivateCACert }}"

builder:
replicated:
enabled: true
# Do not remove the HelmChart document below. This file is intentionally a multi-document YAML file
# for regression testing of SC-131165 bug fix.
---
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: redis-app
spec:
chart:
name: redis-app
chartVersion: 0.1.0
namespace: redis-app
values:
preflight:
enabled: true
server:
replicaCount: 1
3 changes: 3 additions & 0 deletions tests/dryrun/assets/kotskinds-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Do not remove the leading "---" separator below. It is intentional and required for
# regression testing of SC-131165 bug fix.
---
apiVersion: kots.io/v1beta1
kind: Config
spec:
Expand Down
File renamed without changes.
Binary file added tests/dryrun/assets/redis-app-0.1.0.tgz
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/dryrun/assets/rendered-redis-chart-preflight.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-app-preflight
labels:
helm.sh/chart: redis-app-0.1.0
app.kubernetes.io/name: redis-app
app.kubernetes.io/instance: redis-app
app.kubernetes.io/version: "1.0.0"
app.kubernetes.io/managed-by: Helm
data:
preflight.yaml: |
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: redis-app-preflight
spec:
collectors:
- nodeResources: {}
analyzers:
- nodeResources:
checkName: Node status check
outcomes:
- fail:
when: "nodeCondition(Ready) == False"
message: "Not all nodes are online."
- fail:
when: "nodeCondition(Ready) == Unknown"
message: "Not all nodes are online."
- pass:
message: "All nodes are online."
10 changes: 7 additions & 3 deletions tests/dryrun/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ var (
//go:embed assets/kotskinds-chart.yaml
helmChartData string

//go:embed assets/chart.tgz
helmChartArchiveData string
//go:embed assets/nginx-app-0.1.0.tgz
nginxChartArchiveData string

//go:embed assets/redis-app-0.1.0.tgz
redisChartArchiveData string

//go:embed assets/install-license.yaml
licenseData string
Expand Down Expand Up @@ -156,7 +159,8 @@ func embedReleaseData(clusterConfig string) error {
"application.yaml": []byte(applicationData),
"config.yaml": []byte(configData),
"chart.yaml": []byte(helmChartData),
"nginx-app-0.1.0.tgz": []byte(helmChartArchiveData),
"nginx-app-0.1.0.tgz": []byte(nginxChartArchiveData),
"redis-app-0.1.0.tgz": []byte(redisChartArchiveData),
}); err != nil {
return fmt.Errorf("set release data: %v", err)
}
Expand Down
18 changes: 14 additions & 4 deletions tests/dryrun/v3_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1810,8 +1810,11 @@ func validateVeleroPlugin(t *testing.T, hcli *helm.MockClient) {
}

var (
//go:embed assets/rendered-chart-preflight.yaml
renderedChartPreflightData string
//go:embed assets/rendered-nginx-chart-preflight.yaml
renderedNginxChartPreflightData string

//go:embed assets/rendered-redis-chart-preflight.yaml
renderedRedisChartPreflightData string

//go:embed assets/kotskinds-config-values.yaml
configValuesData string
Expand Down Expand Up @@ -1847,7 +1850,8 @@ func setupV3Test(t *testing.T, opts setupV3TestOpts) (string, string) {
"application.yaml": []byte(applicationData),
"config.yaml": []byte(configData),
"chart.yaml": []byte(helmChartData),
"nginx-app-0.1.0.tgz": []byte(helmChartArchiveData),
"nginx-app-0.1.0.tgz": []byte(nginxChartArchiveData),
"redis-app-0.1.0.tgz": []byte(redisChartArchiveData),
}); err != nil {
t.Fatalf("fail to set release data: %v", err)
}
Expand Down Expand Up @@ -1893,7 +1897,13 @@ func setupV3TestHelmClient() *helm.MockClient {
On("Render", mock.Anything, mock.MatchedBy(func(opts helm.InstallOptions) bool {
return opts.ReleaseName == "nginx-app"
})).
Return([][]byte{[]byte(renderedChartPreflightData)}, nil).
Return([][]byte{[]byte(renderedNginxChartPreflightData)}, nil).
Maybe()
hcli.
On("Render", mock.Anything, mock.MatchedBy(func(opts helm.InstallOptions) bool {
return opts.ReleaseName == "redis-app"
})).
Return([][]byte{[]byte(renderedRedisChartPreflightData)}, nil).
Maybe()
hcli.On("Close").Return(nil).Maybe()

Expand Down
11 changes: 9 additions & 2 deletions tests/dryrun/v3_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ func setupV3UpgradeTest(t *testing.T, hcli helm.Client, setupArgs *v3UpgradeSetu
"application.yaml": []byte(applicationData),
"config.yaml": []byte(configData),
"chart.yaml": []byte(helmChartData),
"nginx-app-0.1.0.tgz": []byte(helmChartArchiveData),
"nginx-app-0.1.0.tgz": []byte(nginxChartArchiveData),
"redis-app-0.1.0.tgz": []byte(redisChartArchiveData),
}); err != nil {
t.Fatalf("fail to set release data: %v", err)
}
Expand Down Expand Up @@ -400,7 +401,13 @@ func setupV3UpgradeTestHelmClient() *helm.MockClient {
On("Render", mock.Anything, mock.MatchedBy(func(opts helm.InstallOptions) bool {
return opts.ReleaseName == "nginx-app"
})).
Return([][]byte{[]byte(renderedChartPreflightData)}, nil).
Return([][]byte{[]byte(renderedNginxChartPreflightData)}, nil).
Maybe()
hcli.
On("Render", mock.Anything, mock.MatchedBy(func(opts helm.InstallOptions) bool {
return opts.ReleaseName == "redis-app"
})).
Return([][]byte{[]byte(renderedRedisChartPreflightData)}, nil).
Maybe()
hcli.On("Close").Return(nil).Maybe()
return hcli
Expand Down
Loading