Skip to content

Commit a2c2c89

Browse files
authored
Merge pull request #1846 from cncf/1840_core_validator
Add 5G Core Validator Test #1840
2 parents 8758bce + 09bbee5 commit a2c2c89

File tree

16 files changed

+395
-59
lines changed

16 files changed

+395
-59
lines changed

sample-cnfs/sample_open5gs/cnf-testsuite.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ helm_directory: open5gs
33
release_name: open5gs
44
allowlist_helm_chart_container_names: []
55
#optional 5gcore tag
6-
core_label: app.kubernetes.io/name=amf
6+
amf_label: app.kubernetes.io/name=amf
7+
smf_label: app.kubernetes.io/name=smf
8+
upf_label: app.kubernetes.io/name=upf
79
amf_pod_name: open5gs-amf-ngap
810
mmc: '999'
911
mnc: '70'

sample-cnfs/sample_open5gs_no_auth/cnf-testsuite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ helm_directory: open5gs
33
release_name: open5gs
44
allowlist_helm_chart_container_names: []
55
#optional 5gcore tag
6-
core_label: app.kubernetes.io/name=amf
6+
amf_label: app.kubernetes.io/name=amf
77
amf_pod_name: open5gs-amf-ngap
88
mmc: '999'
99
mnc: '70'

shard.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ shards:
5454

5555
kubectl_client:
5656
git: https://github.com/cnf-testsuite/kubectl_client.git
57-
version: 1.0.4
57+
version: 1.0.5
5858

5959
popcorn:
6060
git: https://github.com/icyleaf/popcorn.git
@@ -66,15 +66,15 @@ shards:
6666

6767
readline:
6868
git: https://github.com/crystal-lang/crystal-readline.git
69-
version: 0.1.1+git.commit.add6679775d59c164e2db04f5116557180d04ad9
69+
version: 0.1.1+git.commit.69ecf33d7cad5568d7d19333510cfd9d17cb1bbd
7070

7171
release_manager:
7272
git: https://github.com/cnf-testsuite/release_manager.git
7373
version: 0.1.0+git.commit.a1d7b3568d3112f737ab3ff4a7bae69a6b86970a
7474

7575
retriable:
7676
git: https://github.com/sija/retriable.cr.git
77-
version: 0.2.4
77+
version: 0.2.5
7878

7979
sam:
8080
git: https://github.com/vulk/sam.cr.git

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies:
4949
version: ~> 1.0.0
5050
kubectl_client:
5151
github: cnf-testsuite/kubectl_client
52-
version: ~> 1.0.4
52+
version: ~> 1.0.5
5353
cluster_tools:
5454
github: cnf-testsuite/cluster_tools
5555
version: ~> 1.0.0

spec/5g/core_spec.cr

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require "../spec_helper"
2+
require "colorize"
3+
require "../../src/tasks/utils/utils.cr"
4+
require "../../src/tasks/kind_setup.cr"
5+
require "file_utils"
6+
require "sam"
7+
8+
describe "Core" do
9+
10+
before_all do
11+
`./cnf-testsuite setup`
12+
$?.success?.should be_true end
13+
14+
it "'smf_upf_heartbeat' should pass if the smf_upf core is resilient to network latency", tags: ["core"] do
15+
begin
16+
Log.info {`./cnf-testsuite cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml`}
17+
$?.success?.should be_true
18+
response_s = `./cnf-testsuite smf_upf_heartbeat verbose`
19+
Log.info {"response: #{response_s}"}
20+
(/PASSED: Chaos service degradation is less than 50%/ =~ response_s).should_not be_nil
21+
ensure
22+
Log.info {`./cnf-testsuite cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml`}
23+
$?.success?.should be_true
24+
end
25+
end
26+
27+
it "'smf_upf_heartbeat' should fail if the smf_upf core is not resilient to network latency", tags: ["core"] do
28+
begin
29+
Log.info {`./cnf-testsuite cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml`}
30+
$?.success?.should be_true
31+
response_s = `./cnf-testsuite smf_upf_heartbeat verbose baseline_count=300`
32+
Log.info {"response: #{response_s}"}
33+
(/FAILED: Chaos service degradation is more than 50%/ =~ response_s).should_not be_nil
34+
ensure
35+
Log.info {`./cnf-testsuite cnf_cleanup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml`}
36+
$?.success?.should be_true
37+
end
38+
end
39+
40+
end

