Skip to content

Commit

Permalink
Add an extra test around namespaced CRs
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Nov 6, 2019
1 parent f57de6d commit 62c4cdc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions test/fixtures/crd/mail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: mail.stable.example.io
labels:
app: krane
spec:
group: stable.example.io
names:
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/fixture_deploy_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def deploy_global_fixtures(set, subset: nil, **args)
fixtures = load_fixtures(set, subset)
raise "Cannot deploy empty template set" if fixtures.empty?
args[:selector] = ["test=#{@namespace}", args[:selector]].compact.join(",")
destroyable = namespace_gloabls(fixtures)
destroyable = namespace_globals(fixtures)

yield fixtures if block_given?

Expand Down Expand Up @@ -180,7 +180,7 @@ def build_kubectl(log_failure_by_default: true, timeout: '5s')
log_failure_by_default: log_failure_by_default, default_timeout: timeout)
end

def namespace_gloabls(fixtures)
def namespace_globals(fixtures)
fixtures.each_with_object({}) do |(_, kinds_map), hash|
kinds_map.each do |kind, resources|
hash[kind] ||= []
Expand Down
18 changes: 18 additions & 0 deletions test/integration-serial/serial_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,24 @@ def test_global_deploy_black_box_timeout
storage_v1_kubeclient.delete_storage_class("testing-storage-class")
end

def test_global_deploy_validation_catches_namespaced_cr
assert_deploy_success(global_deploy_dirs_without_profiling('test/fixtures/crd/mail.yml', selector: "app=krane"))
assert_deploy_failure(global_deploy_dirs_without_profiling('test/fixtures/crd/mail_cr.yml', selector: "app=krane"))
assert_logs_match_all([
"Phase 1: Initializing deploy",
"Using resource selector app=krane",
"All required parameters and files are present",
"Discovering resources:",
"- Mail/my-first-mail",
"Result: FAILURE",
"Deploying namespaced resource is not allowed from this command.",
"Namespaced resources:",
"my-first-mail (Mail)",
])
ensure
wait_for_all_crd_deletion
end

private

def wait_for_all_crd_deletion
Expand Down

0 comments on commit 62c4cdc

Please sign in to comment.