From 6a4754cad6a263ac362c3a144c37c5185a80dc23 Mon Sep 17 00:00:00 2001 From: Joel Studler Date: Thu, 27 Feb 2025 08:49:58 +0100 Subject: [PATCH 1/2] First attempt to make e2e tests idempotent by changing preserveInNetbox to false (doesn't work just yet) --- .../chainsaw-test.yaml | 32 +++++++++++++++ .../chainsaw-test.yaml | 40 ++++++++++++++++--- .../netbox_v1_prefixclaim_2.yaml | 2 +- .../chainsaw-test.yaml | 32 +++++++++++++++ .../chainsaw-test.yaml | 40 ++++++++++++++++--- .../netbox_v1_prefixclaim_2.yaml | 2 +- .../chainsaw-test.yaml | 32 +++++++++++++++ 7 files changed, 166 insertions(+), 14 deletions(-) diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml index 52876cb0..303bc5d8 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml @@ -45,3 +45,35 @@ spec: tenant: MY_TENANT_2 customFields: netboxOperatorRestorationHash: e3ea4eebe4ab49cc7c91dc9f96007965ede43338 + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-parentprefixselector-sample + spec: + preserveInNetbox: false + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-parentprefixselector-sample + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-parentprefixselector-sample + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-parentprefixselector-sample + spec: + (preserveInNetbox == true): false diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml index 0301a1e6..25d06199 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml @@ -56,7 +56,6 @@ spec: description: some description parentPrefix: 2.0.3.0/24 prefixLength: /28 - preserveInNetbox: true site: MY_SITE tenant: MY_TENANT status: @@ -73,7 +72,6 @@ spec: comments: your comments description: some description prefix: 2.0.3.16/28 - preserveInNetbox: true site: MY_SITE tenant: MY_TENANT customFields: @@ -87,10 +85,10 @@ spec: kind: PrefixClaim name: prefixclaim-ipv4-apply-delete-apply-restored-1 - name: Apply prefix claim CR 1 for the second time and check after deletion and reapply of CR 1 - description: + description: try: - apply: - file: netbox_v1_prefixclaim_1.yaml + file: netbox_v1_prefixclaim_1.yaml - assert: resource: apiVersion: netbox.dev/v1 @@ -135,7 +133,6 @@ spec: description: some description parentPrefix: 2.0.3.0/24 prefixLength: /28 - preserveInNetbox: true site: MY_SITE tenant: MY_TENANT status: @@ -152,8 +149,39 @@ spec: comments: your comments description: some description prefix: 2.0.3.16/28 - preserveInNetbox: true site: MY_SITE tenant: MY_TENANT customFields: netboxOperatorRestorationHash: 0265a1eec7bba9748f9542476fe3dccb46cceb5a + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-apply-delete-apply-restored-1 + spec: + (preserveInNetbox == true): false diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml index 3471d5ab..ba07167e 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml @@ -10,6 +10,6 @@ spec: site: "MY_SITE" description: "some description" comments: "your comments" - preserveInNetbox: true + preserveInNetbox: false parentPrefix: "2.0.3.0/24" prefixLength: "/28" diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml index 354e3dcd..e01a6811 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml @@ -41,3 +41,35 @@ spec: tenant: MY_TENANT customFields: netboxOperatorRestorationHash: f773cf04f71c017931716e125a8520d70f4c7f83 + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-apply + spec: + preserveInNetbox: false + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-apply + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-apply + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-apply + spec: + (preserveInNetbox == true): false diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml index be5473d1..d605cce1 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml @@ -66,7 +66,6 @@ spec: site: MY_SITE tenant: MY_TENANT prefixLength: /28 - preserveInNetbox: true site: MY_SITE_2 tenant: MY_TENANT_2 status: @@ -83,7 +82,6 @@ spec: comments: your comments description: some description prefix: 3.0.4.16/28 - preserveInNetbox: true site: MY_SITE_2 tenant: MY_TENANT_2 customFields: @@ -97,10 +95,10 @@ spec: kind: PrefixClaim name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 - name: Apply prefix claim CR 1 for the second time and check after deletion and reapply of CR 1 - description: + description: try: - apply: - file: netbox_v1_prefixclaim_1.yaml + file: netbox_v1_prefixclaim_1.yaml - assert: resource: apiVersion: netbox.dev/v1 @@ -155,7 +153,6 @@ spec: site: MY_SITE tenant: MY_TENANT prefixLength: /28 - preserveInNetbox: true site: MY_SITE_2 tenant: MY_TENANT_2 status: @@ -172,8 +169,39 @@ spec: comments: your comments description: some description prefix: 3.0.4.16/28 - preserveInNetbox: true site: MY_SITE_2 tenant: MY_TENANT_2 customFields: netboxOperatorRestorationHash: 2fecef786a6c3590bc219c540d2a142f9e2ad907 + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 + spec: + (preserveInNetbox == true): false diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml index 4310742d..f22d4bd1 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/netbox_v1_prefixclaim_2.yaml @@ -10,7 +10,7 @@ spec: site: "MY_SITE_2" description: "some description" comments: "your comments" - preserveInNetbox: true + preserveInNetbox: false prefixLength: "/28" parentPrefixSelector: # The keys and values are case-sensitive tenant: "MY_TENANT" # Use the `name` value instead of the `slug` value diff --git a/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml index ca29d522..2f73c297 100644 --- a/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml @@ -47,3 +47,35 @@ spec: tenant: MY_TENANT_2 customFields: netboxOperatorRestorationHash: 92913dac42ca35232682325c7f04639959d3a3cf + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv6-parentprefixselector-apply-succeed + spec: + preserveInNetbox: false + - patch: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv6-parentprefixselector-apply-succeed + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: PrefixClaim + metadata: + name: prefixclaim-ipv6-parentprefixselector-apply-succeed + spec: + preserveInNetbox: false + - assert: + resource: + apiVersion: netbox.dev/v1 + kind: Prefix + metadata: + name: prefixclaim-ipv6-parentprefixselector-apply-succeed + spec: + (preserveInNetbox == true): false From 4a187858192d31f947edb29b61806a21e9ffc6a9 Mon Sep 17 00:00:00 2001 From: Joel Studler Date: Thu, 27 Feb 2025 09:03:25 +0100 Subject: [PATCH 2/2] Only patch claim --- .../chainsaw-test.yaml | 8 -------- .../chainsaw-test.yaml | 8 -------- .../chainsaw-test.yaml | 8 -------- .../chainsaw-test.yaml | 8 -------- .../chainsaw-test.yaml | 8 -------- 5 files changed, 40 deletions(-) diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml index 303bc5d8..45827906 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithIPv4ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml @@ -53,14 +53,6 @@ spec: name: prefixclaim-ipv4-parentprefixselector-sample spec: preserveInNetbox: false - - patch: - resource: - apiVersion: netbox.dev/v1 - kind: Prefix - metadata: - name: prefixclaim-ipv4-parentprefixselector-sample - spec: - preserveInNetbox: false - assert: resource: apiVersion: netbox.dev/v1 diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml index 25d06199..474a71f0 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml @@ -161,14 +161,6 @@ spec: name: prefixclaim-ipv4-apply-delete-apply-restored-1 spec: preserveInNetbox: false - - patch: - resource: - apiVersion: netbox.dev/v1 - kind: Prefix - metadata: - name: prefixclaim-ipv4-apply-delete-apply-restored-1 - spec: - preserveInNetbox: false - assert: resource: apiVersion: netbox.dev/v1 diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml index e01a6811..44734393 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed/chainsaw-test.yaml @@ -49,14 +49,6 @@ spec: name: prefixclaim-ipv4-apply spec: preserveInNetbox: false - - patch: - resource: - apiVersion: netbox.dev/v1 - kind: Prefix - metadata: - name: prefixclaim-ipv4-apply - spec: - preserveInNetbox: false - assert: resource: apiVersion: netbox.dev/v1 diff --git a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml index d605cce1..362ce637 100644 --- a/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv4/GivenPrefixClaimWithPreserveWhenParentPrefixSelectorAppliedDeletedAppliedThenRestorationSucceed/chainsaw-test.yaml @@ -181,14 +181,6 @@ spec: name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 spec: preserveInNetbox: false - - patch: - resource: - apiVersion: netbox.dev/v1 - kind: Prefix - metadata: - name: prefixclaim-ipv4-parentprefixselector-apply-delete-apply-restored-1 - spec: - preserveInNetbox: false - assert: resource: apiVersion: netbox.dev/v1 diff --git a/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml b/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml index 2f73c297..a109137e 100644 --- a/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml +++ b/tests/e2e/Prefix/IPv6/GivenPrefixClaimWithIPv6ParentPrefixSelectorWhenAppliedThenSucceed/chainsaw-test.yaml @@ -55,14 +55,6 @@ spec: name: prefixclaim-ipv6-parentprefixselector-apply-succeed spec: preserveInNetbox: false - - patch: - resource: - apiVersion: netbox.dev/v1 - kind: Prefix - metadata: - name: prefixclaim-ipv6-parentprefixselector-apply-succeed - spec: - preserveInNetbox: false - assert: resource: apiVersion: netbox.dev/v1