spec/5g/ran_spec.cr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ describe "5g" do
1414

1515
it "'suci_enabled' should pass if the 5G core has suci enabled", tags: ["5g"] do
1616
begin
17-
# `/bin/bash -c "#{Dir.current}/spec/5g/key-setup.sh"`
18-
# KubectlClient::Create.command("-f ./configmap.yml")
19-
# Helm.fetch("openverso/open5gs --version 2.0.11 --untar")
20-
# File.copy("#{Dir.current}/spec/fixtures/udm-config-open5gs.yml", "#{Dir.current}/open5gs/charts/open5gs-udm/resources/config/udm.yaml")
21-
# Helm.install("open5gs #{Dir.current}/open5gs --values #{Dir.current}/spec/fixtures/5g-core-config.yml")
22-
# KubectlClient::Get.wait_for_install("open5gs-pcf")
23-
# $?.success?.should be_true
24-
# # (/PASSED: CNF compatible with both Calico and Cilium/ =~ response_s).should_not be_nil
2517
Log.info {`./cnf-testsuite cnf_setup cnf-config=sample-cnfs/sample_open5gs/cnf-testsuite.yml`}
2618
$?.success?.should be_true
2719
response_s = `./cnf-testsuite suci_enabled verbose`

src/tasks/utils/config.cr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ module CNFManager
3535
white_list_container_names: Array(String),
3636
docker_insecure_registries: Array(String) | Nil,
3737
#todo change this to an array of labels that capture all of 5g core nodes
38-
core_label: String,
38+
amf_label: String,
39+
smf_label: String,
40+
upf_label: String,
3941
ric_label: String,
4042
fiveG_core: NamedTuple(amf_pod_name: String,
4143
mmc: String,
@@ -129,7 +131,9 @@ module CNFManager
129131
apn: optional_key_as_string(config, "apn"),
130132
emergency: core_emergency,
131133
}
132-
core = optional_key_as_string(config, "core_label")
134+
core = optional_key_as_string(config, "amf_label")
135+
smf = optional_key_as_string(config, "smf_label")
136+
upf = optional_key_as_string(config, "upf_label")
133137
ric = optional_key_as_string(config, "ric_label")
134138
if helm_directory.empty?
135139
working_chart_directory = "exported_chart"
@@ -208,7 +212,9 @@ module CNFManager
208212
container_names: container_names,
209213
white_list_container_names: white_list_container_names,
210214
docker_insecure_registries: docker_insecure_registries,
211-
core_label: core,
215+
amf_label: core,
216+
smf_label: smf,
217+
upf_label: upf,
212218
ric_label: ric,
213219
fiveG_core: fiveG_core,
214220
image_registry_fqdns: image_registry_fqdns,})

src/tasks/utils/k8s_tshark.cr

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,49 @@ module K8sTshark
3232
# ClusterTools.exec_by_node_bg("tshark -ni any -a duration:120 -Y nas_5gs.mm.type_id -T json 2>&1 | tee #{tshark_log_name}", node)
3333
# Log.info { "after exec by node bg" }
3434
# resp = tshark_log_name
35-
resp = log_of_tshark_by_node(command, node, duration="120")
35+
resp = log_of_tshark_by_node(command, node, duration)
3636
else
3737
resp = "label key:#{label_key} value: #{label_value} not found"
3838
end
3939
Log.info { "resp #{resp}" }
4040
resp
4141
end
4242

