diff --git a/test/helpers/fixture_deploy_helper.rb b/test/helpers/fixture_deploy_helper.rb index 57cd7b0bd..f1181e026 100644 --- a/test/helpers/fixture_deploy_helper.rb +++ b/test/helpers/fixture_deploy_helper.rb @@ -26,7 +26,7 @@ module FixtureDeployHelper # pod = fixtures["unmanaged-pod.yml.erb"]["Pod"].first # pod["spec"]["containers"].first["image"] = "hello-world:thisImageIsBad" # end - def deploy_fixtures(set, subset: nil, **args) # extra args are passed through to deploy_dir_without_profiling + def deploy_fixtures(set, subset: nil, **args) # extra args are passed through to deploy_dirs_without_profiling fixtures = load_fixtures(set, subset) raise "Cannot deploy empty template set" if fixtures.empty? @@ -60,7 +60,7 @@ def deploy_raw_fixtures(set, wait: true, bindings: {}, subset: nil) success end - def deploy_dir_without_profiling(dir, wait: true, allow_protected_ns: false, prune: true, bindings: {}, + def deploy_dirs_without_profiling(dirs, wait: true, allow_protected_ns: false, prune: true, bindings: {}, sha: "k#{SecureRandom.hex(6)}", kubectl_instance: nil, max_watch_seconds: nil, selector: nil) kubectl_instance ||= build_kubectl @@ -68,7 +68,7 @@ def deploy_dir_without_profiling(dir, wait: true, allow_protected_ns: false, pru namespace: @namespace, current_sha: sha, context: KubeclientHelper::TEST_CONTEXT, - template_dir: dir, + template_dirs: dirs, logger: logger, kubectl_instance: kubectl_instance, bindings: bindings, @@ -85,16 +85,16 @@ def deploy_dir_without_profiling(dir, wait: true, allow_protected_ns: false, pru # Deploys all fixtures in the given directory via KubernetesDeploy::DeployTask # Exposed for direct use only when deploy_fixtures cannot be used because the template cannot be loaded pre-deploy, # for example because it contains an intentional syntax error - def deploy_dir(dir, **args) + def deploy_dir(*dirs, **args) if ENV["PROFILE"] deploy_result = nil - result = RubyProf.profile { deploy_result = deploy_dir_without_profiling(dir, args) } + result = RubyProf.profile { deploy_result = deploy_dirs_without_profiling(dirs, args) } printer = RubyProf::FlameGraphPrinter.new(result) filename = File.expand_path("../../../dev/profile", __FILE__) printer.print(File.new(filename, "a+"), {}) deploy_result else - deploy_dir_without_profiling(dir, args) + deploy_dirs_without_profiling(dirs, args) end end diff --git a/test/integration/kubernetes_deploy_test.rb b/test/integration/kubernetes_deploy_test.rb index 173e598c9..43a5ebb48 100644 --- a/test/integration/kubernetes_deploy_test.rb +++ b/test/integration/kubernetes_deploy_test.rb @@ -906,7 +906,7 @@ def test_bad_container_on_stateful_sets_fails_with_rolling_update "StatefulSet/stateful-busybox: FAILED", "app: Crashing repeatedly (exit 1). See logs for more information.", "Events (common success events excluded):", - %r{\[Pod/stateful-busybox-\d\] BackOff: Back-off restarting failed container}, + %r{\[Pod/stateful-busybox-\d\]\tBackOff: Back-off restarting failed container}, "Logs from container 'app':", "ls: /not-a-dir: No such file or directory", ], in_order: true) @@ -1095,7 +1095,7 @@ def test_jobs_can_fail "Result: FAILURE", "Job/hello-job: FAILED", "Final status: Failed", - %r{\[Job/hello-job\] DeadlineExceeded: Job was active longer than specified deadline \(\d+ events\)}, + %r{\[Job/hello-job\]\tDeadlineExceeded: Job was active longer than specified deadline \(\d+ events\)}, ]) end diff --git a/test/unit/kubernetes-deploy/deploy_task_test.rb b/test/unit/kubernetes-deploy/deploy_task_test.rb index c5b37c7c7..c6e377ae2 100644 --- a/test/unit/kubernetes-deploy/deploy_task_test.rb +++ b/test/unit/kubernetes-deploy/deploy_task_test.rb @@ -14,7 +14,7 @@ def test_initializer context: "", logger: logger, current_sha: "", - template_dir: "unknown", + template_dirs: ["unknown"], ).run assert_logs_match("Configuration invalid") assert_logs_match("Namespace must be specified") diff --git a/test/unit/kubernetes-deploy/kubeclient_builder_test.rb b/test/unit/kubernetes-deploy/kubeclient_builder_test.rb index 73afd5952..8a9f19724 100644 --- a/test/unit/kubernetes-deploy/kubeclient_builder_test.rb +++ b/test/unit/kubernetes-deploy/kubeclient_builder_test.rb @@ -62,6 +62,6 @@ def test_build_client_from_multiple_config_files context_name = "docker-for-desktop" client = kubeclient_builder.build_v1_kubeclient(context_name) assert(!client.nil?, "Expected Kubeclient is built for context " \ - "#{context_name} with success.") + "#{context_name} with success.") end end diff --git a/test/unit/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler_test.rb b/test/unit/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler_test.rb index ec8ffe2d7..484c22e10 100644 --- a/test/unit/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler_test.rb +++ b/test/unit/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler_test.rb @@ -10,7 +10,7 @@ def test_hpa_is_whitelisted_for_pruning .with("get", "CustomResourceDefinition", output: "json", attempts: 5) .returns(['{ "items": [] }', "", SystemExit.new(0)]) task = KubernetesDeploy::DeployTask.new(namespace: 'test', context: KubeclientHelper::TEST_CONTEXT, - current_sha: 'foo', template_dir: '', logger: logger) + current_sha: 'foo', template_dirs: [''], logger: logger) assert(task.prune_whitelist.one? { |whitelisted_type| whitelisted_type.include?("HorizontalPodAutoscaler") }) end diff --git a/test/unit/kubernetes-deploy/options_helper_test.rb b/test/unit/kubernetes-deploy/options_helper_test.rb index 63bf335f2..27e43bd40 100644 --- a/test/unit/kubernetes-deploy/options_helper_test.rb +++ b/test/unit/kubernetes-deploy/options_helper_test.rb @@ -5,15 +5,15 @@ class OptionsHelperTest < KubernetesDeploy::TestCase include EnvTestHelper def test_with_template_dir - KubernetesDeploy::OptionsHelper.with_validated_template_dir(fixture_path('hello-cloud')) do |template_dir| - assert_equal(fixture_path('hello-cloud'), template_dir) + KubernetesDeploy::OptionsHelper.with_validated_template_dirs([fixture_path('hello-cloud')]) do |template_dirs| + assert_equal(template_dirs, [fixture_path('hello-cloud')]) end end def test_template_dir_with_default_env_var with_env("ENVIRONMENT", "test") do - KubernetesDeploy::OptionsHelper.with_validated_template_dir(nil) do |template_dir| - assert_equal(template_dir, File.join("config", "deploy", "test")) + KubernetesDeploy::OptionsHelper.with_validated_template_dirs([]) do |template_dirs| + assert_equal(template_dirs, [File.join("config", "deploy", "test")]) end end end @@ -21,7 +21,7 @@ def test_template_dir_with_default_env_var def test_missing_template_dir_raises with_env("ENVIRONMENT", nil) do assert_raises(KubernetesDeploy::OptionsHelper::OptionsError) do - KubernetesDeploy::OptionsHelper.with_validated_template_dir(nil) do + KubernetesDeploy::OptionsHelper.with_validated_template_dirs([]) do end end end @@ -29,8 +29,8 @@ def test_missing_template_dir_raises def test_with_explicit_template_dir_with_env_var_set with_env("ENVIRONMENT", "test") do - KubernetesDeploy::OptionsHelper.with_validated_template_dir(fixture_path('hello-cloud')) do |template_dir| - assert_equal(fixture_path('hello-cloud'), template_dir) + KubernetesDeploy::OptionsHelper.with_validated_template_dirs([fixture_path('hello-cloud')]) do |template_dirs| + assert_equal(template_dirs, [fixture_path('hello-cloud')]) end end end @@ -52,9 +52,9 @@ def test_with_template_dir_from_stdin input.rewind $stdin = input - KubernetesDeploy::OptionsHelper.with_validated_template_dir('-') do |template_dir| + KubernetesDeploy::OptionsHelper.with_validated_template_dirs(['-']) do |template_dirs| split_templates = File.read( - File.join(template_dir, KubernetesDeploy::OptionsHelper::STDIN_TEMP_FILE) + File.join(template_dirs.first, KubernetesDeploy::OptionsHelper::STDIN_TEMP_FILE) ).split(/^---$/).map(&:strip).reject(&:empty?) refute(split_templates.empty?) split_templates.each do |template|