Skip to content

Commit 9dbed5f

Browse files
committed
Add E2E tests for resync scheduling behavior
Add E2E tests covering resync period, resync jitter, resync disabled, and terminal error behavior during resync. Add integration tests for handling unmanaged resources during resync to verify that imported resources without resyncPeriod skip requeue scheduling.
1 parent 37beaca commit 9dbed5f

27 files changed

Lines changed: 1129 additions & 0 deletions

internal/controllers/generic/reconciler/resource_actions_unmanaged_test.go

Lines changed: 569 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Verify the network is available and lastSyncTime has been set after the
3+
# initial reconciliation, even with resyncPeriod=0 (disabled periodic resync).
4+
apiVersion: kuttl.dev/v1beta1
5+
kind: TestAssert
6+
resourceRefs:
7+
- apiVersion: openstack.k-orc.cloud/v1alpha1
8+
kind: Network
9+
name: network-resync-disabled
10+
ref: network
11+
assertAll:
12+
- celExpr: "has(network.status.lastSyncTime)"
13+
- celExpr: "network.status.lastSyncTime != ''"
14+
---
15+
apiVersion: openstack.k-orc.cloud/v1alpha1
16+
kind: Network
17+
metadata:
18+
name: network-resync-disabled
19+
status:
20+
resource:
21+
name: network-resync-disabled
22+
adminStateUp: true
23+
external: false
24+
portSecurityEnabled: true
25+
shared: false
26+
status: ACTIVE
27+
conditions:
28+
- type: Available
29+
status: "True"
30+
reason: Success
31+
- type: Progressing
32+
status: "False"
33+
reason: Success
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: openstack.k-orc.cloud/v1alpha1
2+
kind: Network
3+
metadata:
4+
name: network-resync-disabled
5+
spec:
6+
cloudCredentialsRef:
7+
cloudName: openstack
8+
secretName: openstack-clouds
9+
managementPolicy: managed
10+
# resyncPeriod of 0s explicitly disables periodic resync. The controller
11+
# should reconcile the resource once on creation and then not reschedule.
12+
resyncPeriod: 0s
13+
resource: {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
5+
namespaced: true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# Verify the network is still available and stable after the waiting period.
3+
# No changes should have occurred since no resync was triggered.
4+
apiVersion: openstack.k-orc.cloud/v1alpha1
5+
kind: Network
6+
metadata:
7+
name: network-resync-disabled
8+
status:
9+
conditions:
10+
- type: Available
11+
status: "True"
12+
reason: Success
13+
- type: Progressing
14+
status: "False"
15+
reason: Success
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
# Record the current lastSyncTime, sleep for 15 seconds (longer than even a
4+
# fast resync period would trigger), then verify that lastSyncTime has NOT
5+
# changed. This confirms that resyncPeriod=0 prevents periodic re-reconciliation.
6+
commands:
7+
- script: |
8+
INITIAL=$(kubectl get network.openstack.k-orc.cloud network-resync-disabled \
9+
-n ${NAMESPACE} \
10+
-o jsonpath='{.status.lastSyncTime}')
11+
# Sleep longer than any reasonable minimum resync period to confirm no resync fires.
12+
sleep 15
13+
CURRENT=$(kubectl get network.openstack.k-orc.cloud network-resync-disabled \
14+
-n ${NAMESPACE} \
15+
-o jsonpath='{.status.lastSyncTime}')
16+
# Fail if lastSyncTime changed (would indicate an unexpected resync).
17+
[ "${INITIAL}" = "${CURRENT}" ]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Network with resyncPeriod=0 disables periodic resync
2+
3+
## Step 00
4+
5+
Create a network with `resyncPeriod: 0s` (disabled periodic resync) and verify that:
6+
- The network becomes available with correct conditions.
7+
- `lastSyncTime` is set in the status after the first successful reconciliation.
8+
(Even with resync disabled, the controller always records the initial sync time.)
9+
10+
## Step 01
11+
12+
Wait for a period longer than the minimum resync period and verify that
13+
`lastSyncTime` has NOT changed. When `resyncPeriod` is 0 (disabled), the
14+
controller does not schedule additional reconciliations, so `lastSyncTime`
15+
should remain stable after the initial reconciliation.
16+
17+
## Reference
18+
19+
Tests that setting `resyncPeriod: 0s` (or omitting resyncPeriod) disables
20+
periodic resync scheduling. The resource is still reconciled on events (spec
21+
changes, dependency updates) but not on a timer.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
# Verify all three networks are available and each has lastSyncTime set after
3+
# the initial successful reconciliation.
4+
apiVersion: kuttl.dev/v1beta1
5+
kind: TestAssert
6+
resourceRefs:
7+
- apiVersion: openstack.k-orc.cloud/v1alpha1
8+
kind: Network
9+
name: network-resync-jitter-1
10+
ref: network1
11+
- apiVersion: openstack.k-orc.cloud/v1alpha1
12+
kind: Network
13+
name: network-resync-jitter-2
14+
ref: network2
15+
- apiVersion: openstack.k-orc.cloud/v1alpha1
16+
kind: Network
17+
name: network-resync-jitter-3
18+
ref: network3
19+
assertAll:
20+
- celExpr: "has(network1.status.lastSyncTime) && network1.status.lastSyncTime != ''"
21+
- celExpr: "has(network2.status.lastSyncTime) && network2.status.lastSyncTime != ''"
22+
- celExpr: "has(network3.status.lastSyncTime) && network3.status.lastSyncTime != ''"
23+
---
24+
apiVersion: openstack.k-orc.cloud/v1alpha1
25+
kind: Network
26+
metadata:
27+
name: network-resync-jitter-1
28+
status:
29+
conditions:
30+
- type: Available
31+
status: "True"
32+
reason: Success
33+
- type: Progressing
34+
status: "False"
35+
reason: Success
36+
---
37+
apiVersion: openstack.k-orc.cloud/v1alpha1
38+
kind: Network
39+
metadata:
40+
name: network-resync-jitter-2
41+
status:
42+
conditions:
43+
- type: Available
44+
status: "True"
45+
reason: Success
46+
- type: Progressing
47+
status: "False"
48+
reason: Success
49+
---
50+
apiVersion: openstack.k-orc.cloud/v1alpha1
51+
kind: Network
52+
metadata:
53+
name: network-resync-jitter-3
54+
status:
55+
conditions:
56+
- type: Available
57+
status: "True"
58+
reason: Success
59+
- type: Progressing
60+
status: "False"
61+
reason: Success
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# Create three networks all sharing the same resyncPeriod to exercise jitter
3+
# scheduling. Each network will be independently scheduled with [0%, +20%] jitter,
4+
# preventing them from all reconciling simultaneously.
5+
apiVersion: openstack.k-orc.cloud/v1alpha1
6+
kind: Network
7+
metadata:
8+
name: network-resync-jitter-1
9+
spec:
10+
cloudCredentialsRef:
11+
cloudName: openstack
12+
secretName: openstack-clouds
13+
managementPolicy: managed
14+
resyncPeriod: 10s
15+
resource: {}
16+
---
17+
apiVersion: openstack.k-orc.cloud/v1alpha1
18+
kind: Network
19+
metadata:
20+
name: network-resync-jitter-2
21+
spec:
22+
cloudCredentialsRef:
23+
cloudName: openstack
24+
secretName: openstack-clouds
25+
managementPolicy: managed
26+
resyncPeriod: 10s
27+
resource: {}
28+
---
29+
apiVersion: openstack.k-orc.cloud/v1alpha1
30+
kind: Network
31+
metadata:
32+
name: network-resync-jitter-3
33+
spec:
34+
cloudCredentialsRef:
35+
cloudName: openstack
36+
secretName: openstack-clouds
37+
managementPolicy: managed
38+
resyncPeriod: 10s
39+
resource: {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
5+
namespaced: true

0 commit comments

Comments
 (0)