43+
def self.log_of_tshark_by_label_bg(command, label_key, label_value, duration="120") : String
44+
Log.info { "log_of_tshark_by_label command label_key label value: #{command} #{label_key} #{label_value}" }
45+
all_pods = KubectlClient::Get.pods_by_nodes(KubectlClient::Get.schedulable_nodes_list)
46+
pods = KubectlClient::Get.pods_by_label(all_pods, label_key, label_value)
47+
first_labeled_pod = pods[0]?
48+
Log.info { "first_labeled_pod: #{first_labeled_pod}" }
49+
if first_labeled_pod && first_labeled_pod.dig?("metadata", "name")
50+
Log.info { "first_labeled_pod #{first_labeled_pod} metadata name: #{first_labeled_pod.dig?("metadata", "name")}" }
51+
pod_name = first_labeled_pod.dig("metadata", "name")
52+
Log.info { "pod_name: #{pod_name}" }
53+
nodes = KubectlClient::Get.nodes_by_pod(first_labeled_pod)
54+
node = nodes.first
55+
#create a unique name for the log
56+
# rnd = Random.new
57+
# name_id = rnd.next_int
58+
# tshark_log_name = "/tmp/tshark-#{name_id}.json"
59+
# Log.info { "tshark_log_name #{tshark_log_name}" }
60+
#
61+
# #tshark -ni any -Y nas_5gs.mm.type_id -T json 2>&1 | tee hi.log
62+
# #command= -ni any -Y nas_5gs.mm.type_id -T json
63+
# #todo check if tshark running already to keep from saturating network
64+
# #todo play with reducing default duration
65+
# ClusterTools.exec_by_node_bg("tshark #{command} -a duration:#{duration} 2>&1 | tee #{tshark_log_name}", node)
66+
# ClusterTools.exec_by_node_bg("tshark -ni any -a duration:120 -Y nas_5gs.mm.type_id -T json 2>&1 | tee #{tshark_log_name}", node)
67+
# Log.info { "after exec by node bg" }
68+
# resp = tshark_log_name
69+
resp = log_of_tshark_by_node_bg(command, node, duration="120")
70+
else
71+
resp = "label key:#{label_key} value: #{label_value} not found"
72+
end
73+
Log.info { "resp #{resp}" }
74+
resp
75+
end
76+
77+
4378
def self.log_of_tshark_by_node(command, node, duration="120") : String
4479
Log.info { "log_of_tshark_by_node: command #{command}" }
4580
#create a unique name for the log
@@ -48,6 +83,22 @@ module K8sTshark
4883
tshark_log_name = "/tmp/tshark-#{name_id}.json"
4984
Log.info { "log_of_tshark_by_node tshark_log_name #{tshark_log_name}" }
5085

86+
#tshark -ni any -Y nas_5gs.mm.type_id -T json 2>&1 | tee hi.log
87+
#command= -ni any -Y nas_5gs.mm.type_id -T json
88+
#todo check if tshark running already to keep from saturating network
89+
ClusterTools.exec_by_node("tshark #{command} -a duration:#{duration} 2>&1 | tee #{tshark_log_name}", node)
90+
Log.info { "after exec by node bg" }
91+
tshark_log_name
92+
end
93+
94+
def self.log_of_tshark_by_node_bg(command, node, duration="120") : String
95+
Log.info { "log_of_tshark_by_node: command #{command}" }
96+
#create a unique name for the log
97+
rnd = Random.new
98+
name_id = rnd.next_int.abs
99+
tshark_log_name = "/tmp/tshark-#{name_id}.json"
100+
Log.info { "log_of_tshark_by_node tshark_log_name #{tshark_log_name}" }
101+
51102
#tshark -ni any -Y nas_5gs.mm.type_id -T json 2>&1 | tee hi.log
52103
#command= -ni any -Y nas_5gs.mm.type_id -T json
53104
#todo check if tshark running already to keep from saturating network
@@ -56,23 +107,45 @@ module K8sTshark
56107
tshark_log_name
57108
end
58109

