|
| 1 | +--- |
| 2 | +apiVersion: chainsaw.kyverno.io/v1alpha1 |
| 3 | +kind: Test |
| 4 | +metadata: |
| 5 | + name: iprangeclaim-ipv4-prefixexhausted |
| 6 | + annotations: |
| 7 | + description: Tests if creation fails in case the ParentPrefix is exhausted |
| 8 | +spec: |
| 9 | + steps: |
| 10 | + - name: Apply CR 1 |
| 11 | + try: |
| 12 | + - apply: |
| 13 | + file: netbox_v1_iprangeclaim_1.yaml |
| 14 | + - name: Check CR 1 spec and status |
| 15 | + try: |
| 16 | + - assert: |
| 17 | + resource: |
| 18 | + apiVersion: netbox.dev/v1 |
| 19 | + kind: IpRangeClaim |
| 20 | + metadata: |
| 21 | + name: iprangeclaim-ipv4-prefixexhausted-1 |
| 22 | + spec: |
| 23 | + comments: your comments |
| 24 | + description: some description |
| 25 | + parentPrefix: 3.2.1.0/26 |
| 26 | + size: 30 |
| 27 | + tenant: MY_TENANT |
| 28 | + status: |
| 29 | + (conditions[?type == 'Ready']): |
| 30 | + - status: 'True' |
| 31 | + endAddress: 3.2.1.30/32 |
| 32 | + endAddressDotDecimal: 3.2.1.30 |
| 33 | + ipAddressName: iprangeclaim-ipv4-prefixexhausted-1 |
| 34 | + ipRange: 3.2.1.1/32-3.2.1.30/32 |
| 35 | + ipRangeDotDecimal: 3.2.1.1-3.2.1.30 |
| 36 | + startAddress: 3.2.1.1/32 |
| 37 | + startAddressDotDecimal: 3.2.1.1 |
| 38 | + - assert: |
| 39 | + resource: |
| 40 | + apiVersion: netbox.dev/v1 |
| 41 | + kind: IpRange |
| 42 | + metadata: |
| 43 | + name: iprangeclaim-ipv4-prefixexhausted-1 |
| 44 | + finalizers: |
| 45 | + - iprange.netbox.dev/finalizer |
| 46 | + ownerReferences: |
| 47 | + - apiVersion: netbox.dev/v1 |
| 48 | + blockOwnerDeletion: true |
| 49 | + controller: true |
| 50 | + kind: IpRangeClaim |
| 51 | + name: iprangeclaim-ipv4-prefixexhausted-1 |
| 52 | + spec: |
| 53 | + comments: your comments |
| 54 | + description: some description |
| 55 | + startAddress: 3.2.1.1/32 |
| 56 | + tenant: MY_TENANT |
| 57 | + status: |
| 58 | + (conditions[?type == 'Ready']): |
| 59 | + - status: 'True' |
| 60 | + - name: Apply CR 2 |
| 61 | + try: |
| 62 | + - apply: |
| 63 | + file: netbox_v1_iprangeclaim_2.yaml |
| 64 | + - name: Check CR 2 spec and status |
| 65 | + try: |
| 66 | + - assert: |
| 67 | + resource: |
| 68 | + apiVersion: netbox.dev/v1 |
| 69 | + kind: IpRangeClaim |
| 70 | + metadata: |
| 71 | + name: iprangeclaim-ipv4-prefixexhausted-2 |
| 72 | + spec: |
| 73 | + comments: your comments |
| 74 | + description: some description |
| 75 | + parentPrefix: 3.2.1.0/26 |
| 76 | + size: 30 |
| 77 | + tenant: MY_TENANT |
| 78 | + status: |
| 79 | + (conditions[?type == 'Ready']): |
| 80 | + - status: 'True' |
| 81 | + endAddress: 3.2.1.60/32 |
| 82 | + endAddressDotDecimal: 3.2.1.60 |
| 83 | + ipAddressName: iprangeclaim-ipv4-prefixexhausted-2 |
| 84 | + ipRange: 3.2.1.31/32-3.2.1.60/32 |
| 85 | + ipRangeDotDecimal: 3.2.1.31-3.2.1.60 |
| 86 | + startAddress: 3.2.1.31/32 |
| 87 | + startAddressDotDecimal: 3.2.1.31 |
| 88 | + - assert: |
| 89 | + resource: |
| 90 | + apiVersion: netbox.dev/v1 |
| 91 | + kind: IpRange |
| 92 | + metadata: |
| 93 | + name: iprangeclaim-ipv4-prefixexhausted-2 |
| 94 | + finalizers: |
| 95 | + - iprange.netbox.dev/finalizer |
| 96 | + ownerReferences: |
| 97 | + - apiVersion: netbox.dev/v1 |
| 98 | + blockOwnerDeletion: true |
| 99 | + controller: true |
| 100 | + kind: IpRangeClaim |
| 101 | + name: iprangeclaim-ipv4-prefixexhausted-2 |
| 102 | + spec: |
| 103 | + comments: your comments |
| 104 | + description: some description |
| 105 | + startAddress: 3.2.1.31/32 |
| 106 | + endAddress: 3.2.1.60/32 |
| 107 | + tenant: MY_TENANT |
| 108 | + status: |
| 109 | + (conditions[?type == 'Ready']): |
| 110 | + - status: 'True' |
| 111 | + - name: Apply CR 3 |
| 112 | + try: |
| 113 | + - apply: |
| 114 | + file: netbox_v1_iprangeclaim_3.yaml |
| 115 | + - name: Check CR 3 spec and status and verify it fails |
| 116 | + try: |
| 117 | + - assert: |
| 118 | + resource: |
| 119 | + apiVersion: netbox.dev/v1 |
| 120 | + kind: IpRangeClaim |
| 121 | + metadata: |
| 122 | + name: iprangeclaim-ipv4-prefixexhausted-3 |
| 123 | + spec: |
| 124 | + comments: your comments |
| 125 | + description: some description |
| 126 | + parentPrefix: 3.2.1.0/26 |
| 127 | + size: 30 |
| 128 | + tenant: MY_TENANT |
| 129 | + status: |
| 130 | + (conditions[?type == 'IPRangeAssigned']): # TODO(jstudler): Change this to Ready, will need change in SetConditionAndCreateEvent to also update Ready condition |
| 131 | + - status: 'False' |
| 132 | + - assert: |
| 133 | + resource: |
| 134 | + apiVersion: v1 |
| 135 | + count: 1 |
| 136 | + kind: Event |
| 137 | + type: Warning |
| 138 | + reason: IPRangeCRNotCreated |
| 139 | + source: |
| 140 | + component: ip-range-claim-controller |
| 141 | + message: Failed to fetch new IP Range from NetBox. Check the logs for more information. |
| 142 | + involvedObject: |
| 143 | + apiVersion: netbox.dev/v1 |
| 144 | + kind: IpRangeClaim |
| 145 | + name: iprangeclaim-ipv4-prefixexhausted-3 |
0 commit comments