|
| 1 | +--- |
| 2 | +suite: Ingress |
| 3 | +templates: |
| 4 | + # primary template files |
| 5 | + - ingress.yaml |
| 6 | + |
| 7 | +tests: |
| 8 | + - it: Ingress not present if disabled |
| 9 | + set: |
| 10 | + ingress: |
| 11 | + enabled: false |
| 12 | + asserts: |
| 13 | + - hasDocuments: |
| 14 | + count: 0 |
| 15 | + |
| 16 | + - it: Ingress is present when enabled without hosts (older k8s) |
| 17 | + capabilities: &cap_older |
| 18 | + majorVersion: 1 |
| 19 | + minorVersion: 18 |
| 20 | + apiVersions: |
| 21 | + - networking.k8s.io/v1beta1 |
| 22 | + set: |
| 23 | + ingress: |
| 24 | + enabled: true |
| 25 | + hosts: [] |
| 26 | + tls: [] |
| 27 | + st2web: |
| 28 | + service: |
| 29 | + hostname: &st2web_hostname hostname.domain.tld |
| 30 | + release: |
| 31 | + name: st2ha |
| 32 | + asserts: |
| 33 | + - hasDocuments: |
| 34 | + count: 1 |
| 35 | + - equal: |
| 36 | + path: kind |
| 37 | + value: Ingress |
| 38 | + # no ingress.hosts, so only st2web.hostname |
| 39 | + - equal: &st2web_rules_host |
| 40 | + path: spec.rules[0].host |
| 41 | + value: *st2web_hostname |
| 42 | + - contains: |
| 43 | + path: spec.rules[0].http.paths |
| 44 | + count: 1 |
| 45 | + content: |
| 46 | + path: "/" |
| 47 | + backend: |
| 48 | + serviceName: st2ha-st2web |
| 49 | + servicePort: 80 |
| 50 | + - isNull: |
| 51 | + path: spec.rules[0].http.paths[0].pathType |
| 52 | + |
| 53 | + - it: Ingress is present when enabled without hosts (newer k8s) |
| 54 | + capabilities: &cap_newer |
| 55 | + majorVersion: 1 |
| 56 | + minorVersion: 19 |
| 57 | + apiVersions: |
| 58 | + - networking.k8s.io/v1 # introduced in 1.19, stable in 1.22 |
| 59 | + - networking.k8s.io/v1beta1 |
| 60 | + set: |
| 61 | + ingress: |
| 62 | + enabled: true |
| 63 | + hosts: [] |
| 64 | + tls: [] |
| 65 | + st2web: |
| 66 | + service: |
| 67 | + hostname: *st2web_hostname |
| 68 | + release: |
| 69 | + name: st2ha |
| 70 | + asserts: |
| 71 | + - hasDocuments: |
| 72 | + count: 1 |
| 73 | + - equal: |
| 74 | + path: kind |
| 75 | + value: Ingress |
| 76 | + # no ingress.hosts, so only st2web.hostname |
| 77 | + - equal: *st2web_rules_host |
| 78 | + - contains: |
| 79 | + path: spec.rules[0].http.paths |
| 80 | + count: 1 |
| 81 | + content: |
| 82 | + path: "/" |
| 83 | + pathType: Prefix |
| 84 | + backend: |
| 85 | + service: |
| 86 | + name: st2ha-st2web |
| 87 | + port: |
| 88 | + number: 80 |
| 89 | + |
| 90 | + - it: Ingress is present when enabled with hosts (older k8s) |
| 91 | + capabilities: *cap_older |
| 92 | + set: |
| 93 | + ingress: |
| 94 | + enabled: true |
| 95 | + hosts: &hosts |
| 96 | + - host: *st2web_hostname |
| 97 | + paths: |
| 98 | + - serviceName: st2ha-st2web |
| 99 | + servicePort: 80 |
| 100 | + - path: /fancy-sensor |
| 101 | + serviceName: fancy-sensor |
| 102 | + servicePort: 8080 |
| 103 | + tls: [] |
| 104 | + st2web: |
| 105 | + service: |
| 106 | + hostname: *st2web_hostname |
| 107 | + release: |
| 108 | + name: st2ha |
| 109 | + asserts: |
| 110 | + - hasDocuments: |
| 111 | + count: 1 |
| 112 | + - equal: |
| 113 | + path: kind |
| 114 | + value: Ingress |
| 115 | + # no ingress.hosts, so only st2web.hostname |
| 116 | + - equal: *st2web_rules_host |
| 117 | + - equal: &host_path_is_root_glob |
| 118 | + path: spec.rules[0].http.paths[0].path |
| 119 | + value: "/*" |
| 120 | + - isNull: |
| 121 | + path: spec.rules[0].http.paths[0].pathType |
| 122 | + - equal: |
| 123 | + path: spec.rules[0].http.paths[0].backend |
| 124 | + value: |
| 125 | + serviceName: st2ha-st2web |
| 126 | + servicePort: 80 |
| 127 | + |
| 128 | + - equal: |
| 129 | + path: spec.rules[0].http.paths[1].path |
| 130 | + value: "/fancy-sensor" |
| 131 | + - isNull: |
| 132 | + path: spec.rules[0].http.paths[1].pathType |
| 133 | + - equal: |
| 134 | + path: spec.rules[0].http.paths[1].backend |
| 135 | + value: |
| 136 | + serviceName: fancy-sensor |
| 137 | + servicePort: 8080 |
| 138 | + |
| 139 | + - it: Ingress is present when enabled with hosts (newer k8s) |
| 140 | + capabilities: *cap_newer |
| 141 | + set: |
| 142 | + ingress: |
| 143 | + enabled: true |
| 144 | + hosts: *hosts |
| 145 | + tls: [] |
| 146 | + st2web: |
| 147 | + service: |
| 148 | + hostname: *st2web_hostname |
| 149 | + release: |
| 150 | + name: st2ha |
| 151 | + asserts: |
| 152 | + - hasDocuments: |
| 153 | + count: 1 |
| 154 | + - equal: |
| 155 | + path: kind |
| 156 | + value: Ingress |
| 157 | + # no ingress.hosts, so only st2web.hostname |
| 158 | + - equal: *st2web_rules_host |
| 159 | + - equal: *host_path_is_root_glob |
| 160 | + - equal: |
| 161 | + path: spec.rules[0].http.paths[0].pathType |
| 162 | + value: Prefix |
| 163 | + - equal: |
| 164 | + path: spec.rules[0].http.paths[0].backend |
| 165 | + value: |
| 166 | + service: |
| 167 | + name: st2ha-st2web |
| 168 | + port: |
| 169 | + number: 80 |
| 170 | + |
| 171 | + - equal: |
| 172 | + path: spec.rules[0].http.paths[1].path |
| 173 | + value: "/fancy-sensor" |
| 174 | + - equal: |
| 175 | + path: spec.rules[0].http.paths[1].pathType |
| 176 | + value: Prefix |
| 177 | + - equal: |
| 178 | + path: spec.rules[0].http.paths[1].backend |
| 179 | + value: |
| 180 | + service: |
| 181 | + name: fancy-sensor |
| 182 | + port: |
| 183 | + number: 8080 |
0 commit comments