From 1d0b3c925d708dbf48a099f4e3961c7bd92acb20 Mon Sep 17 00:00:00 2001 From: Konstantin Yarovoy Date: Tue, 6 Aug 2024 21:46:18 +0000 Subject: [PATCH] config: introduce new config format and parser For supporting multiple deployments in one cnf and improving overall config usability and structure - new config format has to be introduced. Some existing parameters usage need to be changed for easier adaptation. This change does not replace the old config format. Refs: #2121 Signed-off-by: Konstantin Yarovoy --- embedded_files/cnf-testsuite-v2-example.yml | 23 ++ src/tasks/setup.cr | 8 + src/tasks/utils/cnf_installation/config.cr | 211 ++++++++++++++++++ .../utils/cnf_installation/install_common.cr | 8 - src/tasks/utils/cnf_manager.cr | 29 +-- src/tasks/utils/config.cr | 56 ++--- src/tasks/utils/task.cr | 7 - .../utils/types/cnf_testsuite_yml_type.cr | 6 - src/tasks/workload/compatibility.cr | 9 +- src/tasks/workload/configuration.cr | 4 +- src/tasks/workload/microservice.cr | 7 +- src/tasks/workload/observability.cr | 1 - src/tasks/workload/ran.cr | 3 +- 13 files changed, 284 insertions(+), 88 deletions(-) create mode 100644 embedded_files/cnf-testsuite-v2-example.yml create mode 100644 src/tasks/utils/cnf_installation/config.cr diff --git a/embedded_files/cnf-testsuite-v2-example.yml b/embedded_files/cnf-testsuite-v2-example.yml new file mode 100644 index 000000000..136b1c131 --- /dev/null +++ b/embedded_files/cnf-testsuite-v2-example.yml @@ -0,0 +1,23 @@ +--- +config_version: "v2" +common: + container_names: + - name: coredns + rolling_update_test_tag: "1.8.0" + rolling_downgrade_test_tag: 1.6.7 + rolling_version_change_test_tag: 1.8.0 + rollback_from_tag: 1.8.0 + +deployments: + helm_charts: + - name: coredns + helm_repo_name: stable + helm_repo_url: https://cncf.gitlab.io/stable + helm_chart_name: coredns +# helm_dirs: +# - name: envoy +# helm_directory: ../example-cnfs/envoy/envoy/ +# manifests: +# - name: nginx +# manifest_directory: ../sample_cnfs/ndn-mutable-configmap/manifests + diff --git a/src/tasks/setup.cr b/src/tasks/setup.cr index bf2b9801b..d819a7e19 100644 --- a/src/tasks/setup.cr +++ b/src/tasks/setup.cr @@ -25,3 +25,11 @@ task "configuration_file_setup" do |_, args| CNFManager::Points.create_points_yml end +task "test_config" do |_, args| + if args.named["cfg"]? + puts CNFInstall::Config.parse_cnf_config_from_file(args.named["cfg"].to_s).inspect + else + stdout_failure "cfg parameter needed" + exit 1 + end +end diff --git a/src/tasks/utils/cnf_installation/config.cr b/src/tasks/utils/cnf_installation/config.cr new file mode 100644 index 000000000..07a8357ce --- /dev/null +++ b/src/tasks/utils/cnf_installation/config.cr @@ -0,0 +1,211 @@ +require "yaml" +require "../utils.cr" + +module CNFInstall + module Config + @[YAML::Serializable::Options(emit_nulls: true)] + alias AnyDeploymentConfig = HelmChartConfig | HelmDirectoryConfig | ManifestDirectoryConfig + + class ConfigBase + include YAML::Serializable + include YAML::Serializable::Strict + end + + class Config < ConfigBase + getter config_version : String, + common : CommonParameters = CommonParameters.new(), + dynamic : DynamicParameters = DynamicParameters.new(), + deployments : DeploymentsConfig + end + + class CommonParameters < ConfigBase + getter container_names : Array(ContainerParameters) | Nil, + white_list_container_names : Array(String) | Nil, + docker_insecure_registries : Array(String) | Nil, + image_registry_fqdns : Hash(String, String) | Nil, + five_g_parameters : FiveGParameters | Nil + def initialize() + end + end + + class DynamicParameters < ConfigBase + property source_cnf_dir : String?, + destination_cnf_dir : String?, + install_method : Tuple(CNFInstall::InstallMethod, String) | Nil + def initialize() + end + end + + class DeploymentsConfig < ConfigBase + getter helm_charts : Array(HelmChartConfig) = [] of HelmChartConfig, + helm_dirs : Array(HelmDirectoryConfig) = [] of HelmDirectoryConfig, + manifests : Array(ManifestDirectoryConfig) = [] of ManifestDirectoryConfig + # deployments.current and all related functionality should be removed with new installation process. + @@current : AnyDeploymentConfig | Nil + + def after_initialize + if @helm_charts.empty? && @helm_dirs.empty? && @manifests.empty? + raise YAML::Error.new("At least one deployment should be configured") + end + + # To be removed with new installation process. + if @helm_charts.size + @helm_dirs.size + @manifests.size > 1 + raise YAML::Error.new("Multiple deployments are not supported yet") + end + + deployment_names = Set(String).new + {@helm_charts, @helm_dirs, @manifests}.each do |deployment_array| + if deployment_array && !deployment_array.empty? + + # To be removed with new installation process. + @@current = deployment_array[0] + + deployment_array.each do |deployment| + if deployment_names.includes?(deployment.name) + raise YAML::Error.new("Deployment names should be unique: \"#{deployment.name}\"") + else + deployment_names.add(deployment.name) + end + end + end + end + end + + def get_deployment_param(param : Symbol) : String + current = @@current.not_nil! + result = case current + when HelmChartConfig + case param + when :name then current.name + when :helm_repo_name then current.helm_repo_name + when :helm_repo_url then current.helm_repo_url + when :helm_chart_name then current.helm_chart_name + when :helm_values then current.helm_values + when :namespace then current.namespace + else raise ArgumentError.new("Unknown symbol for #{current.class}: #{param}") + end + when HelmDirectoryConfig + case param + when :name then current.name + when :helm_directory then current.helm_directory + when :helm_values then current.helm_values + when :namespace then current.namespace + else raise ArgumentError.new("Unknown symbol for #{current.class}: #{param}") + end + when ManifestDirectoryConfig + case param + when :name then current.name + when :manifest_directory then current.manifest_directory + else raise ArgumentError.new("Unknown symbol for #{current.class}: #{param}") + end + end + result || "" + end + + def get_install_method + case @@current + when HelmChartConfig + {CNFInstall::InstallMethod::HelmChart, get_deployment_param(:helm_chart_name)} + when HelmDirectoryConfig + full_helm_directory = Path[CNF_DIR + "/" + get_deployment_param(:name) + "/" + CNFManager.sandbox_helm_directory(get_deployment_param(:helm_directory))].expand.to_s + {CNFInstall::InstallMethod::HelmDirectory, full_helm_directory} + when ManifestDirectoryConfig + full_manifest_directory = Path[CNF_DIR + "/" + get_deployment_param(:name) + "/" + CNFManager.sandbox_helm_directory(get_deployment_param(:manifest_directory))].expand.to_s + {CNFInstall::InstallMethod::ManifestDirectory, full_manifest_directory} + else + raise YAML::Error.new("At least one deployment should be configured") + end + end + end + + class DeploymentConfig < ConfigBase + getter name : String + end + + class HelmDeploymentConfig < DeploymentConfig + getter helm_values : String?, + namespace : String? + end + + class HelmChartConfig < HelmDeploymentConfig + getter helm_repo_name : String, + helm_repo_url : String, + helm_chart_name : String + end + + class HelmDirectoryConfig < HelmDeploymentConfig + getter helm_directory : String + end + + class ManifestDirectoryConfig < DeploymentConfig + getter manifest_directory : String + end + + class FiveGParameters < ConfigBase + getter amf_label : String?, + smf_label : String?, + upf_label : String?, + ric_label : String?, + amf_service_name : String?, + mmc : String?, + mnc : String?, + sst : String?, + sd : String?, + tac : String?, + protectionScheme : String?, + publicKey : String?, + publicKeyId : String?, + routingIndicator : String?, + enabled : String?, + count : String?, + initialMSISDN : String?, + key : String?, + op : String?, + opType : String?, + type : String?, + apn : String?, + emergency : String? + end + + class ContainerParameters < ConfigBase + getter name : String?, + rolling_update_test_tag : String?, + rolling_downgrade_test_tag : String?, + rolling_version_change_test_tag : String?, + rollback_from_tag : String? + end + + def self.parse_cnf_config_from_file(path_to_config) + yaml_content = File.read(path_to_config) + config_dir = CNFManager.ensure_cnf_testsuite_dir(path_to_config) + begin + parse_cnf_config_from_yaml(yaml_content, config_dir) + rescue exception + stdout_failure "Error during parsing CNF config on #{path_to_config}" + stdout_failure exception.message + stdout_failure "Please check your config according to the config template." + exit 1 + end + end + + def self.parse_cnf_config_from_yaml(yaml_content, config_dir) + config = Config.from_yaml(yaml_content) + + unless config.dynamic.source_cnf_dir + config.dynamic.source_cnf_dir = config_dir + end + + unless config.dynamic.install_method + config.dynamic.install_method = config.deployments.get_install_method + end + + unless config.dynamic.destination_cnf_dir + deployment_name = config.deployments.get_deployment_param(:name) + current_dir = FileUtils.pwd + config.dynamic.destination_cnf_dir = "#{current_dir}/#{CNF_DIR}/#{deployment_name}" + end + + config + end + end +end diff --git a/src/tasks/utils/cnf_installation/install_common.cr b/src/tasks/utils/cnf_installation/install_common.cr index 351a0734a..41a51248a 100644 --- a/src/tasks/utils/cnf_installation/install_common.cr +++ b/src/tasks/utils/cnf_installation/install_common.cr @@ -29,14 +29,6 @@ module CNFInstall end end - def self.cnf_installation_method(config : CNFManager::Config) : Tuple(CNFInstall::InstallMethod, String) - Log.info { "cnf_installation_method config : CNFManager::Config" } - Log.info { "config_cnf_config: #{config.cnf_config}" } - yml_file_path = config.cnf_config[:source_cnf_file] - parsed_config_file = CNFManager.parsed_config_file(yml_file_path) - cnf_installation_method(parsed_config_file) - end - #Determine, for cnf, whether a helm chart, helm directory, or manifest directory is being used for installation def self.cnf_installation_method(config : Totem::Config) : Tuple(CNFInstall::InstallMethod, String) Log.info { "cnf_installation_method" } diff --git a/src/tasks/utils/cnf_manager.cr b/src/tasks/utils/cnf_manager.cr index 41b5f993d..698aa9c5c 100644 --- a/src/tasks/utils/cnf_manager.cr +++ b/src/tasks/utils/cnf_manager.cr @@ -74,17 +74,16 @@ module CNFManager def self.cnf_resource_ymls(args, config) Log.info { "cnf_resource_ymls" } destination_cnf_dir = config.cnf_config[:destination_cnf_dir] - yml_file_path = config.cnf_config[:yml_file_path] helm_directory = sandbox_helm_directory(config.cnf_config[:helm_directory]) manifest_directory = config.cnf_config[:manifest_directory] release_name = config.cnf_config[:release_name] - helm_chart_path = config.cnf_config[:helm_chart_path] - manifest_file_path = config.cnf_config[:manifest_file_path] + helm_chart_path = Config.get_helm_chart_path(config) + manifest_file_path = Config.get_manifest_file_path(config) helm_values = config.cnf_config[:helm_values] test_passed = true deployment_namespace = CNFManager.get_deployment_namespace(config) - install_method = CNFInstall.cnf_installation_method(config) + install_method = config.cnf_config[:install_method] Log.debug { "install_method: #{install_method}" } template_ymls = [] of YAML::Any case install_method[0] @@ -134,7 +133,7 @@ module CNFManager # ``` def self.get_deployment_namespace(config) - install_method = CNFInstall.cnf_installation_method(config) + install_method = config.cnf_config[:install_method] case install_method[0] when CNFInstall::InstallMethod::HelmChart, Helm::InstallMethod::HelmDirectory if !config.cnf_config[:helm_install_namespace].empty? @@ -503,10 +502,8 @@ module CNFManager release_name = config.cnf_config[:release_name] install_method = config.cnf_config[:install_method] helm_directory = config.cnf_config[:helm_directory] - source_helm_directory = config.cnf_config[:source_helm_directory] manifest_directory = config.cnf_config[:manifest_directory] - helm_chart_path = config.cnf_config[:helm_chart_path] - destination_cnf_dir = CNFManager.cnf_destination_dir(config_file) + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] # Create a CNF sandbox dir FileUtils.mkdir_p(destination_cnf_dir) @@ -535,7 +532,7 @@ module CNFManager end when CNFInstall::InstallMethod::HelmDirectory Log.info { "preparing helm_directory sandbox" } - source_directory = config_source_dir(config_file) + "/" + source_helm_directory.split(" ")[0] # todo support parameters separately + source_directory = config_source_dir(config_file) + "/" + helm_directory.split(" ")[0] # todo support parameters separately src_path = Path[source_directory].expand.to_s Log.info { "cp -a #{src_path} #{destination_cnf_dir}" } @@ -567,7 +564,7 @@ module CNFManager config_file = config.cnf_config[:source_cnf_dir] helm_directory = config.cnf_config[:helm_directory] helm_chart = config.cnf_config[:helm_chart] - destination_cnf_dir = CNFManager.cnf_destination_dir(config_file) + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] #TODO don't think we need to make this here FileUtils.mkdir_p("#{destination_cnf_dir}/#{helm_directory}") @@ -648,11 +645,9 @@ module CNFManager Log.info { "helm_repo_name: #{helm_repo_name}" } Log.info { "helm_repo_url: #{helm_repo_url}" } - - helm_chart_path = config.cnf_config[:helm_chart_path] Log.debug { "helm_directory: #{helm_directory}" } - destination_cnf_dir = CNFManager.cnf_destination_dir(config_file) + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] Log.for("verbose").info { "destination_cnf_dir: #{destination_cnf_dir}" } if verbose Log.debug { "mkdir_p destination_cnf_dir: #{destination_cnf_dir}" } @@ -900,7 +895,6 @@ module CNFManager helm_repository = config.cnf_config[:helm_repository] helm_repo_name = "#{helm_repository && helm_repository["name"]}" helm_repo_url = "#{helm_repository && helm_repository["repo_url"]}" - helm_chart_path = config.cnf_config[:helm_chart_path] helm_chart = config.cnf_config[:helm_chart] destination_cnf_dir = config.cnf_config[:destination_cnf_dir] deployment_namespace = CNFManager.get_deployment_namespace(config) @@ -950,11 +944,12 @@ module CNFManager def self.sample_cleanup(config_file, force=false, installed_from_manifest=false, verbose=true) Log.info { "sample_cleanup" } Log.info { "sample_cleanup installed_from_manifest: #{installed_from_manifest}" } - destination_cnf_dir = CNFManager.cnf_destination_dir(config_file) - Log.info { "destination_cnf_dir: #{destination_cnf_dir}" } config = parsed_config_file(ensure_cnf_testsuite_yml_path(config_file)) parsed_config = CNFManager::Config.parse_config_yml(CNFManager.ensure_cnf_testsuite_yml_path(config_file)) Log.for("verbose").info { "cleanup config: #{config.inspect}" } if verbose + destination_cnf_dir = parsed_config.cnf_config[:destination_cnf_dir] + Log.info { "destination_cnf_dir: #{destination_cnf_dir}" } + config_maps_dir = "#{destination_cnf_dir}/config_maps" if Dir.exists?(config_maps_dir) @@ -978,7 +973,7 @@ module CNFManager Log.for("sample_cleanup").info { "Destination dir #{destination_cnf_dir} exists" } end - install_method = CNFInstall.cnf_installation_method(parsed_config) + install_method = parsed_config.cnf_config[:install_method] Log.for("sample_cleanup:install_method").info { install_method } case install_method[0] when CNFInstall::InstallMethod::HelmChart, CNFInstall::InstallMethod::HelmDirectory diff --git a/src/tasks/utils/config.cr b/src/tasks/utils/config.cr index 52e8132bf..5faa5a2a2 100644 --- a/src/tasks/utils/config.cr +++ b/src/tasks/utils/config.cr @@ -14,22 +14,15 @@ module CNFManager end #when addeding to this you must add to task.cr's CNFManager::Config.new( property cnf_config : NamedTuple(destination_cnf_dir: String, - source_cnf_file: String, source_cnf_dir: String, - yml_file_path: String, install_method: Tuple(CNFInstall::InstallMethod, String), manifest_directory: String, helm_directory: String, - source_helm_directory: String, - helm_chart_path: String, - manifest_file_path: String, release_name: String, - service_name: String, helm_repository: NamedTuple(name: String, repo_url: String) | Nil, helm_chart: String, helm_values: String, helm_install_namespace: String, - rolling_update_tag: String, container_names: Array(Hash(String, String )) | Nil, white_list_container_names: Array(String), docker_insecure_registries: Array(String) | Nil, @@ -74,9 +67,7 @@ module CNFManager destination_cnf_dir = CNFManager.cnf_destination_dir(yml_file) - yml_file_path = CNFManager.ensure_cnf_testsuite_dir(config_yml_path) - source_cnf_file = yml_file - source_cnf_dir = yml_file_path + source_cnf_dir = CNFManager.ensure_cnf_testsuite_dir(config_yml_path) manifest_directory = optional_key_as_string(config, "manifest_directory") if config["helm_repository"]? helm_repository = config["helm_repository"].as_h @@ -89,9 +80,7 @@ module CNFManager helm_chart = optional_key_as_string(config, "helm_chart") helm_values = optional_key_as_string(config, "helm_values") release_name = optional_key_as_string(config, "release_name") - service_name = optional_key_as_string(config, "service_name") helm_directory = optional_key_as_string(config, "helm_directory") - source_helm_directory = optional_key_as_string(config, "helm_directory") helm_install_namespace = optional_key_as_string(config, "helm_install_namespace") if config["enabled"]? core_enabled = config["enabled"].as_bool.to_s @@ -132,21 +121,7 @@ module CNFManager smf = optional_key_as_string(config, "smf_label") upf = optional_key_as_string(config, "upf_label") ric = optional_key_as_string(config, "ric_label") - if helm_directory.empty? - working_chart_directory = "exported_chart" - Log.info { "USING EXPORTED CHART PATH" } - else - # todo separate parameters from helm directory - # TODO Fix bug with helm_directory for arguments, it creates an invalid path - # # we don't handle arguments anymore - # helm_directory = source_helm_directory.split("/")[0] + " " + source_helm_directory.split(" ")[1..-1].join(" ") - # helm_directory = optional_key_as_string(config, "helm_directory") - working_chart_directory = helm_directory - Log.info { "NOT USING EXPORTED CHART PATH" } - end - helm_chart_path = destination_cnf_dir + "/" + CNFManager.sandbox_helm_directory(working_chart_directory) - helm_chart_path = Path[helm_chart_path].expand.to_s - manifest_file_path = destination_cnf_dir + "/" + "temp_template.yml" + white_list_container_names = optional_key_as_string(config, "allowlist_helm_chart_container_names") if config["allowlist_helm_chart_container_names"]? white_list_container_names = config["allowlist_helm_chart_container_names"].as_a.map do |c| @@ -190,22 +165,15 @@ module CNFManager # if you change this, change instantiation in task.cr/single_task_runner as well new({ destination_cnf_dir: destination_cnf_dir, - source_cnf_file: source_cnf_file, source_cnf_dir: source_cnf_dir, - yml_file_path: yml_file_path, install_method: install_method, manifest_directory: manifest_directory, helm_directory: helm_directory, - source_helm_directory: source_helm_directory, - helm_chart_path: helm_chart_path, - manifest_file_path: manifest_file_path, release_name: release_name, - service_name: service_name, helm_repository: {name: helm_repo_name, repo_url: helm_repo_url}, helm_chart: helm_chart, helm_values: helm_values, helm_install_namespace: helm_install_namespace, - rolling_update_tag: "", container_names: container_names, white_list_container_names: white_list_container_names, docker_insecure_registries: docker_insecure_registries, @@ -217,6 +185,26 @@ module CNFManager image_registry_fqdns: image_registry_fqdns,}) end + + def self.get_helm_chart_path(config) + helm_directory = config.cnf_config[:helm_directory] + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] + if helm_directory.empty? + working_chart_directory = "exported_chart" + Log.info { "USING EXPORTED CHART PATH" } + else + working_chart_directory = helm_directory + Log.info { "NOT USING EXPORTED CHART PATH" } + end + helm_chart_path = destination_cnf_dir + "/" + CNFManager.sandbox_helm_directory(working_chart_directory) + helm_chart_path = Path[helm_chart_path].expand.to_s + end + + def self.get_manifest_file_path(config) + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] + manifest_file_path = destination_cnf_dir + "/" + "temp_template.yml" + end + def self.install_method_by_config_file(config_file) : CNFInstall::InstallMethod LOGGING.info "install_data_by_config_file" config = CNFManager.parsed_config_file(config_file) diff --git a/src/tasks/utils/task.cr b/src/tasks/utils/task.cr index b24473736..2f07e9a9a 100644 --- a/src/tasks/utils/task.cr +++ b/src/tasks/utils/task.cr @@ -65,22 +65,15 @@ module CNFManager config = CNFManager::Config.parse_config_yml(args.named["cnf-config"].as(String)) else config = CNFManager::Config.new({ destination_cnf_dir: "", - source_cnf_file: "", source_cnf_dir: "", - yml_file_path: "", install_method: {CNFInstall::InstallMethod::HelmChart, ""}, manifest_directory: "", helm_directory: "", - source_helm_directory: "", - helm_chart_path: "", - manifest_file_path: "", release_name: "", - service_name: "", helm_repository: {name: "", repo_url: ""}, helm_chart: "", helm_values: "", helm_install_namespace: "", - rolling_update_tag: "", container_names: [{"name" => "", "rolling_update_test_tag" => ""}], white_list_container_names: [""], docker_insecure_registries: [] of String, diff --git a/src/tasks/utils/types/cnf_testsuite_yml_type.cr b/src/tasks/utils/types/cnf_testsuite_yml_type.cr index 437d57eb1..0d01c9afa 100644 --- a/src/tasks/utils/types/cnf_testsuite_yml_type.cr +++ b/src/tasks/utils/types/cnf_testsuite_yml_type.cr @@ -22,8 +22,6 @@ class CnfTestSuiteYmlType property helm_directory : String? - property service_name : String? - property release_name : String? property helm_repository : HelmRepositoryType? @@ -32,10 +30,6 @@ class CnfTestSuiteYmlType property helm_install_namespace : String? - # property rolling_update_test_tag : String? - # property rolling_downgrade_test_tag : String? - # property rolling_version_change_test_tag : String? - property rollback_from_tag : String? property allowlist_helm_chart_container_names : Array(String)? diff --git a/src/tasks/workload/compatibility.cr b/src/tasks/workload/compatibility.cr index d65e4c752..e4a46b2cb 100644 --- a/src/tasks/workload/compatibility.cr +++ b/src/tasks/workload/compatibility.cr @@ -393,7 +393,6 @@ task "helm_deploy" do |t, args| helm_chart = config.cnf_config[:helm_chart] helm_directory = config.cnf_config[:helm_directory] release_name = config.cnf_config[:release_name] - yml_file_path = config.cnf_config[:yml_file_path] configmap = KubectlClient::Get.configmap("cnf-testsuite-#{release_name}-startup-information") #TODO check if json is empty helm_used = configmap["data"].as_h["helm_used"].as_s @@ -451,7 +450,7 @@ task "helm_chart_published", ["helm_local_install"] do |t, args| end task "helm_chart_valid", ["helm_local_install"] do |t, args| - CNFManager::Task.task_runner(args, task: t) do |args| + CNFManager::Task.task_runner(args, task: t) do |args, config| if check_verbose(args) Log.for("verbose").debug { "helm_chart_valid args.raw: #{args.raw}" } Log.for("verbose").debug { "helm_chart_valid args.named: #{args.named}" } @@ -459,9 +458,7 @@ task "helm_chart_valid", ["helm_local_install"] do |t, args| response = String::Builder.new - config = CNFManager.parsed_config_file(CNFManager.ensure_cnf_testsuite_yml_path(args.named["cnf-config"].as(String))) - # helm_directory = config.get("helm_directory").as_s - helm_directory = optional_key_as_string(config, "helm_directory") + helm_directory = config.cnf_config[:helm_directory] if helm_directory.empty? working_chart_directory = "exported_chart" else @@ -478,7 +475,7 @@ task "helm_chart_valid", ["helm_local_install"] do |t, args| Log.for(t.name).debug { "current dir: #{current_dir}" } helm = Helm::BinarySingleton.helm - destination_cnf_dir = CNFManager.cnf_destination_dir(CNFManager.ensure_cnf_testsuite_dir(args.named["cnf-config"].as(String))) + destination_cnf_dir = config.cnf_config[:destination_cnf_dir] helm_lint_cmd = "#{helm} lint #{destination_cnf_dir}/#{working_chart_directory}" helm_lint_status = Process.run( diff --git a/src/tasks/workload/configuration.cr b/src/tasks/workload/configuration.cr index ca3e4073a..d8e4b9040 100644 --- a/src/tasks/workload/configuration.cr +++ b/src/tasks/workload/configuration.cr @@ -107,7 +107,7 @@ task "ip_addresses" do |t, args| cdir = FileUtils.pwd() response = String::Builder.new helm_directory = config.cnf_config[:helm_directory] - helm_chart_path = config.cnf_config[:helm_chart_path] + helm_chart_path = CNFManager::Config.get_helm_chart_path(config) Log.info { "Path: #{helm_chart_path}" } if File.directory?(helm_chart_path) # Switch to the helm chart directory @@ -191,7 +191,6 @@ task "nodeport_not_used" do |t, args| # TODO rename task_runner to multi_cnf_task_runner CNFManager::Task.task_runner(args, task: t) do |args, config| release_name = config.cnf_config[:release_name] - service_name = config.cnf_config[:service_name] destination_cnf_dir = config.cnf_config[:destination_cnf_dir] task_response = CNFManager.workload_resource_test(args, config, check_containers: false, check_service: true) do |resource, container, initialized| Log.for(t.name).info { "nodeport_not_used resource: #{resource}" } @@ -222,7 +221,6 @@ desc "Does the CNF use HostPort" task "hostport_not_used" do |t, args| CNFManager::Task.task_runner(args, task: t) do |args, config| release_name = config.cnf_config[:release_name] - service_name = config.cnf_config[:service_name] destination_cnf_dir = config.cnf_config[:destination_cnf_dir] task_response = CNFManager.workload_resource_test(args, config, check_containers: false, check_service: true) do |resource, container, initialized| diff --git a/src/tasks/workload/microservice.cr b/src/tasks/workload/microservice.cr index a2c7a486c..a4301572f 100644 --- a/src/tasks/workload/microservice.cr +++ b/src/tasks/workload/microservice.cr @@ -104,7 +104,6 @@ end desc "Does the CNF have a reasonable startup time (< 30 seconds)?" task "reasonable_startup_time" do |t, args| CNFManager::Task.task_runner(args, task: t) do |args, config| - yml_file_path = config.cnf_config[:yml_file_path] helm_chart = config.cnf_config[:helm_chart] helm_directory = config.cnf_config[:helm_directory] release_name = config.cnf_config[:release_name] @@ -199,7 +198,7 @@ task "reasonable_image_size" do |t, args| Log.for(t.name).debug { "cnf_config: #{config}" } task_response = CNFManager.workload_resource_test(args, config) do |resource, container, initialized| - yml_file_path = config.cnf_config[:yml_file_path] + source_cnf_dir = config.cnf_config[:source_cnf_dir] if resource["kind"].downcase == "deployment" || resource["kind"].downcase == "statefulset" || @@ -245,9 +244,9 @@ task "reasonable_image_size" do |t, args| }[0..-2]}}}) puts "str_auths: #{str_auths}" end - File.write("#{yml_file_path}/config.json", str_auths) + File.write("#{source_cnf_dir}/config.json", str_auths) Dockerd.exec("mkdir -p /root/.docker/") - KubectlClient.cp("#{yml_file_path}/config.json #{TESTSUITE_NAMESPACE}/dockerd:/root/.docker/config.json") + KubectlClient.cp("#{source_cnf_dir}/config.json #{TESTSUITE_NAMESPACE}/dockerd:/root/.docker/config.json") end Log.info { "FQDN of the docker image: #{fqdn_image}" } diff --git a/src/tasks/workload/observability.cr b/src/tasks/workload/observability.cr index 51d94ce27..eac6d4f97 100644 --- a/src/tasks/workload/observability.cr +++ b/src/tasks/workload/observability.cr @@ -224,7 +224,6 @@ task "tracing" do |t, args| helm_chart = config.cnf_config[:helm_chart] helm_directory = config.cnf_config[:helm_directory] release_name = config.cnf_config[:release_name] - yml_file_path = config.cnf_config[:yml_file_path] configmap = KubectlClient::Get.configmap("cnf-testsuite-#{release_name}-startup-information") #TODO check if json is empty tracing_used = configmap["data"].as_h["tracing_used"].as_s diff --git a/src/tasks/workload/ran.cr b/src/tasks/workload/ran.cr index a52a2950e..946a99b0e 100644 --- a/src/tasks/workload/ran.cr +++ b/src/tasks/workload/ran.cr @@ -17,7 +17,6 @@ desc "Test if RAN uses the ORAN e2 interface" task "oran_e2_connection" do |t, args| CNFManager::Task.task_runner(args, task: t) do |args, config| release_name = config.cnf_config[:release_name] - destination_cnf_dir = CNFManager.cnf_destination_dir(CNFManager.ensure_cnf_testsuite_dir(args.named["cnf-config"].as(String))) if ORANMonitor.isCNFaRIC?(config.cnf_config) configmap = KubectlClient::Get.configmap("cnf-testsuite-#{release_name}-startup-information") e2_found = configmap["data"].as_h["e2_found"].as_s @@ -29,7 +28,7 @@ task "oran_e2_connection" do |t, args| CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Failed, "RAN does not connect to a RIC using the e2 standard interface") end else - CNFManager::TestcaseResult.new(CNFManager::ResultStatus::NA, "[oran_e2_connection] No ric designated in cnf_testsuite.yml for #{destination_cnf_dir}") + CNFManager::TestcaseResult.new(CNFManager::ResultStatus::NA, "[oran_e2_connection] No ric designated in cnf_testsuite.yml") end end