Skip to content

Commit

Permalink
Fix up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Jul 20, 2018
1 parent 49b57f6 commit 38381fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module KubernetesDeploy
class CustomResourceDefinition < KubernetesResource
TIMEOUT = 2.minutes
TIMEOUT = 5.minutes
GLOBAL = true

def deploy_succeeded?
Expand Down
4 changes: 3 additions & 1 deletion test/helpers/fixture_sets/hello_cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def assert_job_up
end

def assert_crd_up
assert_crd_present("mails.stable.example.io")
crd_name = "mails.stable.example.io"
assert_crd_present(crd_name)
apiextensions_v1beta1_kubeclient.delete_custom_resource_definition(crd_name)
end
end
end
18 changes: 12 additions & 6 deletions test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
require 'test_helper'

class KubernetesDeployTest < KubernetesDeploy::IntegrationTest
def teardown
crds = apiextensions_v1beta1_kubeclient.get_custom_resource_definitions.map(&:names)
crds.each { |crd| apiextensions_v1beta1_kubeclient.delete_custom_resource_definition(crd) }
end

def test_full_hello_cloud_set_deploy_succeeds
assert_deploy_success(deploy_fixtures("hello-cloud"))
hello_cloud = FixtureSetAssertions::HelloCloud.new(@namespace)
Expand All @@ -12,7 +17,7 @@ def test_full_hello_cloud_set_deploy_succeeds
%r{Deploying Pod/unmanaged-pod-[-\w]+ \(timeout: 60s\)}, # annotation timeout override
"Hello from the command runner!", # unmanaged pod logs
"Result: SUCCESS",
"Successfully deployed 19 resources"
"Successfully deployed 20 resources"
], in_order: true)

assert_logs_match_all([
Expand All @@ -24,7 +29,7 @@ def test_full_hello_cloud_set_deploy_succeeds
%r{Service/redis-external\s+Doesn't require any endpoint},
"- Job/hello-job (timeout: 600s)",
%r{Job/hello-job\s+(Succeeded|Started)},
%r{CustomResourceDefinition/mails.stable.example.io\s+Names Accepted},
%r{CustomResourceDefinition/mails.stable.example.io\s+Names accepted},
])

# Verify that success section isn't duplicated for predeployed resources
Expand Down Expand Up @@ -73,7 +78,7 @@ def test_pruning_works
'ingress(\.extensions)? "web"',
'daemonset(\.extensions)? "ds-app"',
'statefulset(\.apps)? "stateful-busybox"',
'job "hello-job"',
'job(\.batch)? "hello-job"',
] # not necessarily listed in this order
expected_msgs = [/Pruned 9 resources and successfully deployed 6 resources/]
expected_pruned.map do |resource|
Expand Down Expand Up @@ -1062,12 +1067,13 @@ def test_crd_can_be_successful
"Detected non-namespaced resource which will never be pruned:",
" - CustomResourceDefinition/mails.stable.example.io",
"Phase 2: Checking initial resource statuses",
"Deploying CustomResourceDefinition/mails.stable.example.io (timeout: 120s)",
%r{CustomResourceDefinition/mails.stable.example.io\s+Names Accepted}
"Deploying CustomResourceDefinition/mails.stable.example.io (timeout: 300s)",
%r{CustomResourceDefinition/mails.stable.example.io\s+Names accepted}
])
end

def test_crd_can_fail
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["crd.yml"]))
result = deploy_fixtures("hello-cloud", subset: ["crd.yml"]) do |f|
crd = f.dig("crd.yml", "CustomResourceDefinition").first
names = crd.dig("spec", "names")
Expand All @@ -1076,7 +1082,7 @@ def test_crd_can_fail
end
assert_deploy_failure(result)
assert_logs_match_all([
"Deploying CustomResourceDefinition/mis-matched.stable.example.io (timeout: 120s)",
"Deploying CustomResourceDefinition/mis-matched.stable.example.io (timeout: 300s)",
"CustomResourceDefinition/mis-matched.stable.example.io: FAILED",
'Final status: ListKindConflict ("MailList" is already in use)'
])
Expand Down

0 comments on commit 38381fd

Please sign in to comment.