Skip to content

Commit 42301ec

Browse files
committed
Add a test
1 parent aa0a065 commit 42301ec

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: networkpolicies.stable.example.io
5+
labels:
6+
app: krane
7+
spec:
8+
group: stable.example.io
9+
version: v1
10+
names:
11+
kind: NetworkPolicy
12+
plural: networkpolicies
13+
scope: Namespaced
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: "stable.example.io/v1"
3+
kind: NetworkPolicy
4+
metadata:
5+
name: cr-np
6+
---
7+
apiVersion: networking.k8s.io/v1
8+
kind: NetworkPolicy
9+
metadata:
10+
name: built-in-policy
11+
spec:
12+
ingress:
13+
- ports:
14+
- port: 80
15+
protocol: TCP
16+
podSelector:
17+
matchLabels:
18+
app: nginx-ingress-controller
19+
policyTypes:
20+
- Ingress

test/integration-serial/serial_deploy_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,27 @@ def test_cr_merging
236236
assert_deploy_success(result)
237237
end
238238

239+
def test_custom_resources_predeployed_correctly_with_non_unique_kinds
240+
results = deploy_global_fixtures("crd", subset: %w(network_policy.yml)) do |f|
241+
# revert name muning since we're explicitly testing conflicting names
242+
np = f["network_policy.yml"]["CustomResourceDefinition"].first
243+
np["metadata"]["name"] = "networkpolicies.stable.example.io"
244+
np["spec"]["names"] = { "kind" => "NetworkPolicy", "plural" => "networkpolicies" }
245+
end
246+
assert_deploy_success(results)
247+
reset_logger
248+
249+
result = deploy_fixtures("crd", subset: %w(network_policy_cr.yml))
250+
assert_deploy_success(result)
251+
assert_logs_match_all([
252+
/Phase 3: Predeploying priority resources/,
253+
/Successfully deployed in \d.\ds: NetworkPolicy\/built-in-policy, NetworkPolicy\/cr-np/,
254+
/Phase 4: Deploying all resources/,
255+
/NetworkPolicy\/built-in-policy Created/,
256+
/NetworkPolicy\/cr-np Exists/,
257+
], in_order: true)
258+
end
259+
239260
def test_custom_resources_predeployed
240261
assert_deploy_success(deploy_global_fixtures("crd", subset: %w(mail.yml things.yml widgets.yml)) do |f|
241262
mail = f.dig("mail.yml", "CustomResourceDefinition").first

0 commit comments

Comments
 (0)