Skip to content

Commit

Permalink
rejig tests due to method signature/name changes
Browse files Browse the repository at this point in the history
more test updates

actually a tab:

use \t instead of actual tab (for linter)

fixup
  • Loading branch information
timothysmith0609 committed Jul 23, 2019
1 parent 2bcd7f7 commit 79d77dc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions test/helpers/fixture_deploy_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down Expand Up @@ -60,15 +60,15 @@ 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

deploy = KubernetesDeploy::DeployTask.new(
namespace: @namespace,
current_sha: sha,
context: KubeclientHelper::TEST_CONTEXT,
template_dir: dir,
template_dirs: dirs,
logger: logger,
kubectl_instance: kubectl_instance,
bindings: bindings,
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/unit/kubernetes-deploy/deploy_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/unit/kubernetes-deploy/kubeclient_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions test/unit/kubernetes-deploy/options_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
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

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
end

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
Expand All @@ -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|
Expand Down

0 comments on commit 79d77dc

Please sign in to comment.