|
| 1 | +suite: HiveMQ Platform - Testing configuration tests |
| 2 | +templates: |
| 3 | + - tests/test-mqtt-cli.yml |
| 4 | +release: |
| 5 | + name: test-platform |
| 6 | +tests: |
| 7 | + |
| 8 | + - it: should render test pod by default when MQTT service is exposed |
| 9 | + asserts: |
| 10 | + - hasDocuments: |
| 11 | + count: 1 |
| 12 | + - containsDocument: |
| 13 | + apiVersion: v1 |
| 14 | + kind: Pod |
| 15 | + - matchRegex: |
| 16 | + path: metadata.name |
| 17 | + pattern: ^hivemq-test-connection-test-platform-hivemq-test-platform-mqtt-\d+$ |
| 18 | + - equal: |
| 19 | + path: metadata.annotations["helm.sh/hook"] |
| 20 | + value: test |
| 21 | + - equal: |
| 22 | + path: spec.containers[0].name |
| 23 | + value: hivemq-mqtt-cli |
| 24 | + - matchRegex: |
| 25 | + path: spec.containers[0].image |
| 26 | + pattern: ^hivemq/mqtt-cli:\d+\.\d+\.\d+$ |
| 27 | + - equal: |
| 28 | + path: spec.restartPolicy |
| 29 | + value: Never |
| 30 | + |
| 31 | + - it: should not render test pod when testing.enabled is false |
| 32 | + set: |
| 33 | + testing: |
| 34 | + enabled: false |
| 35 | + asserts: |
| 36 | + - hasDocuments: |
| 37 | + count: 0 |
| 38 | + |
| 39 | + - it: should not render test pod when no MQTT service is exposed |
| 40 | + set: |
| 41 | + services: |
| 42 | + - type: control-center |
| 43 | + exposed: true |
| 44 | + port: 8080 |
| 45 | + containerPort: 8080 |
| 46 | + asserts: |
| 47 | + - hasDocuments: |
| 48 | + count: 0 |
| 49 | + |
| 50 | + - it: should not render test pod when MQTT service is not exposed |
| 51 | + set: |
| 52 | + services: |
| 53 | + - type: mqtt |
| 54 | + exposed: false |
| 55 | + port: 1883 |
| 56 | + containerPort: 1883 |
| 57 | + asserts: |
| 58 | + - hasDocuments: |
| 59 | + count: 0 |
| 60 | + |
| 61 | + - it: should render test pod with custom MQTT service name |
| 62 | + set: |
| 63 | + services: |
| 64 | + - type: mqtt |
| 65 | + name: custom-mqtt-service |
| 66 | + exposed: true |
| 67 | + port: 1883 |
| 68 | + containerPort: 1883 |
| 69 | + asserts: |
| 70 | + - hasDocuments: |
| 71 | + count: 1 |
| 72 | + - equal: |
| 73 | + path: metadata.name |
| 74 | + value: hivemq-test-connection-test-platform-custom-mqtt-service |
| 75 | + - contains: |
| 76 | + path: spec.containers[0].args |
| 77 | + content: -h |
| 78 | + - contains: |
| 79 | + path: spec.containers[0].args |
| 80 | + content: custom-mqtt-service |
| 81 | + |
| 82 | + - it: should render test pod when testing.enabled is explicitly true |
| 83 | + set: |
| 84 | + testing: |
| 85 | + enabled: true |
| 86 | + asserts: |
| 87 | + - hasDocuments: |
| 88 | + count: 1 |
| 89 | + - containsDocument: |
| 90 | + apiVersion: v1 |
| 91 | + kind: Pod |
| 92 | + |
| 93 | + - it: should fail schema validation when testing.enabled is not a boolean |
| 94 | + set: |
| 95 | + testing: |
| 96 | + enabled: "true" |
| 97 | + asserts: |
| 98 | + - failedTemplate: {} |
| 99 | + |
| 100 | + - it: should allow testing object with only enabled property |
| 101 | + set: |
| 102 | + testing: |
| 103 | + enabled: true |
| 104 | + asserts: |
| 105 | + - hasDocuments: |
| 106 | + count: 1 |
| 107 | + |
| 108 | + - it: should render test pod with default MQTT service when multiple services exist |
| 109 | + set: |
| 110 | + services: |
| 111 | + - type: control-center |
| 112 | + exposed: true |
| 113 | + port: 8080 |
| 114 | + containerPort: 8080 |
| 115 | + - type: mqtt |
| 116 | + exposed: true |
| 117 | + port: 1883 |
| 118 | + containerPort: 1883 |
| 119 | + - type: metrics |
| 120 | + exposed: true |
| 121 | + port: 9399 |
| 122 | + containerPort: 9399 |
| 123 | + asserts: |
| 124 | + - hasDocuments: |
| 125 | + count: 1 |
| 126 | + - equal: |
| 127 | + path: kind |
| 128 | + value: Pod |
| 129 | + |
| 130 | + - it: should use correct test command arguments |
| 131 | + asserts: |
| 132 | + - equal: |
| 133 | + path: spec.containers[0].args[0] |
| 134 | + value: test |
| 135 | + - equal: |
| 136 | + path: spec.containers[0].args[1] |
| 137 | + value: -h |
| 138 | + - exists: |
| 139 | + path: spec.containers[0].args[2] |
| 140 | + |
| 141 | + - it: should have helm test hook annotation |
| 142 | + asserts: |
| 143 | + - equal: |
| 144 | + path: metadata.annotations["helm.sh/hook"] |
| 145 | + value: test |
| 146 | + |
| 147 | + - it: should use Never restart policy for test pod |
| 148 | + asserts: |
| 149 | + - equal: |
| 150 | + path: spec.restartPolicy |
| 151 | + value: Never |
| 152 | + |
| 153 | + - it: should render one test pod per exposed MQTT service with unique names |
| 154 | + set: |
| 155 | + services: |
| 156 | + - type: mqtt |
| 157 | + name: mqtt-primary |
| 158 | + exposed: true |
| 159 | + port: 1883 |
| 160 | + containerPort: 1883 |
| 161 | + - type: mqtt |
| 162 | + name: mqtt-secondary |
| 163 | + exposed: true |
| 164 | + port: 1884 |
| 165 | + containerPort: 1884 |
| 166 | + asserts: |
| 167 | + - hasDocuments: |
| 168 | + count: 2 |
| 169 | + |
| 170 | + - it: should render test pods with correct name for multiple MQTT services exposed |
| 171 | + set: |
| 172 | + services: |
| 173 | + - type: mqtt |
| 174 | + name: mqtt-primary |
| 175 | + exposed: true |
| 176 | + port: 1883 |
| 177 | + containerPort: 1883 |
| 178 | + - type: mqtt |
| 179 | + name: mqtt-secondary |
| 180 | + exposed: true |
| 181 | + port: 1884 |
| 182 | + containerPort: 1884 |
| 183 | + asserts: |
| 184 | + - equal: |
| 185 | + path: metadata.name |
| 186 | + value: hivemq-test-connection-test-platform-mqtt-primary |
| 187 | + documentIndex: 0 |
| 188 | + - equal: |
| 189 | + path: spec.containers[0].args[2] |
| 190 | + value: mqtt-primary |
| 191 | + documentIndex: 0 |
| 192 | + - equal: |
| 193 | + path: metadata.name |
| 194 | + value: hivemq-test-connection-test-platform-mqtt-secondary |
| 195 | + documentIndex: 1 |
| 196 | + - equal: |
| 197 | + path: spec.containers[0].args[2] |
| 198 | + value: mqtt-secondary |
| 199 | + documentIndex: 1 |
0 commit comments