Skip to content

Commit

Permalink
Rather set namespace in cnf-testsuite.yml if helm_dirs
Browse files Browse the repository at this point in the history
It also uses the right constant instead of cnf-testsuite directly
and unifies all samples to use namespace cnfspace.

It also fixes a spec test in shared_database, installing now
the chart in a dedicated namespace with the right labels.

Signed-off-by: Cédric Ollivier <[email protected]>
  • Loading branch information
collivier authored and martin-mat committed Jan 22, 2025
1 parent 8e03ab9 commit 4bf8e73
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 26 deletions.
12 changes: 1 addition & 11 deletions sample-cnfs/k8s-multiple-processes/chart/templates/pod.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: cnfspace
labels:
pod-security.kubernetes.io/enforce: privileged

---
apiVersion: v1
kind: Pod
metadata:
name: sidecar-container-demo
namespace: cnfspace
spec:
containers:
- image: busybox
Expand All @@ -33,4 +23,4 @@ spec:
dnsPolicy: Default
volumes:
- name: var-logs
emptyDir: {}
emptyDir: {}
1 change: 1 addition & 0 deletions sample-cnfs/k8s-multiple-processes/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ deployments:
helm_dirs:
- name: sidecar-container-demo
helm_directory: chart
namespace: cnfspace
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: cnfspace
labels:
pod-security.kubernetes.io/enforce: privileged

---
apiVersion: v1
kind: Pod
metadata:
name: sidecar-container-demo
namespace: cnfspace
spec:
containers:
- image: busybox
Expand All @@ -33,4 +23,4 @@ spec:
dnsPolicy: Default
volumes:
- name: var-logs
emptyDir: {}
emptyDir: {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ deployments:
helm_dirs:
- name: sidecar-container-demo
helm_directory: chart
namespace: cnfspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ deployments:
- name: test
helm_directory: wordpress
helm_values: --set mariadb.primary.persistence.enabled=false --set persistence.enabled=false
namespace: cnfspace
1 change: 1 addition & 0 deletions sample-cnfs/sample-statefulset-cnf/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ deployments:
helm_values: --version 15.2.0 --set mariadb.primary.persistence.enabled=false --set persistence.enabled=false
helm_repo_name: bitnami
helm_repo_url: https://charts.bitnami.com/bitnami
namespace: cnfspace
1 change: 1 addition & 0 deletions sample-cnfs/sample_coredns/cnf-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ deployments:
helm_dirs:
- name: coredns
helm_directory: chart
namespace: cnfspace
10 changes: 6 additions & 4 deletions spec/workload/microservice_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ describe "Microservice" do
it "'shared_database' should pass if two services on the cluster connect to the same database but they are not in the helm chart of the cnf", tags: ["shared_database"] do
begin
ShellCmd.cnf_install("cnf-path=sample-cnfs/sample_coredns")
Helm.install("multi-db sample-cnfs/ndn-multi-db-connections-fail/wordpress/")
KubectlClient::Get.resource_wait_for_install(kind: "Deployment", resource_name: "multi-db-wordpress", wait_count: 180, namespace: "default")
KubectlClient::Get.resource_wait_for_install(kind: "Deployment", resource_name: "multi-db-wordpress2", wait_count: 180, namespace: "default")
KubectlClient::Create.namespace(DEFAULT_CNF_NAMESPACE)
ShellCmd.run("kubectl label namespace #{DEFAULT_CNF_NAMESPACE} pod-security.kubernetes.io/enforce=privileged", "Label.namespace")
Helm.install("-n #{DEFAULT_CNF_NAMESPACE} multi-db sample-cnfs/ndn-multi-db-connections-fail/wordpress/")
KubectlClient::Get.resource_wait_for_install(kind: "Deployment", resource_name: "multi-db-wordpress", wait_count: 180, namespace: DEFAULT_CNF_NAMESPACE)
KubectlClient::Get.resource_wait_for_install(kind: "Deployment", resource_name: "multi-db-wordpress2", wait_count: 180, namespace: DEFAULT_CNF_NAMESPACE)
# todo kubctl appy of all resourcesin ndn-multi-db-connections-fail
# todo cnf_install of coredns
# todo run shared_database (should pass)
Expand All @@ -80,7 +82,7 @@ describe "Microservice" do
result[:status].success?.should be_true
(/(PASSED).*(No shared database found)/ =~ result[:output]).should_not be_nil
ensure
Helm.delete("multi-db")
Helm.delete("multi-db -n #{DEFAULT_CNF_NAMESPACE}")
KubectlClient::Delete.command("pvc data-multi-db-mariadb-0")
result = ShellCmd.cnf_uninstall()
result[:status].success?.should be_true
Expand Down

0 comments on commit 4bf8e73

Please sign in to comment.