Skip to content

Commit

Permalink
Ensure Ueransim in uninstall before running testcncf/cnf-testsuite#1803
Browse files Browse the repository at this point in the history
  • Loading branch information
denverwilliams committed Aug 11, 2023
1 parent 846e30d commit cf8e1b2
Showing 1 changed file with 78 additions and 9 deletions.
87 changes: 78 additions & 9 deletions src/tasks/workload/5g.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,88 @@ task "suci_enabled" do |_, args|
CNFManager::Task.task_runner(args) do |args, config|
Log.info { "Running #{test_name} test" }

#todo put in prereq
Helm.fetch("openverso/ueransim-gnb --version 0.2.5 --untar")
File.write("gnb-ues-values.yaml", UES_VALUES)
Helm.install("ueransim #{Dir.current}/ueransim-gnb --values ./gnb-ues-values.yaml")

#TODO cluster_tools exec tshark command: tshark -ni any -Y nas_5gs.mm.type_id -T json > test.file
#TODO look for connection text (sanity check)
ClusterTools.exec("tshark -ni any -Y nas_5gs.mm.type_id -T json > test.log")
#TODO cluster_tools exec tshark command: tshark -ni any -Y nas_5gs.mm.type_id -T json > test.file
#todo use sane defaults (i.e. search for amf, upf, etc in pod names) if no 5gcore labels are present
#todo get 5gcore pods
all_pods = KubectlClient::Get.pods_by_nodes(KubectlClient::Get.schedulable_nodes_list)
pods = KubectlClient::Get.pods_by_label(all_pods, "app.kubernetes.io/core", "5gcore")
fivegpod = pods[0]?
Log.info { "fivegpod: #{fivegpod}" }
if fivegpod && fivegpod.dig?("metadata", "name")
Log.info { "fivegpod #{fivegpod} metadata name: #{fivegpod.dig?("metadata", "name")}" }
fivegcore_pod_name = fivegpod.dig("metadata", "name")
Log.info { "fivegcore_pod_name: #{fivegcore_pod_name}" }
# nodes = KubectlClient::Get.nodes_by_pod(fivegcore_pod_name)
nodes = KubectlClient::Get.nodes_by_pod(fivegpod)
node = nodes.first
#todo get node for 5gcore
#todo deploy ueransim to same node as the 5gcore
#TODO look for connection text (sanity check)
# ClusterTools.exec("tshark -ni any -Y nas_5gs.mm.type_id -T json > test.log")
#todo name_id = random number
rnd = Random.new
name_id = rnd.next_int
tshark_log_name = "/tmp/tshark-#{name_id}.json"
Log.info { "tshark_log_name #{tshark_log_name}" }
ClusterTools.exec_by_node_bg("tshark -ni any -Y nas_5gs.mm.type_id -T json 2>&1 | tee #{tshark_log_name}", node)
Log.info { "after exec by node bg" }

#todo cluster_tools exec get text-<uniqueid>.file
#todo put in prereq

ueran_pods = KubectlClient::Get.pods_by_label(all_pods, "app.kubernetes.io/name", "ueransim-gnb")

Log.info { "ueran_pods: #{ueran_pods}" }
if ueran_pods[0]? == nil
Helm.fetch("openverso/ueransim-gnb --version 0.2.5 --untar")
File.write("gnb-ues-values.yaml", UES_VALUES)
Helm.install("ueransim #{Dir.current}/ueransim-gnb --values ./gnb-ues-values.yaml")
Log.info { "after helm install" }
else
Helm.delete("ueransim")
Helm.fetch("openverso/ueransim-gnb --version 0.2.5 --untar")
File.write("gnb-ues-values.yaml", UES_VALUES)
Helm.install("ueransim #{Dir.current}/ueransim-gnb --values ./gnb-ues-values.yaml")
Log.info { "after helm install" }
end

# pid_log_names << pid_log_name


# todo save off all directory/filenames into a hash
#strace: Process 94273 attached
# ---SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=1, si_uid=0} ---
# --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=0, si_uid=0} ---
#todo 2.2 wait for 30 seconds

# ClusterTools.exec_by_node("bash -c 'sleep 10 && kill #{pid} && sleep 5 && kill -9 #{pid}'", node)
sleep 10.0
Log.info { "tshark_log_name: #{tshark_log_name}" }
resp = File.read("#{tshark_log_name}")
Log.info { "tshark_log_name resp: #{resp}" }
ans : Bool
if resp
Log.info { "resp: #{resp}" }
if resp =~ /"nas_5gs.mm.type_id": "1"/
ans = true
else
Log.info { "resp: #{resp}" }
ans = false
end
else
ans = false
end
Log.info { "found nas_5gs.mm.type_id: 1: #{ans}" }

#todo delete log file
else
puts "no 5g labels"
end

#todo cluster_tools exec get text-<uniqueid>.file
#TODO parse tshark command
#TODO look for authentication text
#todo cluster_tools exec delete text-<uniqueid>.file
#todo cluster_tools exec delete text-<uniqueid>.file


# extra
Expand Down

0 comments on commit cf8e1b2

Please sign in to comment.