Skip to content

Commit

Permalink
output: Add test name before and after the test
Browse files Browse the repository at this point in the history
Ref: #1958
Add information of which test is starting to the console output
Add test name to test result console output

Signed-off-by: Konstantin Yarovoy <[email protected]>
  • Loading branch information
Konstantin Yarovoy committed Apr 19, 2024
1 parent 5961641 commit 5a1512d
Show file tree
Hide file tree
Showing 27 changed files with 137 additions and 136 deletions.
8 changes: 4 additions & 4 deletions spec/5g/core_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe "Core" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("smf_upf_heartbeat verbose")
(/PASSED: Chaos service degradation is less than 50%/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] Chaos service degradation is less than 50%/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand All @@ -29,7 +29,7 @@ describe "Core" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("smf_upf_heartbeat verbose baseline_count=300")
(/FAILED: Chaos service degradation is more than 50%/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] Chaos service degradation is more than 50%/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand All @@ -41,7 +41,7 @@ describe "Core" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("suci_enabled verbose")
(/PASSED: Core uses SUCI 5g authentication/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] Core uses SUCI 5g authentication/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand All @@ -53,7 +53,7 @@ describe "Core" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample_open5gs_no_auth/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("suci_enabled verbose")
(/FAILED: Core does not use SUCI 5g authentication/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] Core does not use SUCI 5g authentication/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs_no_auth/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand Down
4 changes: 2 additions & 2 deletions spec/5g/ran_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe "5g" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample-oran-ric/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("oran_e2_connection verbose")
(/PASSED: RAN connects to a RIC using the e2 standard interface/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] RAN connects to a RIC using the e2 standard interface/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample-oran-ric/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand All @@ -36,7 +36,7 @@ describe "5g" do
result = ShellCmd.run_testsuite("cnf_setup cnf-config=sample-cnfs/sample-oran-noric/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("oran_e2_connection verbose")
(/FAILED: RAN does not connect to a RIC using the e2 standard interface/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] RAN does not connect to a RIC using the e2 standard interface/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand Down
2 changes: 1 addition & 1 deletion spec/platform/platform_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe "Platform" do
end
it "'k8s_conformance' should pass if the sonobuoy tests pass", tags: ["platform"] do
result = ShellCmd.run_testsuite("k8s_conformance")
(/PASSED: K8s conformance test has no failures/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] K8s conformance test has no failures/ =~ result[:output]).should_not be_nil
end

it "individual tasks like 'platform:exposed_dashboard' should not require an installed cnf to run", tags: ["platform"] do
Expand Down
2 changes: 1 addition & 1 deletion spec/platform/resilience_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe "Platform" do
if check_destructive
puts "Tests running in destructive mode".colorize(:red)
result = ShellCmd.run_testsuite("platform:worker_reboot_recovery destructive")
(/(PASSED: Node came back online)/ =~ result[:output]).should_not be_nil
(/(PASSED: \[[^\]]*\] Node came back online)/ =~ result[:output]).should_not be_nil
else
result = ShellCmd.run_testsuite("platform:worker_reboot_recovery")
(/SKIPPED/ =~ result[:output]).should_not be_nil
Expand Down
12 changes: 6 additions & 6 deletions spec/platform/security_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ describe "Platform" do

it "'control_plane_hardening' should pass if the control plane has been hardened", tags: ["platform:security"] do
result = ShellCmd.run_testsuite("platform:control_plane_hardening")
(/(PASSED: Control plane hardened)/ =~ result[:output]).should_not be_nil
(/(PASSED: \[[^\]]*\] Control plane hardened)/ =~ result[:output]).should_not be_nil
end

it "'cluster_admin' should fail on a cnf that uses a cluster admin binding", tags: ["platform:security"] do
begin
result = ShellCmd.run_testsuite("platform:cluster_admin")
result[:status].success?.should be_true
(/FAILED: Users with cluster admin role found/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] Users with cluster admin role found/ =~ result[:output]).should_not be_nil
end
end

Expand All @@ -26,7 +26,7 @@ describe "Platform" do
begin
# Run the exposed_dashboard test to confirm no vulnerability before dashboard is installed
result = ShellCmd.run_testsuite("platform:exposed_dashboard")
(/PASSED: No exposed dashboard found in the cluster/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] No exposed dashboard found in the cluster/ =~ result[:output]).should_not be_nil

# Install the dashboard version 2.0.0.
# According to the kubescape rule, anything less than v2.0.1 would fail.
Expand All @@ -52,7 +52,7 @@ describe "Platform" do
# Run the test again to confirm vulnerability with an exposed dashboard
result = ShellCmd.run_testsuite("platform:exposed_dashboard")
result[:status].success?.should be_true
(/FAILED: Found exposed dashboard in the cluster/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] Found exposed dashboard in the cluster/ =~ result[:output]).should_not be_nil
ensure
# Ensure to remove the Kubectl dashboard after the test
KubectlClient::Delete.file(dashboard_install_url)
Expand All @@ -64,7 +64,7 @@ describe "Platform" do
KubectlClient::Get.resource_wait_for_install("pod", "tiller")
result = ShellCmd.run_testsuite("platform:helm_tiller")
result[:status].success?.should be_true
(/FAILED: Containers with the Helm Tiller image are running/ =~ result[:output]).should_not be_nil
(/FAILED: \[[^\]]*\] Containers with the Helm Tiller image are running/ =~ result[:output]).should_not be_nil
ensure
KubectlClient::Delete.command("pod/tiller")
KubectlClient::Get.resource_wait_for_uninstall("pod", "tiller")
Expand All @@ -74,6 +74,6 @@ describe "Platform" do
# By default we have nothing to setup for this task to pass since Helm v3 does not use Tiller.
result = ShellCmd.run_testsuite("platform:helm_tiller")
result[:status].success?.should be_true
(/PASSED: No Helm Tiller containers are running/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] No Helm Tiller containers are running/ =~ result[:output]).should_not be_nil
end
end
4 changes: 2 additions & 2 deletions spec/utils/cnf_manager_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ describe "SampleUtils" do

