@@ -8,8 +8,8 @@ require "../../src/netstat/k8s.cr"
88describe " netstat" do
99 before_all do
1010 begin
11- KubectlClient ::Create .namespace(" cnf-testsuite" )
12- rescue e : KubectlClient ::Create ::AlreadyExistsError
11+ KubectlClient ::Apply .namespace(" cnf-testsuite" )
12+ rescue e : KubectlClient ::ShellCMD ::AlreadyExistsError
1313 end
1414 ClusterTools .install
1515 end
@@ -19,25 +19,28 @@ describe "netstat" do
1919 release_name = " wordpress"
2020 helm_chart_directory = " sample-cnfs/ndn-multi-db-connections-fail/wordpress"
2121
22- after_all do
22+ after_all do
2323 resp = Helm .uninstall(release_name)
24- KubectlClient ::Delete .command(" pvc/data-wordpress-mariadb-0" )
25- KubectlClient ::Delete .command(" pvc/wordpress" )
24+ begin
25+ KubectlClient ::Delete .resource(" pvc" , " data-wordpress-mariadb-0" )
26+ KubectlClient ::Delete .resource(" pvc" , " wordpress" )
27+ rescue ex : KubectlClient ::ShellCMD ::NotFoundError
28+ end
2629 Log .info { resp }
2730 (resp[:status ].exit_status == 0 ).should be_true
2831 end
2932
3033 it " should install" do
3134 helm_install(release_name, helm_chart_directory)
3235 end
33-
36+
3437 it " k8s_netstat should detect multiple pods conected to same db" do
35- KubectlClient ::Get .resource_wait_for_install(kind= " Deployment" , resource_name= " wordpress" , wait_count= 180 , namespace= " default" )
38+ KubectlClient ::Wait .resource_wait_for_install(kind = " Deployment" , resource_name = " wordpress" , wait_count = 180 , namespace = " default" )
3639 violators = Netstat ::K8s .get_multiple_pods_connected_to_mariadb_violators
3740 (Netstat ::K8s .detect_multiple_pods_connected_to_mariadb_from_violators(violators)).should be_false
3841 end
3942 end
40-
43+
4144 describe " cnf with no database is used by two microservices" do
4245 # sample-cnfs/sample-statefulset-cnf
4346 release_name = " test"
@@ -47,23 +50,25 @@ describe "netstat" do
4750 Helm .helm_repo_add(" bitnami" , " https://charts.bitnami.com/bitnami" )
4851 end
4952
50- after_all do
53+ after_all do
5154 resp = Helm .uninstall(release_name)
52- KubectlClient ::Delete .command(" pvc/data-wordpress-mariadb-0" )
53- KubectlClient ::Delete .command(" pvc/wordpress" )
55+ begin
56+ KubectlClient ::Delete .resource(" pvc" , " data-wordpress-mariadb-0" )
57+ KubectlClient ::Delete .resource(" pvc" , " wordpress" )
58+ rescue ex : KubectlClient ::ShellCMD ::NotFoundError
59+ end
5460 Log .info { resp }
5561 (resp[:status ].exit_status == 0 ).should be_true
5662 end
5763
5864 it " should install" do
5965 helm_install(release_name, helm_chart, nil , " --set mariadb.primary.persistence.enabled=false --set persistence.enabled=false" )
6066 end
61-
67+
6268 it " k8s_netstat should detect mutiple pods NOT connected to same db" do
63- KubectlClient ::Get .resource_wait_for_install(kind= " Deployment" , resource_name= " test-wordpress" , wait_count= 180 , namespace= " default" )
69+ KubectlClient ::Wait .resource_wait_for_install(kind = " Deployment" , resource_name = " test-wordpress" , wait_count = 180 , namespace = " default" )
6470 violators = Netstat ::K8s .get_multiple_pods_connected_to_mariadb_violators
6571 (Netstat ::K8s .detect_multiple_pods_connected_to_mariadb_from_violators(violators)).should be_false
6672 end
6773 end
68-
6974end
0 commit comments