diff --git a/charts/hivemq-platform/tests/hivemq_services_test.yaml b/charts/hivemq-platform/tests/hivemq_services_test.yaml deleted file mode 100644 index 68ce4f090..000000000 --- a/charts/hivemq-platform/tests/hivemq_services_test.yaml +++ /dev/null @@ -1,2794 +0,0 @@ -suite: HiveMQ Platform services tests -templates: - - hivemq-custom-resource.yml -release: - name: test-hivemq-platform -tests: - - - it: with default values - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: cc-8080 - containerPort: 8080 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8080 - spec: - ports: - - name: cc-8080 - targetPort: cc-8080 - port: 8080 - sessionAffinity: ClientIP - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - port: 9399 - targetPort: metrics-9399 - - - it: with no mandatory `type` value for service, schema validation fails - set: - services: - - exposed: true - containerPort: 1884 - asserts: - - failedTemplate: {} - - - it: with no mandatory `exposed` value for service, schema validation fails - set: - services: - - type: mqtt - containerPort: 1884 - asserts: - - failedTemplate: {} - - - it: with no mandatory `containerPort` value for service, schema validation fails - set: - services: - - type: mqtt - exposed: true - asserts: - - failedTemplate: {} - - - it: with NodePort - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - serviceType: NodePort - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - type: NodePort - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with additional annotations - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - annotations: - annotation-key-1: annotation-value-1 - annotation-key-2: annotation-value-2 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - annotations: - annotation-key-1: annotation-value-1 - annotation-key-2: annotation-value-2 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with additional labels - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - labels: - label-key-1: label-value-1 - label-key-2: label-value-2 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - labels: - label-key-1: label-value-1 - label-key-2: label-value-2 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with additional annotations and labels - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - annotations: - annotation-key-1: annotation-value-1 - annotation-key-2: annotation-value-2 - labels: - label-key-1: label-value-1 - label-key-2: label-value-2 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - annotations: - annotation-key-1: annotation-value-1 - annotation-key-2: annotation-value-2 - labels: - label-key-1: label-value-1 - label-key-2: label-value-2 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with a MQTT service enabled - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1884 - containerPort: 1884 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with a MQTT service disabled, no MQTT service added - set: - services: - - type: mqtt - exposed: false - containerPort: 1884 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1884 - containerPort: 1884 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - - it: with a Control Center service enabled - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: cc-8081 - containerPort: 8081 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8081 - spec: - ports: - - name: cc-8081 - targetPort: cc-8081 - port: 8081 - sessionAffinity: ClientIP - - - it: with a Control Center service disabled, no Control Center service added - set: - services: - - type: control-center - exposed: false - containerPort: 8081 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: cc-8081 - containerPort: 8081 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8081 - spec: - ports: - - name: cc-8081 - targetPort: cc-8081 - port: 8081 - sessionAffinity: ClientIP - - - it: with default container ports in enabled services, then fails - set: - services: - - type: mqtt - exposed: true - containerPort: 7000 - asserts: - - failedTemplate: - errorMessage: Container port 7000 in service `mqtt` already exists as part of one of the predefined ports (7979, 8889, 7000) - - - it: with default containerPort in enabled metrics service, then no error is thrown - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with default container ports in disabled services, no error is thrown and only enabled services are created - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: false - containerPort: 7000 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - notContains: - path: spec.services - content: - - metadata: - name: hivemq-test-hivemq-platform-mqtt-7000 - spec: - ports: - - name: mqtt-7000 - targetPort: mqtt-7000 - port: 7000 - - - it: with default containerPort in disabled metrics service, then no default metrics service is created - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: metrics - exposed: false - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - notContains: - path: spec.services - content: - - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with default containerPort in disabled metrics service, then no metric container port in HiveMQ container - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: metrics - exposed: false - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with default metrics service disabled, then no service is added - set: - services: - - type: metrics - exposed: false - containerPort: 9399 - asserts: - - isNullOrEmpty: - path: spec.services - - - it: with default metrics service disabled, then no container port is added to the HiveMQ container - set: - services: - - type: metrics - exposed: false - containerPort: 9399 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0] - - isNullOrEmpty: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - - it: with custom metrics service enabled but without default metrics port, then additional default metric service is added - set: - services: - - type: metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9499 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with custom metrics service enabled but without default metrics port, then additional default metrics container port is added to the HiveMQ container - set: - services: - - type: metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with custom metrics service enabled and with default metrics port, then no additional default metric service is added - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - count: 1 - - - it: with custom metrics service enabled and with default metrics port, then no additional default metrics container port is added to the HiveMQ container - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - - it: with custom metrics service disabled but without default metrics port, then additional default metric service is added - set: - services: - - type: metrics - exposed: false - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9499 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with custom metrics service disabled but without default metrics port, then default metrics container port is added to the HiveMQ container - set: - services: - - type: metrics - exposed: false - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with statefulSet migration, then no default metrics service is created - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with statefulSet migration, then no default metrics service port is added to the HiveMQ container - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with default metrics values - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.metricsPath - - equal: - path: spec.metricsPath - value: / - - - it: with default metrics values, default metrics service is created - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with default metrics values, default metrics service port is added to the HiveMQ container - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with metrics values disabled, then metrics port 0 - set: - metrics: - enabled: false - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 0 - - exists: - path: spec.metricsPath - - equal: - path: spec.metricsPath - value: / - - - it: with metrics values disabled, then no metrics service is created - set: - metrics: - enabled: false - asserts: - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-0 - spec: - ports: - - name: metrics-0 - targetPort: metrics-0 - port: 0 - - - it: with metrics values disabled, then no metrics port is added to the HiveMQ container - set: - metrics: - enabled: false - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-0 - containerPort: 0 - - - it: with custom metrics port - set: - metrics: - port: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - - it: with custom metrics port, default metrics service is created in custom port - set: - metrics: - port: 9499 - asserts: - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9499 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - - it: with custom metrics port, default metrics port is added to the HiveMQ container - set: - metrics: - port: 9499 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - - - it: with metrics enabled but port set to 0, default metrics service is created - set: - metrics: - port: 0 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-0 - spec: - ports: - - name: metrics-0 - targetPort: metrics-0 - port: 0 - - - it: with metrics enabled but port set to 0, default metrics port is added to the HiveMQ container - set: - metrics: - port: 0 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-0 - containerPort: 0 - - - it: with custom metrics path - set: - metrics: - path: /foo - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPath - value: /foo - - - it: with metrics port within range, no schema validation fails - set: - metrics: - port: 0 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with metrics port within range, no schema validation fails - set: - metrics: - port: 65535 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with metrics port out of range, schema validation fails - set: - metrics: - port: 65536 - asserts: - - failedTemplate: {} - - - it: with custom service names - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-mqtt - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - - it: with custom metrics service name with default metrics port, no additional default metrics service is created - set: - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with custom metrics service name with default metrics port, no additional default metrics port is added to the HiveMQ container - set: - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - - it: with custom metrics service name with custom metrics port, no additional default metrics service is created - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - count: 1 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with custom metrics service name with custom metrics port, no additional default metrics port is added to the HiveMQ container - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - count: 1 - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with custom metrics service name with non matching metrics port, additional default metrics service is created - set: - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with custom metrics service name with non matching metrics port, additional default metrics port is added to the HiveMQ container - set: - services: - - type: metrics - name: my-custom-metrics - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with multiple metrics services with default metrics port, then multiple metrics services are created with no default additional metrics service - set: - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9399 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-1 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-2 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with multiple metrics services with default metrics port, then no duplicated metrics port are added to the HiveMQ container - set: - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9399 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - - it: with multiple metrics services with non matching default metrics port, then default metric port is added with no ports are added to the HiveMQ container - set: - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9499 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9399 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - count: 1 - - - it: with multiple metrics services with custom metrics port, then multiple metrics services are created with no default additional metrics service - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9499 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-1 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-2 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with multiple metrics services with custom metrics port, then no default metrics port is added to the HiveMQ container - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9499 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - count: 1 - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - - it: with multiple metrics services with matching and non matching metrics port, then multiple metrics services are created with no default additional metrics service - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9399 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-1 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - contains: - path: spec.services - content: - metadata: - name: my-custom-metrics-2 - spec: - ports: - - name: metrics-9499 - targetPort: metrics-9499 - port: 9499 - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with multiple metrics services with matching and non matching metrics port, then no default metrics port is added to the HiveMQ container - set: - metrics: - port: 9499 - services: - - type: metrics - name: my-custom-metrics-1 - exposed: true - containerPort: 9399 - - type: metrics - name: my-custom-metrics-2 - exposed: true - containerPort: 9499 - asserts: - - exists: - path: spec.metricsPort - - equal: - path: spec.metricsPort - value: 9499 - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9499 - containerPort: 9499 - - - it: with duplicated container ports and different services types, then validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: control-center - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Services with same container port (1883) but different types cannot be set - - - it: with duplicated legacy port name and different services types, validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt - - type: control-center - exposed: true - containerPort: 1884 - legacyPortName: mqtt - asserts: - - failedTemplate: - errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt - - - it: with duplicated container ports and different services types but disabled services, only enabled services are created - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: control-center - exposed: false - containerPort: 1883 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - notContains: - path: spec.services - content: - - metadata: - name: hivemq-test-hivemq-platform-cc-1883 - spec: - sessionAffinity: ClientIP - ports: - - name: cc-1883 - targetPort: cc-1883 - port: 1883 - - - it: with duplicated container ports and different services types but disabled services, then only enabled container ports added to the HiveMQ container - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: control-center - exposed: false - containerPort: 1883 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - count: 1 - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: cc-1883 - containerPort: 1883 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - count: 1 - - - it: with duplicated service container port, same type but different custom names, then services are created - set: - services: - - type: mqtt - name: my-custom-mqtt-1 - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt-2 - exposed: true - containerPort: 1883 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-mqtt-1 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - contains: - path: spec.services - content: - metadata: - name: my-custom-mqtt-2 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - - it: with duplicated service container port, same type but different custom names, then no duplicated ports added to the HiveMQ container - set: - services: - - type: mqtt - name: my-custom-mqtt-1 - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt-2 - exposed: true - containerPort: 1883 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - count: 1 - - - it: with duplicated service container port, same type but different custom names in disabled services, then only enabled services are created - set: - services: - - type: mqtt - name: my-custom-mqtt-1 - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt-2 - exposed: false - containerPort: 1883 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: my-custom-mqtt-1 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - notContains: - path: spec.services - content: - metadata: - name: my-custom-mqtt-2 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - - it: with duplicated service container port, same type but different custom names in disabled services, then no duplicated ports added to the HiveMQ container - set: - services: - - type: mqtt - name: my-custom-mqtt-1 - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt-2 - exposed: true - containerPort: 1883 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - count: 1 - - - it: with duplicated service container port and type, validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt-1883 - - - it: with duplicated legacy port names, validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt - - type: mqtt - exposed: true - containerPort: 1884 - legacyPortName: mqtt - asserts: - - failedTemplate: - errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt - - - it: with different legacy port names but duplicated ports, validation succeeds - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt1 - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt2 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with duplicated legacy port names in disabled services, then validation fails with ambiguous definition - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: false - containerPort: 1883 - legacyPortName: mqtt - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt - asserts: - - failedTemplate: - errorMessage: Ambiguous definition found for service hivemq-test-hivemq-platform-mqtt (set as exposed and not exposed) - - - it: with duplicated custom legacy service names, then validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt1 - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1884 - legacyPortName: mqtt2 - asserts: - - failedTemplate: - errorMessage: Found duplicated service name my-custom-mqtt - - - it: with statefulSet migration and `port` value set, then validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt1 - - type: mqtt - exposed: true - containerPort: 1884 - port: 1885 - legacyPortName: mqtt2 - asserts: - - failedTemplate: - errorMessage: Service type `mqtt` with container port `1884` cannot use `port` value as `migration.statefulSet` value is enabled - - - it: with statefulSet migration and `port` value set in not exposed services, then validation succeeds - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: mqtt1 - - type: mqtt - exposed: false - containerPort: 1884 - port: 1885 - legacyPortName: mqtt2 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with statefulSet migration disabled and `legacyPortName` value set, then validation fails - set: - migration.statefulSet: false - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: true - containerPort: 1884 - legacyPortName: mqtt2 - asserts: - - failedTemplate: - errorMessage: Service type `mqtt` with container port `1884` cannot use `legacyPortName` value as `migration.statefulSet` value is disabled - - - it: with statefulSet migration disabled and `legacyPortName` value set in not exposed services, then validation succeeds - set: - migration.statefulSet: false - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: false - containerPort: 1884 - legacyPortName: mqtt2 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with duplicated service container port and type in disabled services, then validation fails with ambiguous definition - set: - services: - - type: mqtt - exposed: false - containerPort: 1883 - - type: mqtt - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Ambiguous definition found for service hivemq-test-hivemq-platform-mqtt-1883 (set as exposed and not exposed) - - - it: with duplicated custom service names and container port, validation fails - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - - type: metrics - name: my-custom-mqtt - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Found duplicated service name my-custom-mqtt - - - it: with duplicated service container port and custom name but different type in disabled services, then validation fails with ambiguous definition - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - - type: metrics - name: my-custom-mqtt - exposed: false - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) - - - it: with duplicated custom service names and container port but different types in disabled services, then fails with ambiguous definition - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - - type: metrics - name: my-custom-mqtt - exposed: false - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) - - - it: with duplicated custom service names and container port and type, validation fails - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Found duplicated service name my-custom-mqtt - - - it: with duplicated service container port, custom name and type in disabled services, then validation fails with ambiguous definition - set: - services: - - type: mqtt - name: my-custom-mqtt - exposed: true - containerPort: 1883 - - type: mqtt - name: my-custom-mqtt - exposed: false - containerPort: 1883 - asserts: - - failedTemplate: - errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) - - - it: with custom service name longer than 63 characters, schema validation fails - set: - services: - - type: mqtt - name: my-so-huge-and-extremely-very-very-long-custom-mqtt-service-name - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: {} - - - it: with container service port within range, no schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 0 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with container service port within range, no schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 65535 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with container service port out of range, schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 65536 - asserts: - - failedTemplate: {} - - - it: with service port within range, no schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 0 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with service port within range, no schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 65535 - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with service port out of range, schema validation fails - set: - services: - - type: mqtt - exposed: true - containerPort: 65536 - asserts: - - failedTemplate: {} - - - it: with a non MQTT or WebSocket service enabled and PROXY protocol enabled, validation fails - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - hivemqProxyProtocol: true - asserts: - - failedTemplate: - errorMessage: Service type control-center with container port 8081 is using PROXY protocol value. PROXY protocol is only supported for MQTT and WebSocket services - - - it: with a non MQTT or WebSocket service disabled and PROXY protocol enabled, validation succeeds - set: - services: - - type: control-center - exposed: false - containerPort: 8081 - hivemqProxyProtocol: true - asserts: - - notFailedTemplate: {} - - hasDocuments: - count: 1 - - - it: with defaults, Metrics service is enabled - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with a REST API service enabled - set: - services: - - type: rest-api - exposed: true - containerPort: 8890 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: rest-8890 - containerPort: 8890 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8890 - spec: - ports: - - name: rest-8890 - targetPort: rest-8890 - port: 8890 - - - it: with a REST API service disabled, no REST API service added - set: - services: - - type: rest-api - exposed: false - containerPort: 8890 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: rest-8890 - containerPort: 8890 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8890 - spec: - ports: - - name: rest-8890 - targetPort: rest-8890 - port: 8890 - - - it: with a WebSocket service enabled - set: - services: - - type: websocket - exposed: true - containerPort: 8000 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: ws-8000 - containerPort: 8000 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8000 - spec: - ports: - - name: ws-8000 - targetPort: ws-8000 - port: 8000 - - - it: with a WebSocket service disabled, no WebSocket service added - set: - services: - - type: websocket - exposed: false - containerPort: 8000 - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - notContains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: ws-8000 - containerPort: 8000 - - exists: - path: spec.services - - notContains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8000 - spec: - ports: - - name: ws-8000 - targetPort: ws-8000 - port: 8000 - - - it: with all service types, then service names are correct - set: - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: true - containerPort: 1884 - keystoreSecretName: "keystore-secret" - keystorePasswordSecretName: "keystore-secret-password" - - type: control-center - exposed: true - containerPort: 8080 - - type: control-center - exposed: true - containerPort: 8081 - keystoreSecretName: "keystore-secret" - keystorePasswordSecretName: "keystore-secret-password" - - type: websocket - exposed: true - containerPort: 8000 - - type: websocket - exposed: true - containerPort: 8001 - keystoreSecretName: "keystore-secret" - keystorePasswordSecretName: "keystore-secret-password" - - type: rest-api - exposed: true - containerPort: 8888 - - type: metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - port: 1883 - targetPort: mqtt-1883 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 # FIXME: Expected secure MQTT service name should be `mqtts` - spec: - ports: - - name: mqtts-1884 - port: 1884 - targetPort: mqtts-1884 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8080 - spec: - ports: - - name: cc-8080 - port: 8080 - targetPort: cc-8080 - sessionAffinity: ClientIP - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8081 - spec: - ports: - - name: cc-8081 - port: 8081 - targetPort: cc-8081 - sessionAffinity: ClientIP - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8000 - spec: - ports: - - name: ws-8000 - port: 8000 - targetPort: ws-8000 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8001 - spec: - ports: - - name: ws-8001 - port: 8001 - targetPort: ws-8001 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8888 - spec: - ports: - - name: rest-8888 - port: 8888 - targetPort: rest-8888 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - port: 9399 - targetPort: metrics-9399 - - - it: with multiple service listeners defined - values: - - multiple-service-listeners.yaml - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1884 - containerPort: 1884 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: ws-8000 - containerPort: 8000 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: ws-8001 - containerPort: 8001 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8000 - spec: - ports: - - name: ws-8000 - targetPort: ws-8000 - port: 8000 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8001 - spec: - ports: - - name: ws-8001 - targetPort: ws-8001 - port: 8001 - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - port: 9399 - targetPort: metrics-9399 - - - it: with statefulSet migration and no mandatory `type` value for service, schema validation fails - set: - migration.statefulSet: true - services: - - exposed: true - legacyPortName: mqtt - containerPort: 1883 - asserts: - - failedTemplate: {} - - - it: with statefulSet migration and no mandatory `exposed` value for service, schema validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - legacyPortName: mqtt - containerPort: 1883 - asserts: - - failedTemplate: {} - - - it: with statefulSet migration and no mandatory `legacyPortName` value for service, schema validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - asserts: - - failedTemplate: {} - - - it: with statefulSet migration and no mandatory `containerPort` value for service, schema validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - legacyPortName: mqtt - asserts: - - failedTemplate: {} - - - it: with statefulSet migration and missing mandatory values in some services, schema validation fails - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - - type: mqtt - exposed: true - containerPort: 1884 - legacyPortName: legacy - asserts: - - failedTemplate: {} - - - it: with statefulSet migration, then legacy service name - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.services - - lengthEqual: - path: spec.services - count: 1 - - equal: - path: spec.services[0].metadata.name - value: hivemq-test-hivemq-platform-legacy - - - it: with statefulSet migration and custom service name, then custom service name - set: - migration.statefulSet: true - services: - - type: mqtt - name: my-custom-legacy-mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.services - - lengthEqual: - path: spec.services - count: 1 - - equal: - path: spec.services[0].metadata.name - value: my-custom-legacy-mqtt - - - it: with statefulSet migration, then legacy service ports - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.services - - lengthEqual: - path: spec.services - count: 1 - - equal: - path: spec.services[0].metadata.name - value: hivemq-test-hivemq-platform-legacy - - exists: - path: spec.services[0].spec.ports - - contains: - path: spec.services[0].spec.ports - content: - name: legacy - targetPort: legacy - port: 1883 - - - it: with statefulSet migration, then legacy container ports - set: - migration.statefulSet: true - services: - - type: mqtt - exposed: true - containerPort: 1883 - legacyPortName: legacy - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: legacy - containerPort: 1883 - - - it: with default values, then truncated service names - release: - name: this-is-more-than-32-chars-long-release-name - asserts: - - exists: - path: spec.statefulSet.spec.template.spec.containers[0].ports[0] - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: mqtt-1883 - containerPort: 1883 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: cc-8080 - containerPort: 8080 - - contains: - path: spec.statefulSet.spec.template.spec.containers[0].ports - content: - name: metrics-9399 - containerPort: 9399 - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-this-is-more-than-32-chars-long-release-na-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - contains: - path: spec.services - content: - metadata: - name: hivemq-this-is-more-than-32-chars-long-release-na-cc-8080 - spec: - ports: - - name: cc-8080 - targetPort: cc-8080 - port: 8080 - sessionAffinity: ClientIP - - contains: - path: spec.services - content: - metadata: - name: hivemq-this-is-more-than-32-chars-long-release-na-metrics-9399 - spec: - ports: - - name: metrics-9399 - port: 9399 - targetPort: metrics-9399 - -# MQTT services - - it: with default MQTT service, then no service session affinity set - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1883 - spec: - ports: - - name: mqtt-1883 - targetPort: mqtt-1883 - port: 1883 - - - it: with MQTT service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - sessionAffinity: - type: ClientIP - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - sessionAffinity: ClientIP - - - it: with MQTT service enabled and session affinity `None`, then service session affinity is `None` - set: - services: - - type: mqtt - exposed: true - containerPort: 1884 - sessionAffinity: - type: None - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-mqtt-1884 - spec: - ports: - - name: mqtt-1884 - targetPort: mqtt-1884 - port: 1884 - sessionAffinity: None - - # CC services - - it: with default Control Center service enabled, then service session affinity is `ClientIP` - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8080 - spec: - ports: - - name: cc-8080 - targetPort: cc-8080 - port: 8080 - sessionAffinity: ClientIP - - - it: with Control Center service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - type: ClientIP - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8081 - spec: - ports: - - name: cc-8081 - targetPort: cc-8081 - port: 8081 - sessionAffinity: ClientIP - - - it: with Control Center service enabled and session affinity `None`, then service session affinity is `None` - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - type: None - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-cc-8081 - spec: - ports: - - name: cc-8081 - targetPort: cc-8081 - port: 8081 - sessionAffinity: None - - # REST API services - - it: with REST API service enabled with no session affinity, then no service session affinity - set: - services: - - type: rest-api - exposed: true - containerPort: 8888 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8888 - spec: - ports: - - name: rest-8888 - targetPort: rest-8888 - port: 8888 - - - it: with REST API service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` - set: - services: - - type: rest-api - exposed: true - containerPort: 8888 - sessionAffinity: - type: ClientIP - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8888 - spec: - ports: - - name: rest-8888 - targetPort: rest-8888 - port: 8888 - sessionAffinity: ClientIP - - - it: with REST API service enabled session affinity `None`, then service session affinity is `None` - set: - services: - - type: rest-api - exposed: true - containerPort: 8888 - sessionAffinity: - type: None - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-rest-8888 - spec: - ports: - - name: rest-8888 - targetPort: rest-8888 - port: 8888 - sessionAffinity: None - - # WebSocket services - - it: with WebSocket service enabled with no session affinity, then no service session affinity - set: - services: - - type: websocket - exposed: true - containerPort: 8001 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8001 - spec: - ports: - - name: ws-8001 - targetPort: ws-8001 - port: 8001 - - - it: with WebSocket service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` - set: - services: - - type: websocket - exposed: true - containerPort: 8001 - sessionAffinity: - type: ClientIP - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8001 - spec: - ports: - - name: ws-8001 - targetPort: ws-8001 - port: 8001 - sessionAffinity: ClientIP - - - it: with WebSocket service enabled and session affinity `None`, then service session affinity is `None` - set: - services: - - type: websocket - exposed: true - containerPort: 8001 - sessionAffinity: - type: None - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-ws-8001 - spec: - ports: - - name: ws-8001 - targetPort: ws-8001 - port: 8001 - sessionAffinity: None - - # Metrics services - - it: with Metrics service enabled with no session affinity, then no service session affinity - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - - - it: with Metrics service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - sessionAffinity: - type: ClientIP - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - sessionAffinity: ClientIP - - - it: with Metrics service enabled and session affinity `None`, then service session affinity is `None` - set: - services: - - type: metrics - exposed: true - containerPort: 9399 - sessionAffinity: - type: None - asserts: - - exists: - path: spec.services - - contains: - path: spec.services - content: - metadata: - name: hivemq-test-hivemq-platform-metrics-9399 - spec: - ports: - - name: metrics-9399 - targetPort: metrics-9399 - port: 9399 - sessionAffinity: None - - - it: with empty session affinity, schema validation fails - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - asserts: - - failedTemplate: {} - - - it: with empty session affinity type, schema validation fails - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - type: - asserts: - - failedTemplate: {} - - - it: with invalid session affinity type, schema validation fails - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - type: foobar - asserts: - - failedTemplate: {} - - - it: with additional session affinity element, schema validation fails - set: - services: - - type: control-center - exposed: true - containerPort: 8081 - sessionAffinity: - type: ClientIP - foo: bar - asserts: - - failedTemplate: {} diff --git a/charts/hivemq-platform/tests/services/hivemq_control_center_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_control_center_services_test.yaml new file mode 100644 index 000000000..7db0cc813 --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_control_center_services_test.yaml @@ -0,0 +1,147 @@ +suite: HiveMQ Platform Control Center services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with a Control Center service enabled + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: cc-8081 + containerPort: 8081 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8081 + spec: + ports: + - name: cc-8081 + targetPort: cc-8081 + port: 8081 + sessionAffinity: ClientIP + + - it: with a Control Center service disabled, no Control Center service added + set: + services: + - type: control-center + exposed: false + containerPort: 8081 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: cc-8081 + containerPort: 8081 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8081 + spec: + ports: + - name: cc-8081 + targetPort: cc-8081 + port: 8081 + sessionAffinity: ClientIP + + - it: with default Control Center service enabled, then service session affinity is `ClientIP` + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8080 + spec: + ports: + - name: cc-8080 + targetPort: cc-8080 + port: 8080 + sessionAffinity: ClientIP + + - it: with Control Center service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + type: ClientIP + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8081 + spec: + ports: + - name: cc-8081 + targetPort: cc-8081 + port: 8081 + sessionAffinity: ClientIP + + - it: with Control Center service enabled and session affinity `None`, then service session affinity is `None` + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + type: None + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8081 + spec: + ports: + - name: cc-8081 + targetPort: cc-8081 + port: 8081 + sessionAffinity: None + + - it: with a Control Center service enabled and PROXY protocol enabled, validation fails + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + hivemqProxyProtocol: true + asserts: + - failedTemplate: + errorMessage: Service type control-center with container port 8081 is using PROXY protocol value. PROXY protocol is only supported for MQTT and WebSocket services + + - it: with a Control Center service disabled and PROXY protocol enabled, validation succeeds + set: + services: + - type: control-center + exposed: false + containerPort: 8081 + hivemqProxyProtocol: true + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 diff --git a/charts/hivemq-platform/tests/services/hivemq_legacy_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_legacy_services_test.yaml new file mode 100644 index 000000000..3351145da --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_legacy_services_test.yaml @@ -0,0 +1,338 @@ +suite: HiveMQ Platform Legacy services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with statefulSet migration, then no default metrics service is created + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with statefulSet migration, then no default metrics service port is added to the HiveMQ container + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with duplicated legacy port name and different services types, validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt + - type: control-center + exposed: true + containerPort: 1884 + legacyPortName: mqtt + asserts: + - failedTemplate: + errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt + + - it: with duplicated legacy port names, validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt + - type: mqtt + exposed: true + containerPort: 1884 + legacyPortName: mqtt + asserts: + - failedTemplate: + errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt + + - it: with different legacy port names but duplicated ports, validation succeeds + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt1 + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt2 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with duplicated legacy port names in disabled services, then validation fails with ambiguous definition + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: false + containerPort: 1883 + legacyPortName: mqtt + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt + asserts: + - failedTemplate: + errorMessage: Ambiguous definition found for service hivemq-test-hivemq-platform-mqtt (set as exposed and not exposed) + + - it: with duplicated custom legacy service names, then validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt1 + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1884 + legacyPortName: mqtt2 + asserts: + - failedTemplate: + errorMessage: Found duplicated service name my-custom-mqtt + + - it: with statefulSet migration and `port` value set, then validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt1 + - type: mqtt + exposed: true + containerPort: 1884 + port: 1885 + legacyPortName: mqtt2 + asserts: + - failedTemplate: + errorMessage: Service type `mqtt` with container port `1884` cannot use `port` value as `migration.statefulSet` value is enabled + + - it: with statefulSet migration and `port` value set in not exposed services, then validation succeeds + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: mqtt1 + - type: mqtt + exposed: false + containerPort: 1884 + port: 1885 + legacyPortName: mqtt2 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with statefulSet migration disabled and `legacyPortName` value set, then validation fails + set: + migration.statefulSet: false + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: true + containerPort: 1884 + legacyPortName: mqtt2 + asserts: + - failedTemplate: + errorMessage: Service type `mqtt` with container port `1884` cannot use `legacyPortName` value as `migration.statefulSet` value is disabled + + - it: with statefulSet migration disabled and `legacyPortName` value set in not exposed services, then validation succeeds + set: + migration.statefulSet: false + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: false + containerPort: 1884 + legacyPortName: mqtt2 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with statefulSet migration and no mandatory `type` value for service, schema validation fails + set: + migration.statefulSet: true + services: + - exposed: true + legacyPortName: mqtt + containerPort: 1883 + asserts: + - failedTemplate: {} + + - it: with statefulSet migration and no mandatory `exposed` value for service, schema validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + legacyPortName: mqtt + containerPort: 1883 + asserts: + - failedTemplate: {} + + - it: with statefulSet migration and no mandatory `legacyPortName` value for service, schema validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: {} + + - it: with statefulSet migration and no mandatory `containerPort` value for service, schema validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + legacyPortName: mqtt + asserts: + - failedTemplate: {} + + - it: with statefulSet migration and missing mandatory values in some services, schema validation fails + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: true + containerPort: 1884 + legacyPortName: legacy + asserts: + - failedTemplate: {} + + - it: with statefulSet migration, then legacy service name + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.services + - lengthEqual: + path: spec.services + count: 1 + - equal: + path: spec.services[0].metadata.name + value: hivemq-test-hivemq-platform-legacy + + - it: with statefulSet migration and custom service name, then custom service name + set: + migration.statefulSet: true + services: + - type: mqtt + name: my-custom-legacy-mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.services + - lengthEqual: + path: spec.services + count: 1 + - equal: + path: spec.services[0].metadata.name + value: my-custom-legacy-mqtt + + - it: with statefulSet migration, then legacy service ports + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.services + - lengthEqual: + path: spec.services + count: 1 + - equal: + path: spec.services[0].metadata.name + value: hivemq-test-hivemq-platform-legacy + - exists: + path: spec.services[0].spec.ports + - contains: + path: spec.services[0].spec.ports + content: + name: legacy + targetPort: legacy + port: 1883 + + - it: with statefulSet migration, then legacy container ports + set: + migration.statefulSet: true + services: + - type: mqtt + exposed: true + containerPort: 1883 + legacyPortName: legacy + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: legacy + containerPort: 1883 diff --git a/charts/hivemq-platform/tests/services/hivemq_metrics_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_metrics_services_test.yaml new file mode 100644 index 000000000..121c41311 --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_metrics_services_test.yaml @@ -0,0 +1,1058 @@ +suite: HiveMQ Platform Metrics services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with default metrics values + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.metricsPath + - equal: + path: spec.metricsPath + value: / + + - it: with default metrics values, default Metrics service is created + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with default Metrics service disabled, then no service is added + set: + services: + - type: metrics + exposed: false + containerPort: 9399 + asserts: + - isNullOrEmpty: + path: spec.services + + - it: with default containerPort in enabled Metrics service, then no error is thrown + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with default containerPort in disabled Metrics service, then no default Metrics service is created + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: metrics + exposed: false + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - notContains: + path: spec.services + content: + - metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with default containerPort in disabled Metrics service, then no metric container port in HiveMQ container + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: metrics + exposed: false + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with default Metrics service disabled, then no container port is added to the HiveMQ container + set: + services: + - type: metrics + exposed: false + containerPort: 9399 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0] + - isNullOrEmpty: + path: spec.statefulSet.spec.template.spec.containers[0].ports + + - it: with custom Metrics service enabled but without default metrics port, then additional default metric service is added + set: + services: + - type: metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9499 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with custom Metrics service enabled but without default metrics port, then additional default metrics container port is added to the HiveMQ container + set: + services: + - type: metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with custom Metrics service enabled and with default metrics port, then no additional default metric service is added + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + count: 1 + + - it: with custom Metrics service enabled and with default metrics port, then no additional default metrics container port is added to the HiveMQ container + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + + - it: with custom Metrics service disabled but without default metrics port, then additional default metric service is added + set: + services: + - type: metrics + exposed: false + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9499 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with custom Metrics service disabled but without default metrics port, then default metrics container port is added to the HiveMQ container + set: + services: + - type: metrics + exposed: false + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with default metrics values, default Metrics service port is added to the HiveMQ container + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with metrics values disabled, then metrics port 0 + set: + metrics: + enabled: false + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 0 + - exists: + path: spec.metricsPath + - equal: + path: spec.metricsPath + value: / + + - it: with metrics values disabled, then no Metrics service is created + set: + metrics: + enabled: false + asserts: + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-0 + spec: + ports: + - name: metrics-0 + targetPort: metrics-0 + port: 0 + + - it: with metrics values disabled, then no metrics port is added to the HiveMQ container + set: + metrics: + enabled: false + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-0 + containerPort: 0 + + - it: with custom metrics port + set: + metrics: + port: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + + - it: with custom metrics port, default Metrics service is created in custom port + set: + metrics: + port: 9499 + asserts: + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9499 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + + - it: with custom metrics port, default metrics port is added to the HiveMQ container + set: + metrics: + port: 9499 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + + - it: with metrics enabled but port set to 0, default Metrics service is created + set: + metrics: + port: 0 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-0 + spec: + ports: + - name: metrics-0 + targetPort: metrics-0 + port: 0 + + - it: with metrics enabled but port set to 0, default metrics port is added to the HiveMQ container + set: + metrics: + port: 0 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-0 + containerPort: 0 + + - it: with custom metrics path + set: + metrics: + path: /foo + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPath + value: /foo + + - it: with metrics port within range, no schema validation fails + set: + metrics: + port: 0 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with metrics port within range, no schema validation fails + set: + metrics: + port: 65535 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with metrics port out of range, schema validation fails + set: + metrics: + port: 65536 + asserts: + - failedTemplate: {} + + - it: with custom Metrics service name with default metrics port, no additional default Metrics service is created + set: + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with custom Metrics service name with default metrics port, no additional default metrics port is added to the HiveMQ container + set: + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + + - it: with custom Metrics service name with custom metrics port, no additional default Metrics service is created + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + count: 1 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with custom Metrics service name with custom metrics port, no additional default metrics port is added to the HiveMQ container + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + count: 1 + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with custom Metrics service name with non matching metrics port, additional default Metrics service is created + set: + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with custom Metrics service name with non matching metrics port, additional default metrics port is added to the HiveMQ container + set: + services: + - type: metrics + name: my-custom-metrics + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with multiple Metrics services with default metrics port, then multiple Metrics services are created with no default additional Metrics service + set: + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9399 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-1 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-2 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with multiple Metrics services with default metrics port, then no duplicated metrics port are added to the HiveMQ container + set: + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9399 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + + - it: with multiple Metrics services with non matching default metrics port, then default metric port is added with no ports are added to the HiveMQ container + set: + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9499 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9399 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + count: 1 + + - it: with multiple Metrics services with custom metrics port, then multiple Metrics services are created with no default additional Metrics service + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9499 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-1 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-2 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with multiple Metrics services with custom metrics port, then no default metrics port is added to the HiveMQ container + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9499 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + count: 1 + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + + - it: with multiple Metrics services with matching and non matching metrics port, then multiple Metrics services are created with no default additional Metrics service + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9399 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-1 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + - contains: + path: spec.services + content: + metadata: + name: my-custom-metrics-2 + spec: + ports: + - name: metrics-9499 + targetPort: metrics-9499 + port: 9499 + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with multiple Metrics services with matching and non matching metrics port, then no default metrics port is added to the HiveMQ container + set: + metrics: + port: 9499 + services: + - type: metrics + name: my-custom-metrics-1 + exposed: true + containerPort: 9399 + - type: metrics + name: my-custom-metrics-2 + exposed: true + containerPort: 9499 + asserts: + - exists: + path: spec.metricsPort + - equal: + path: spec.metricsPort + value: 9499 + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9499 + containerPort: 9499 + + - it: with Metrics service enabled with no session affinity, then no service session affinity + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + + - it: with Metrics service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + sessionAffinity: + type: ClientIP + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + sessionAffinity: ClientIP + + - it: with Metrics service enabled and session affinity `None`, then service session affinity is `None` + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + sessionAffinity: + type: None + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + targetPort: metrics-9399 + port: 9399 + sessionAffinity: None + + - it: with a Metrics service enabled and PROXY protocol enabled, validation fails + set: + services: + - type: metrics + exposed: true + containerPort: 9399 + hivemqProxyProtocol: true + asserts: + - failedTemplate: + errorMessage: Service type metrics with container port 9399 is using PROXY protocol value. PROXY protocol is only supported for MQTT and WebSocket services + + - it: with a Metrics service disabled and PROXY protocol enabled, validation succeeds + set: + services: + - type: metrics + exposed: false + containerPort: 9399 + hivemqProxyProtocol: true + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 diff --git a/charts/hivemq-platform/tests/services/hivemq_mqtt_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_mqtt_services_test.yaml new file mode 100644 index 000000000..8eb46951e --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_mqtt_services_test.yaml @@ -0,0 +1,121 @@ +suite: HiveMQ Platform MQTT services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with a MQTT service enabled + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1884 + containerPort: 1884 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with a MQTT service disabled, no MQTT service added + set: + services: + - type: mqtt + exposed: false + containerPort: 1884 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1884 + containerPort: 1884 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with default MQTT service, then no service session affinity set + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + + - it: with MQTT service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + sessionAffinity: + type: ClientIP + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + sessionAffinity: ClientIP + + - it: with MQTT service enabled and session affinity `None`, then service session affinity is `None` + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + sessionAffinity: + type: None + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + sessionAffinity: None diff --git a/charts/hivemq-platform/tests/services/hivemq_rest_api_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_rest_api_services_test.yaml new file mode 100644 index 000000000..9c42dba51 --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_rest_api_services_test.yaml @@ -0,0 +1,149 @@ +suite: HiveMQ Platform REST API services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with a REST API service enabled + set: + services: + - type: rest-api + exposed: true + containerPort: 8890 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: rest-8890 + containerPort: 8890 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8890 + spec: + ports: + - name: rest-8890 + targetPort: rest-8890 + port: 8890 + + - it: with a REST API service disabled, no REST API service added + set: + services: + - type: rest-api + exposed: false + containerPort: 8890 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: rest-8890 + containerPort: 8890 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8890 + spec: + ports: + - name: rest-8890 + targetPort: rest-8890 + port: 8890 + + - it: with REST API service enabled with no session affinity, then no service session affinity + set: + services: + - type: rest-api + exposed: true + containerPort: 8888 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8888 + spec: + ports: + - name: rest-8888 + targetPort: rest-8888 + port: 8888 + + - it: with REST API service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` + set: + services: + - type: rest-api + exposed: true + containerPort: 8888 + sessionAffinity: + type: ClientIP + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8888 + spec: + ports: + - name: rest-8888 + targetPort: rest-8888 + port: 8888 + sessionAffinity: ClientIP + + - it: with REST API service enabled session affinity `None`, then service session affinity is `None` + set: + services: + - type: rest-api + exposed: true + containerPort: 8888 + sessionAffinity: + type: None + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8888 + spec: + ports: + - name: rest-8888 + targetPort: rest-8888 + port: 8888 + sessionAffinity: None + + - it: with a REST API service enabled and PROXY protocol enabled, validation fails + set: + services: + - type: rest-api + exposed: true + containerPort: 8888 + hivemqProxyProtocol: true + asserts: + - failedTemplate: + errorMessage: Service type rest-api with container port 8888 is using PROXY protocol value. PROXY protocol is only supported for MQTT and WebSocket services + + - it: with a REST API service disabled and PROXY protocol enabled, validation succeeds + set: + services: + - type: rest-api + exposed: false + containerPort: 8888 + hivemqProxyProtocol: true + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 diff --git a/charts/hivemq-platform/tests/hivemq_secure_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_secure_services_test.yaml similarity index 99% rename from charts/hivemq-platform/tests/hivemq_secure_services_test.yaml rename to charts/hivemq-platform/tests/services/hivemq_secure_services_test.yaml index c9142ce00..2556ad3d0 100644 --- a/charts/hivemq-platform/tests/hivemq_secure_services_test.yaml +++ b/charts/hivemq-platform/tests/services/hivemq_secure_services_test.yaml @@ -436,7 +436,7 @@ tests: - it: with several secure and non-secure MQTT services enabled and reusing keystores values: - - tls-mqtt-services-values.yaml + - ../tls-mqtt-services-values.yaml asserts: - exists: path: spec.statefulSet.spec.template.spec.containers[0].env @@ -681,7 +681,7 @@ tests: - it: with several secure MQTT services using mTLS values: - - mtls-mqtt-services-values.yaml + - ../mtls-mqtt-services-values.yaml asserts: - exists: path: spec.statefulSet.spec.template.spec.volumes @@ -1280,7 +1280,7 @@ tests: - it: with several secure and non-secure Control Center services enabled and reusing keystores values: - - tls-cc-services-values.yaml + - ../tls-cc-services-values.yaml asserts: - exists: path: spec.statefulSet.spec.template.spec.containers[0].env @@ -1970,7 +1970,7 @@ tests: - it: with several secure and non-secure WebSocket services enabled and reusing keystores values: - - tls-ws-services-values.yaml + - ../tls-ws-services-values.yaml asserts: - exists: path: spec.statefulSet.spec.template.spec.containers[0].env diff --git a/charts/hivemq-platform/tests/services/hivemq_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_services_test.yaml new file mode 100644 index 000000000..523229d92 --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_services_test.yaml @@ -0,0 +1,917 @@ +suite: HiveMQ Platform services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with default values + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: cc-8080 + containerPort: 8080 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8080 + spec: + ports: + - name: cc-8080 + targetPort: cc-8080 + port: 8080 + sessionAffinity: ClientIP + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + port: 9399 + targetPort: metrics-9399 + + - it: with no mandatory `type` value for service, schema validation fails + set: + services: + - exposed: true + containerPort: 1884 + asserts: + - failedTemplate: {} + + - it: with no mandatory `exposed` value for service, schema validation fails + set: + services: + - type: mqtt + containerPort: 1884 + asserts: + - failedTemplate: {} + + - it: with no mandatory `containerPort` value for service, schema validation fails + set: + services: + - type: mqtt + exposed: true + asserts: + - failedTemplate: {} + + - it: with NodePort + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + serviceType: NodePort + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + type: NodePort + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with additional annotations + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + annotations: + annotation-key-1: annotation-value-1 + annotation-key-2: annotation-value-2 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + annotations: + annotation-key-1: annotation-value-1 + annotation-key-2: annotation-value-2 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with additional labels + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + labels: + label-key-1: label-value-1 + label-key-2: label-value-2 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + labels: + label-key-1: label-value-1 + label-key-2: label-value-2 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with additional annotations and labels + set: + services: + - type: mqtt + exposed: true + containerPort: 1884 + annotations: + annotation-key-1: annotation-value-1 + annotation-key-2: annotation-value-2 + labels: + label-key-1: label-value-1 + label-key-2: label-value-2 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + annotations: + annotation-key-1: annotation-value-1 + annotation-key-2: annotation-value-2 + labels: + label-key-1: label-value-1 + label-key-2: label-value-2 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + + - it: with default container ports in enabled services, then fails + set: + services: + - type: mqtt + exposed: true + containerPort: 7000 + asserts: + - failedTemplate: + errorMessage: Container port 7000 in service `mqtt` already exists as part of one of the predefined ports (7979, 8889, 7000) + + - it: with default container ports in disabled services, no error is thrown and only enabled services are created + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: false + containerPort: 7000 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - notContains: + path: spec.services + content: + - metadata: + name: hivemq-test-hivemq-platform-mqtt-7000 + spec: + ports: + - name: mqtt-7000 + targetPort: mqtt-7000 + port: 7000 + + - it: with custom service names + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-mqtt + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + + - it: with duplicated container ports and different services types, then validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: control-center + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Services with same container port (1883) but different types cannot be set + + - it: with duplicated container ports and different services types but disabled services, only enabled services are created + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: control-center + exposed: false + containerPort: 1883 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - notContains: + path: spec.services + content: + - metadata: + name: hivemq-test-hivemq-platform-cc-1883 + spec: + sessionAffinity: ClientIP + ports: + - name: cc-1883 + targetPort: cc-1883 + port: 1883 + + - it: with duplicated container ports and different services types but disabled services, then only enabled container ports added to the HiveMQ container + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: control-center + exposed: false + containerPort: 1883 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + count: 1 + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: cc-1883 + containerPort: 1883 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + count: 1 + + - it: with duplicated service container port, same type but different custom names, then services are created + set: + services: + - type: mqtt + name: my-custom-mqtt-1 + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt-2 + exposed: true + containerPort: 1883 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-mqtt-1 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - contains: + path: spec.services + content: + metadata: + name: my-custom-mqtt-2 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + + - it: with duplicated service container port, same type but different custom names, then no duplicated ports added to the HiveMQ container + set: + services: + - type: mqtt + name: my-custom-mqtt-1 + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt-2 + exposed: true + containerPort: 1883 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + count: 1 + + - it: with duplicated service container port, same type but different custom names in disabled services, then only enabled services are created + set: + services: + - type: mqtt + name: my-custom-mqtt-1 + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt-2 + exposed: false + containerPort: 1883 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: my-custom-mqtt-1 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - notContains: + path: spec.services + content: + metadata: + name: my-custom-mqtt-2 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + + - it: with duplicated service container port, same type but different custom names in disabled services, then no duplicated ports added to the HiveMQ container + set: + services: + - type: mqtt + name: my-custom-mqtt-1 + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt-2 + exposed: true + containerPort: 1883 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + count: 1 + + - it: with duplicated service container port and type, validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Found duplicated service name hivemq-test-hivemq-platform-mqtt-1883 + + - it: with duplicated service container port and type in disabled services, then validation fails with ambiguous definition + set: + services: + - type: mqtt + exposed: false + containerPort: 1883 + - type: mqtt + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Ambiguous definition found for service hivemq-test-hivemq-platform-mqtt-1883 (set as exposed and not exposed) + + - it: with duplicated custom service names and container port, validation fails + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + - type: metrics + name: my-custom-mqtt + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Found duplicated service name my-custom-mqtt + + - it: with duplicated service container port and custom name but different type in disabled services, then validation fails with ambiguous definition + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + - type: metrics + name: my-custom-mqtt + exposed: false + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) + + - it: with duplicated custom service names and container port but different types in disabled services, then fails with ambiguous definition + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + - type: metrics + name: my-custom-mqtt + exposed: false + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) + + - it: with duplicated custom service names and container port and type, validation fails + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Found duplicated service name my-custom-mqtt + + - it: with duplicated service container port, custom name and type in disabled services, then validation fails with ambiguous definition + set: + services: + - type: mqtt + name: my-custom-mqtt + exposed: true + containerPort: 1883 + - type: mqtt + name: my-custom-mqtt + exposed: false + containerPort: 1883 + asserts: + - failedTemplate: + errorMessage: Ambiguous definition found for service my-custom-mqtt (set as exposed and not exposed) + + - it: with custom service name longer than 63 characters, schema validation fails + set: + services: + - type: mqtt + name: my-so-huge-and-extremely-very-very-long-custom-mqtt-service-name + exposed: true + containerPort: 1883 + asserts: + - failedTemplate: {} + + - it: with container service port within range, no schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 0 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with container service port within range, no schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 65535 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with container service port out of range, schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 65536 + asserts: + - failedTemplate: {} + + - it: with service port within range, no schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 0 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with service port within range, no schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 65535 + asserts: + - notFailedTemplate: {} + - hasDocuments: + count: 1 + + - it: with service port out of range, schema validation fails + set: + services: + - type: mqtt + exposed: true + containerPort: 65536 + asserts: + - failedTemplate: {} + + - it: with all service types, then service names are correct + set: + services: + - type: mqtt + exposed: true + containerPort: 1883 + - type: mqtt + exposed: true + containerPort: 1884 + keystoreSecretName: "keystore-secret" + keystorePasswordSecretName: "keystore-secret-password" + - type: control-center + exposed: true + containerPort: 8080 + - type: control-center + exposed: true + containerPort: 8081 + keystoreSecretName: "keystore-secret" + keystorePasswordSecretName: "keystore-secret-password" + - type: websocket + exposed: true + containerPort: 8000 + - type: websocket + exposed: true + containerPort: 8001 + keystoreSecretName: "keystore-secret" + keystorePasswordSecretName: "keystore-secret-password" + - type: rest-api + exposed: true + containerPort: 8888 + - type: metrics + exposed: true + containerPort: 9399 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + port: 1883 + targetPort: mqtt-1883 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 # FIXME: Expected secure MQTT service name should be `mqtts` + spec: + ports: + - name: mqtts-1884 + port: 1884 + targetPort: mqtts-1884 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8080 + spec: + ports: + - name: cc-8080 + port: 8080 + targetPort: cc-8080 + sessionAffinity: ClientIP + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-cc-8081 + spec: + ports: + - name: cc-8081 + port: 8081 + targetPort: cc-8081 + sessionAffinity: ClientIP + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8000 + spec: + ports: + - name: ws-8000 + port: 8000 + targetPort: ws-8000 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8001 + spec: + ports: + - name: ws-8001 + port: 8001 + targetPort: ws-8001 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-rest-8888 + spec: + ports: + - name: rest-8888 + port: 8888 + targetPort: rest-8888 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + port: 9399 + targetPort: metrics-9399 + + - it: with multiple service listeners defined + values: + - ../multiple-service-listeners.yaml + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1884 + containerPort: 1884 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: ws-8000 + containerPort: 8000 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: ws-8001 + containerPort: 8001 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-mqtt-1884 + spec: + ports: + - name: mqtt-1884 + targetPort: mqtt-1884 + port: 1884 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8000 + spec: + ports: + - name: ws-8000 + targetPort: ws-8000 + port: 8000 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8001 + spec: + ports: + - name: ws-8001 + targetPort: ws-8001 + port: 8001 + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-metrics-9399 + spec: + ports: + - name: metrics-9399 + port: 9399 + targetPort: metrics-9399 + + - it: with default values, then truncated service names + release: + name: this-is-more-than-32-chars-long-release-name + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: mqtt-1883 + containerPort: 1883 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: cc-8080 + containerPort: 8080 + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: metrics-9399 + containerPort: 9399 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-this-is-more-than-32-chars-long-release-na-mqtt-1883 + spec: + ports: + - name: mqtt-1883 + targetPort: mqtt-1883 + port: 1883 + - contains: + path: spec.services + content: + metadata: + name: hivemq-this-is-more-than-32-chars-long-release-na-cc-8080 + spec: + ports: + - name: cc-8080 + targetPort: cc-8080 + port: 8080 + sessionAffinity: ClientIP + - contains: + path: spec.services + content: + metadata: + name: hivemq-this-is-more-than-32-chars-long-release-na-metrics-9399 + spec: + ports: + - name: metrics-9399 + port: 9399 + targetPort: metrics-9399 + + - it: with empty session affinity, schema validation fails + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + asserts: + - failedTemplate: {} + + - it: with empty session affinity type, schema validation fails + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + type: + asserts: + - failedTemplate: {} + + - it: with invalid session affinity type, schema validation fails + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + type: foobar + asserts: + - failedTemplate: {} + + - it: with additional session affinity element, schema validation fails + set: + services: + - type: control-center + exposed: true + containerPort: 8081 + sessionAffinity: + type: ClientIP + foo: bar + asserts: + - failedTemplate: {} diff --git a/charts/hivemq-platform/tests/services/hivemq_websocket_services_test.yaml b/charts/hivemq-platform/tests/services/hivemq_websocket_services_test.yaml new file mode 100644 index 000000000..7b231a8c4 --- /dev/null +++ b/charts/hivemq-platform/tests/services/hivemq_websocket_services_test.yaml @@ -0,0 +1,126 @@ +suite: HiveMQ Platform WebSocket services tests +templates: + - hivemq-custom-resource.yml +release: + name: test-hivemq-platform +tests: + + - it: with a WebSocket service enabled + set: + services: + - type: websocket + exposed: true + containerPort: 8000 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - contains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: ws-8000 + containerPort: 8000 + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8000 + spec: + ports: + - name: ws-8000 + targetPort: ws-8000 + port: 8000 + + - it: with a WebSocket service disabled, no WebSocket service added + set: + services: + - type: websocket + exposed: false + containerPort: 8000 + asserts: + - exists: + path: spec.statefulSet.spec.template.spec.containers[0].ports[0] + - notContains: + path: spec.statefulSet.spec.template.spec.containers[0].ports + content: + name: ws-8000 + containerPort: 8000 + - exists: + path: spec.services + - notContains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8000 + spec: + ports: + - name: ws-8000 + targetPort: ws-8000 + port: 8000 + + - it: with WebSocket service enabled with no session affinity, then no service session affinity + set: + services: + - type: websocket + exposed: true + containerPort: 8001 + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8001 + spec: + ports: + - name: ws-8001 + targetPort: ws-8001 + port: 8001 + + - it: with WebSocket service enabled and session affinity `ClientIP`, then service session affinity is `ClientIP` + set: + services: + - type: websocket + exposed: true + containerPort: 8001 + sessionAffinity: + type: ClientIP + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8001 + spec: + ports: + - name: ws-8001 + targetPort: ws-8001 + port: 8001 + sessionAffinity: ClientIP + + - it: with WebSocket service enabled and session affinity `None`, then service session affinity is `None` + set: + services: + - type: websocket + exposed: true + containerPort: 8001 + sessionAffinity: + type: None + asserts: + - exists: + path: spec.services + - contains: + path: spec.services + content: + metadata: + name: hivemq-test-hivemq-platform-ws-8001 + spec: + ports: + - name: ws-8001 + targetPort: ws-8001 + port: 8001 + sessionAffinity: None