Skip to content

Commit

Permalink
Guard
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmb committed Oct 19, 2017
1 parent 7b5e052 commit 2d78c4b
Showing 1 changed file with 44 additions and 36 deletions.
80 changes: 44 additions & 36 deletions test/integration/resource_discovery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def cleanup(*resources)
end
end

def has_resource?(resource)
_, _, st = kubectl.run("get", resource)
def has_resource?(res)
_, _, st = kubectl.run("get", res)
st.success?
end

Expand All @@ -36,55 +36,63 @@ def has_crd_support?

def test_prunable_tpr
skip unless has_tpr_support?
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["tpr.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["tpr.yml"]))
# Deploy any other resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["configmap-data.yml",]))
begin
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["tpr.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["tpr.yml"]))
# Deploy any other resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["configmap-data.yml",]))

assert_logs_match("The following resources were pruned: gizmo \"my-first-gizmo\"")
refute_logs_match("Don't know how to monitor resources of type Gizmo. " \
"Assuming Gizmo/my-first-gizmo deployed successfully")
ensure
cleanup('thirdpartyresources')
assert_logs_match("The following resources were pruned: gizmo \"my-first-gizmo\"")
refute_logs_match("Don't know how to monitor resources of type Gizmo. " \
"Assuming Gizmo/my-first-gizmo deployed successfully")
ensure
cleanup('thirdpartyresources')
end
end

def test_non_prunable_crd_no_predeploy
skip unless has_crd_support?
assert_deploy_success(deploy_fixtures("resource-discovery/definitions",
subset: ["crd_non_prunable_no_predeploy.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))
# Deploy any other non-priority (predeployable) resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["daemon_set.yml",]))
begin
assert_deploy_success(deploy_fixtures("resource-discovery/definitions",
subset: ["crd_non_prunable_no_predeploy.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))
# Deploy any other non-priority (predeployable) resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["daemon_set.yml",]))

refute_logs_match("The following resources were pruned: widget \"my-first-widget\"")
refute_logs_match("Don't know how to monitor resources of type Widget. " \
"Assuming Widget/my-first-widget deployed successfully")
refute_logs_match("Predeploying priority resources")
ensure
cleanup('customresourcedefinitions')
refute_logs_match("The following resources were pruned: widget \"my-first-widget\"")
refute_logs_match("Don't know how to monitor resources of type Widget. " \
"Assuming Widget/my-first-widget deployed successfully")
refute_logs_match("Predeploying priority resources")
ensure
cleanup('customresourcedefinitions')
end
end

def test_prunable_crd
skip unless has_crd_support?
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["crd.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))
# Deploy any other resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["configmap-data.yml",]))
begin
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["crd.yml"]))
assert_deploy_success(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))
# Deploy any other resource to trigger pruning
assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["configmap-data.yml",]))

assert_logs_match("The following resources were pruned: widget \"my-first-widget\"")
refute_logs_match("Don't know how to monitor resources of type Widget. " \
"Assuming Widget/my-first-widget deployed successfully")
ensure
cleanup('customresourcedefinitions')
assert_logs_match("The following resources were pruned: widget \"my-first-widget\"")
refute_logs_match("Don't know how to monitor resources of type Widget. " \
"Assuming Widget/my-first-widget deployed successfully")
ensure
cleanup('customresourcedefinitions')
end
end

def test_invalid_timeout_format
skip unless has_crd_support?
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["crd_invalid_timespec.yml"]))
assert_deploy_failure(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))
begin
assert_deploy_success(deploy_fixtures("resource-discovery/definitions", subset: ["crd_invalid_timespec.yml"]))
assert_deploy_failure(deploy_fixtures("resource-discovery/instances", subset: ["crd.yml"]))

assert_logs_match("Resource widget specified invalid timeout value 'foobar', must use iso8601 duration.")
ensure
cleanup('customresourcedefinitions')
assert_logs_match("Resource widget specified invalid timeout value 'foobar', must use iso8601 duration.")
ensure
cleanup('customresourcedefinitions')
end
end
end

0 comments on commit 2d78c4b

Please sign in to comment.