59-
def self.regex_tshark_log(regex, tshark_log_name)
110+
111+
def self.regex_tshark_log_scan(regex, tshark_log_name)
112+
Log.info { "regex_tshark_log regex tshark_log_name: #{regex} #{tshark_log_name}" }
113+
resp = File.read("#{tshark_log_name}")
114+
Log.debug { "tshark_log_name resp: #{resp}" }
115+
if resp
116+
Log.debug { "resp: #{resp}" }
117+
ret = resp.scan(regex)
118+
else
119+
Log.info { "file empty" }
120+
ret = nil
121+
end
122+
Log.info { "#{regex}: #{ret}" }
123+
ret
124+
end
125+
126+
def self.regex_tshark_log_match(regex, tshark_log_name)
60127
Log.info { "regex_tshark_log regex tshark_log_name: #{regex} #{tshark_log_name}" }
61-
regex_found : Bool | Nil
62128
resp = File.read("#{tshark_log_name}")
63129
Log.info { "tshark_log_name resp: #{resp}" }
64130
if resp
65131
Log.info { "resp: #{resp}" }
66-
if resp =~ regex
67-
regex_found = true
68-
else
69-
regex_found = false
70-
end
132+
ret = resp =~ regex
71133
else
72134
Log.info { "file empty" }
135+
ret = nil
136+
end
137+
Log.info { "#{regex}: #{ret}" }
138+
ret
139+
end
140+
141+
def self.regex_tshark_log(regex, tshark_log_name)
142+
Log.info { "regex_tshark_log regex tshark_log_name: #{regex} #{tshark_log_name}" }
143+
regex_found : Bool | Nil
144+
if regex_tshark_log_match(regex, tshark_log_name)
145+
regex_found = true
146+
else
73147
regex_found = false
74148
end
75-
Log.info { "#{regex}: #{regex_found}" }
76149
regex_found
77150
end
78151

src/tasks/utils/oran_monitor.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module ORANMonitor
3737
resp = ClusterTools.exec_by_node("tshark --version", node)
3838
Log.info { "tshark must be version 4.0.3 or higher" }
3939
Log.info { "tshark output #{resp[:output]}" }
40-
tshark_log_name = K8sTshark.log_of_tshark_by_node(command,node)
40+
tshark_log_name = K8sTshark.log_of_tshark_by_node_bg(command,node)
4141
else
4242
tshark_log_name = nil
4343
end

src/tasks/utils/srsran.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module SRSRAN
1414

1515
def self.install(config)
1616
Log.info {"Installing srsran"}
17-
core = config.cnf_config[:core_label]?
17+
core = config.cnf_config[:amf_label]?
1818
Log.info { "core: #{core}" }
1919
#todo use sane defaults (i.e. search for amf, upf, etc in pod names) if no 5gcore labels are present
2020
amf_pod_name = config.cnf_config[:fiveG_core][:amf_pod_name]?
@@ -34,8 +34,8 @@ module SRSRAN
3434
emergency = config.cnf_config[:fiveG_core][:emergency]?
3535
core_key : String = ""
3636
core_value : String = ""
37-
core_key = config.cnf_config[:core_label].split("=").first if core
38-
core_value = config.cnf_config[:core_label].split("=").last if core
37+
core_key = config.cnf_config[:amf_label].split("=").first if core
38+
core_value = config.cnf_config[:amf_label].split("=").last if core
3939
if core
4040
all_pods = KubectlClient::Get.pods_by_nodes(KubectlClient::Get.schedulable_nodes_list)
4141
ueran_pods = KubectlClient::Get.pods_by_label(all_pods, "app.kubernetes.io/name", "ueransim-gnb")

0 commit comments

Comments
 (0)