it "'CNFManager::Points.total_max_points' should not include na in the total potential points", tags: ["points"] do
CNFManager::Points.clean_results_yml
upsert_passed_task("liveness", "✔️ PASSED: CNF had a reasonable startup time ", Time.utc)
upsert_passed_task("liveness", "✔️ PASSED: [liveness] CNF had a reasonable startup time ", Time.utc)
resp1 = CNFManager::Points.total_max_points
upsert_na_task("readiness", "✔️ NA", Time.utc)
upsert_na_task("readiness", "✔️ N/A: [readiness]", Time.utc)
resp2 = CNFManager::Points.total_max_points

Log.info { "readiness points: #{CNFManager::Points.task_points("readiness").not_nil!.to_i}" }
Expand Down
22 changes: 11 additions & 11 deletions spec/utils/utils_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe "Utils" do

it "'upsert_skipped_task' should put a 0 in the results file", tags: ["task_runner"] do
CNFManager::Points.clean_results_yml
resp = upsert_skipped_task("ip_addresses","✖️ FAILED: IP addresses found", Time.utc)
resp = upsert_skipped_task("ip_addresses","✖️ FAILED: [ip_addresses] IP addresses found", Time.utc)
yaml = File.open("#{CNFManager::Points::Results.file}") do |file|
YAML.parse(file)
end
Expand Down Expand Up @@ -102,14 +102,14 @@ describe "Utils" do
Log.debug { "violator list: #{violation_list.flatten}" }
emoji_security=""
if resource_response
resp = upsert_passed_task("privileged", "✔️ PASSED: No privileged containers", Time.utc)
resp = upsert_passed_task("privileged", "✔️ PASSED: [privileged] No privileged containers", Time.utc)
else
resp = upsert_failed_task("privileged", "✖️ FAILED: Found #{violation_list.size} privileged containers: #{violation_list.inspect}", Time.utc)
resp = upsert_failed_task("privileged", "✖️ FAILED: [privileged] Found #{violation_list.size} privileged containers: #{violation_list.inspect}", Time.utc)
end
Log.info { resp }
resp
end
(task_response).should eq("✔️ PASSED: No privileged containers")
(task_response).should eq("✔️ PASSED: [privileged] No privileged containers")
ensure
CNFManager.sample_cleanup(config_file: "sample-cnfs/sample-generic-cnf", verbose: true)
end
Expand All @@ -131,14 +131,14 @@ describe "Utils" do
end
Dir.cd(cdir)
if response.to_s.size > 0
resp = upsert_failed_task("ip_addresses","✖️ FAILED: IP addresses found", Time.utc)
resp = upsert_failed_task("ip_addresses","✖️ FAILED: [ip_addresses] IP addresses found", Time.utc)
else
resp = upsert_passed_task("ip_addresses", "✔️ PASSED: No IP addresses found", Time.utc)
resp = upsert_passed_task("ip_addresses", "✔️ PASSED: [ip_addresses] No IP addresses found", Time.utc)
end
resp
else
Dir.cd(cdir)
resp = upsert_passed_task("ip_addresses", "✔️ PASSED: No IP addresses found", Time.utc)
resp = upsert_passed_task("ip_addresses", "✔️ PASSED: [ip_addresses] No IP addresses found", Time.utc)
end
end
yaml = File.open("#{CNFManager::Points::Results.file}") do |file|
Expand Down Expand Up @@ -174,14 +174,14 @@ describe "Utils" do
Log.debug { "violator list: #{violation_list.flatten}" }
emoji_security=""
if resource_response
resp = upsert_passed_task("privileged", "✔️ PASSED: No privileged containers", Time.utc)
resp = upsert_passed_task("privileged", "✔️ PASSED: [privileged] No privileged containers", Time.utc)
else
resp = upsert_failed_task("privileged", "✖️ FAILED: Found #{violation_list.size} privileged containers: #{violation_list.inspect}", Time.utc)
resp = upsert_failed_task("privileged", "✖️ FAILED: [privileged] Found #{violation_list.size} privileged containers: #{violation_list.inspect}", Time.utc)
end
resp
end
(task_response).should eq(["✔️ PASSED: No privileged containers",
"✖️ FAILED: Found 1 privileged containers: [\"privileged-coredns\"]"])
(task_response).should eq(["✔️ PASSED: [privileged] No privileged containers",
"✖️ FAILED: [privileged] Found 1 privileged containers: [\"privileged-coredns\"]"])
ensure
CNFManager.sample_cleanup(config_file: "sample-cnfs/sample-generic-cnf", verbose: true)
CNFManager.sample_cleanup(config_file: "sample-cnfs/sample_privileged_cnf", verbose: true)
Expand Down
2 changes: 1 addition & 1 deletion spec/workload/compatibility_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe "Compatibility" do
retries = retries + 1
end
Log.info { "Status: #{result[:output]}" }
(/PASSED: CNF compatible with both Calico and Cilium/ =~ result[:output]).should_not be_nil
(/PASSED: \[[^\]]*\] CNF compatible with both Calico and Cilium/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample-coredns-cnf/cnf-testsuite.yml")
result[:status].success?.should be_true
Expand Down
Loading

0 comments on commit 5a1512d

Please sign in to comment.