Skip to content

Commit

Permalink
Test: Verify new installation process through actions.
Browse files Browse the repository at this point in the history
Refs: #2168
- This commit serves to verify that the new installation process
is working by passing actions.

Signed-off-by: svteb <[email protected]>
  • Loading branch information
svteb committed Nov 1, 2024
1 parent 23c26e0 commit 969bdb2
Show file tree
Hide file tree
Showing 25 changed files with 301 additions and 329 deletions.
20 changes: 8 additions & 12 deletions spec/5g/core_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,41 @@ describe "Core" do

it "'smf_upf_heartbeat' should pass if the smf_upf core is resilient to network latency", tags: ["core"] do
begin
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result = ShellCmd.run_testsuite("smf_upf_heartbeat verbose")
(/(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
ShellCmd.new_cnf_cleanup()
end
end

it "'smf_upf_heartbeat' should fail if the smf_upf core is not resilient to network latency", tags: ["core"] do
begin
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
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
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result[:status].success?.should be_true
ShellCmd.new_cnf_cleanup()
end
end

it "'suci_enabled' should pass if the 5G core has suci enabled", tags: ["5g"] do
begin
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml")
result = ShellCmd.run_testsuite("suci_enabled verbose")
(/(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
ShellCmd.new_cnf_cleanup()
end
end

it "'suci_enabled' should fail if the 5G core does not have suci enabled", tags: ["5g"] do
begin
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample_open5gs_no_auth/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample_open5gs_no_auth/cnf-testsuite.yml")
result = ShellCmd.run_testsuite("suci_enabled verbose")
(/(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
ShellCmd.new_cnf_cleanup()
end
end

Expand Down
10 changes: 4 additions & 6 deletions spec/5g/ran_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,27 @@ describe "5g" do
begin
setup_success = setup_5g_network
setup_success.should be_true
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample-oran-ric/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample-oran-ric/cnf-testsuite.yml")
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

Check failure on line 43 in spec/5g/ran_spec.cr

View workflow job for this annotation

GitHub Actions / Chaos & Oran Tests (oran)

Expected: nil not to be nil
ensure
result = Helm.delete("open5gs -n oran")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample-oran-ric/cnf-testsuite.yml")
result[:status].success?.should be_true
ShellCmd.new_cnf_cleanup()
end
end

it "'oran_e2_connection' should fail if the ORAN enabled RAN does not connect to the RIC using the e2 standard", tags: ["oran"] do
begin
setup_success = setup_5g_network
setup_success.should be_true
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample-oran-noric/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample-oran-noric/cnf-testsuite.yml")
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

Check failure on line 57 in spec/5g/ran_spec.cr

View workflow job for this annotation

GitHub Actions / Chaos & Oran Tests (oran)

Expected: nil not to be nil
ensure
result = Helm.delete("open5gs -n oran")
result[:status].success?.should be_true
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=sample-cnfs/sample-oran-noric/cnf-testsuite.yml")
result[:status].success?.should be_true
ShellCmd.new_cnf_cleanup()
end
end

Expand Down
35 changes: 14 additions & 21 deletions spec/setup_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,66 @@ describe "Setup" do

it "'cnf_setup/cnf_cleanup' should install/cleanup with cnf-path arg as alias for cnf-config", tags: ["setup"] do
begin
result = ShellCmd.cnf_setup("cnf-path=example-cnfs/coredns/cnf-testsuite.yml")
result = ShellCmd.new_cnf_setup("cnf-path=example-cnfs/coredns/cnf-testsuite.yml")
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=example-cnfs/coredns/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
end
end

it "'cnf_setup/cnf_cleanup' should install/cleanup a cnf with a cnf-testsuite.yml", tags: ["setup"] do
begin
result = ShellCmd.cnf_setup("cnf-config=example-cnfs/coredns/cnf-testsuite.yml")
result = ShellCmd.new_cnf_setup("cnf-config=example-cnfs/coredns/cnf-testsuite.yml")
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=example-cnfs/coredns/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
end
end

it "'cnf_setup/cnf_cleanup' should work with cnf-testsuite.yml that has no directory associated with it", tags: ["setup"] do
begin
#TODO force cnfs/<name> to be deployment name and not the directory name
result = ShellCmd.cnf_setup("cnf-config=spec/fixtures/cnf-testsuite.yml verbose")
result = ShellCmd.new_cnf_setup("cnf-config=spec/fixtures/cnf-testsuite.yml verbose")
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
ensure

result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=spec/fixtures/cnf-testsuite.yml verbose")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
end
end

it "'cnf_setup/cnf_cleanup' should install/cleanup with helm_directory that descends multiple directories", tags: ["setup"] do
begin
result = ShellCmd.cnf_setup("cnf-path=sample-cnfs/multi_helm_directories/cnf-testsuite.yml")
result = ShellCmd.new_cnf_setup("cnf-path=sample-cnfs/multi_helm_directories/cnf-testsuite.yml")
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=sample-cnfs/multi_helm_directories/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
end
end

it "'cnf_setup/cnf_cleanup' should properly install/uninstall old versions of cnf configs", tags: ["setup"] do
begin
result = ShellCmd.cnf_setup("cnf-path=spec/fixtures/cnf-testsuite-v1-example.yml")
result = ShellCmd.new_cnf_setup("cnf-path=spec/fixtures/cnf-testsuite-v1-example.yml")
result[:status].success?.should be_true
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=spec/fixtures/cnf-testsuite-v1-example.yml")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
end
end

it "'cnf_setup' should fail if another CNF is already installed", tags: ["setup"] do
begin
result = ShellCmd.cnf_setup("cnf-path=sample-cnfs/sample_coredns/cnf-testsuite.yml")
result = ShellCmd.new_cnf_setup("cnf-path=sample-cnfs/sample_coredns/cnf-testsuite.yml")
(/Successfully setup coredns/ =~ result[:output]).should_not be_nil
result = ShellCmd.cnf_setup("cnf-path=sample-cnfs/sample-minimal-cnf/cnf-testsuite.yml")
result = ShellCmd.new_cnf_setup("cnf-path=sample-cnfs/sample-minimal-cnf/cnf-testsuite.yml")
(/A CNF is already set up. Setting up multiple CNFs is not allowed./ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=sample-cnfs/sample_coredns/cnf-testsuite.yml")
result[:status].success?.should be_true
result = ShellCmd.new_cnf_cleanup()
(/Successfully cleaned up/ =~ result[:output]).should_not be_nil
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=sample-cnfs/sample-minimal-cnf/cnf-testsuite.yml")
ShellCmd.new_cnf_cleanup(expect_failure: true)
end
end
end
20 changes: 20 additions & 0 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,24 @@ module ShellCmd
end
result
end

def self.new_cnf_setup(setup_params, cmd_prefix="", expect_failure=false)
result = run_testsuite("new_cnf_setup #{setup_params} timeout=300", cmd_prefix)
if !expect_failure
result[:status].success?.should be_true
else
result[:status].success?.should be_false
end
result
end

def self.new_cnf_cleanup(expect_failure=false)
result = run_testsuite("new_cnf_cleanup")
if !expect_failure
result[:status].success?.should be_true
else
result[:status].success?.should be_false
end
result
end
end
12 changes: 6 additions & 6 deletions spec/utils/cnf_manager_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ describe "SampleUtils" do
end

it "'cnf_setup' should pass with a minimal cnf-testsuite.yml", tags: ["cnf-setup"] do
ShellCmd.cnf_setup("cnf-path=./sample-cnfs/sample-minimal-cnf/ skip_wait_for_install")
ShellCmd.new_cnf_setup("cnf-path=./sample-cnfs/sample-minimal-cnf/ skip_wait_for_install")
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=./sample-cnfs/sample-minimal-cnf/ force=true")
ShellCmd.new_cnf_cleanup()
end

it "'cnf_setup' should support cnf-config as an alias for cnf-path", tags: ["cnf-setup"] do
ShellCmd.cnf_setup("cnf-config=./sample-cnfs/sample-minimal-cnf/ skip_wait_for_install")
ShellCmd.new_cnf_setup("cnf-config=./sample-cnfs/sample-minimal-cnf/ skip_wait_for_install")
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=./sample-cnfs/sample-minimal-cnf/ force=true")
ShellCmd.new_cnf_cleanup()
end

it "'points_yml' should parse and return the points yaml file", tags: ["points"] do
Expand Down Expand Up @@ -348,13 +348,13 @@ describe "SampleUtils" do
it "Helm_values should be used during the installation of a cnf", tags: ["cnf-config"] do
begin
# fails because doesn't have a service
ShellCmd.cnf_setup("cnf-path=./sample-cnfs/sample_coredns_values")
ShellCmd.new_cnf_setup("cnf-path=./sample-cnfs/sample_coredns_values")
deployment_containers = KubectlClient::Get.resource_containers("deployment", "coredns-coredns", "cnf-default")
image_tags = KubectlClient::Get.container_image_tags(deployment_containers)
Log.info { "image_tags: #{image_tags}" }
(/1.6.9/ =~ image_tags[0][:tag]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-path=./sample-cnfs/sample_coredns_values")
ShellCmd.new_cnf_cleanup()
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/utils/kubescape_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe "K8sInstrumentation" do
end

it "'#scan and #test_by_test_name' should return the results of a kubescape scan", tags: ["kubescape"] do
ShellCmd.cnf_setup("cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.yml")
Kubescape.scan
results_json = Kubescape.parse
test_json = Kubescape.test_by_test_name(results_json, "Network policies")
(test_json).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.ymll")
ShellCmd.new_cnf_cleanup()
end

end
2 changes: 1 addition & 1 deletion spec/utils/utils_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe "Utils" do
end

it "'logger' or verbose output should be shown when verbose flag is set", tags: ["logger"] do
ShellCmd.cnf_setup("cnf-path=sample-cnfs/sample-coredns-cnf")
ShellCmd.new_cnf_setup("cnf-path=sample-cnfs/sample-coredns-cnf")
result = ShellCmd.run_testsuite("helm_deploy verbose", cmd_prefix: "LOG_LEVEL=info")
puts result[:output]
result[:status].success?.should be_true
Expand Down
9 changes: 4 additions & 5 deletions spec/workload/compatibility_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe "Compatibility" do

it "'cni_compatible' should pass if the cnf works with calico and flannel", tags: ["compatibility"] do
begin
ShellCmd.cnf_setup("cnf-config=sample-cnfs/sample-coredns-cnf/cnf-testsuite.yml")
ShellCmd.new_cnf_setup("cnf-config=sample-cnfs/sample-coredns-cnf/cnf-testsuite.yml")
retry_limit = 5
retries = 1
result = ShellCmd.run_testsuite("cni_compatible verbose")
Expand All @@ -27,19 +27,18 @@ describe "Compatibility" do
Log.info { "Status: #{result[:output]}" }
(/(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
ShellCmd.new_cnf_cleanup()
end
end

it "'increase_decrease_capacity' should pass ", tags: ["increase_decrease_capacity"] do
begin
ShellCmd.cnf_setup("cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.yml verbose skip_wait_for_install")
ShellCmd.new_cnf_setup("cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.yml verbose skip_wait_for_install")
result = ShellCmd.run_testsuite("increase_decrease_capacity verbose")
result[:status].success?.should be_true
(/(PASSED).*(Replicas increased to)/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("cnf_cleanup cnf-config=./sample-cnfs/sample_coredns/cnf-testsuite.yml")
ShellCmd.new_cnf_cleanup()
end
end
end
Loading

0 comments on commit 969bdb2

Please sign in to comment.