Skip to content

Commit

Permalink
fix: Fix YAKS tests
Browse files Browse the repository at this point in the history
- Update expected Json returned from OpenAQ API
- Update ActiveMQ Artemis to version v1.0.14 in tests
- Use specific ActiveMQ Artemis broker instance in tests
- Update ActiveMQ Artemis client to 2.21.0
- Add required activemq-address field removeFromBrokerOnDelete
- Fix user report system endpoint URL
  • Loading branch information
christophd committed Aug 24, 2023
1 parent 68dfdd0 commit 114621d
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 31 deletions.
1 change: 1 addition & 0 deletions infra/messaging/broker/instances/addresses/alarms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ spec:
addressName: alarms
queueName: alarms
routingType: anycast
removeFromBrokerOnDelete: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ spec:
addressName: notifications
queueName: notifications
routingType: anycast
removeFromBrokerOnDelete: true
8 changes: 5 additions & 3 deletions test/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ kafka.bootstrap.server.port=9092
kafka.bootstrap.address=${kafka.bootstrap.server.host}:${kafka.bootstrap.server.port}

# Bridge message broker configuration
messaging.broker.url.amqp=amqp://broker-hdls-svc:5672
messaging.broker.url=tcp://broker-hdls-svc:61616
quarkus.qpid-jms.url=amqp://broker-hdls-svc:5672
messaging.broker.host=artemis-broker-hdls-svc
messaging.broker.port=61616
messaging.broker.url.amqp=amqp://${messaging.broker.host}:5672
messaging.broker.url=tcp://${messaging.broker.host}:61616
quarkus.qpid-jms.url=amqp://${messaging.broker.host}:5672

# Auth
users.allowed=user1,user2,user3
1 change: 0 additions & 1 deletion test/bridges/CrimeBridge.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@require('org.apache.activemq:artemis-jms-client:2.11.0')
Feature: Crime bridge test

Background:
Expand Down
1 change: 0 additions & 1 deletion test/bridges/EarthquakeBridge.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@require('org.apache.activemq:artemis-jms-client:2.11.0')
Feature: Earthquake bridge test

Background:
Expand Down
1 change: 0 additions & 1 deletion test/bridges/HealthBridge.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@require('org.apache.activemq:artemis-jms-client:2.11.0')
Feature: Health bridge test

Background:
Expand Down
1 change: 0 additions & 1 deletion test/bridges/PollutionBridge.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@require('org.apache.activemq:artemis-jms-client:2.11.0')
Feature: Pollution bridge test

Background:
Expand Down
10 changes: 10 additions & 0 deletions test/bridges/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ config:
value: false
- name: YAKS_CAMELK_SUPPORT_VARIABLES_IN_SOURCES
value: false
settings:
loggers:
- name: INTEGRATION_STATUS
level: INFO
- name: INTEGRATION_LOGS
level: INFO
dependencies:
- groupId: org.apache.activemq
artifactId: artemis-jms-client
version: 2.21.0
resources:
- ../../CrimeBridge.java
- ../../EarthquakeBridge.java
Expand Down
7 changes: 6 additions & 1 deletion test/consumers/OpenAQConsumer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ Feature: OpenAQ consumer test
And expect Kafka message with body
"""
{
"locationId": "@assertThat(nullValue())@",
"location": "@assertThat(notNullValue())@",
"parameter": "@assertThat(notNullValue())@",
"date": "@assertThat(notNullValue())@",
"value": "@assertThat(notNullValue())@",
"unit": "@assertThat(notNullValue())@",
"coordinates": "@assertThat(notNullValue())@",
"country": "@assertThat(notNullValue())@",
"city": "@assertThat(notNullValue())@"
"city": "@assertThat(notNullValue())@",
"isMobile": "@assertThat(nullValue())@",
"isAnalysis": "@assertThat(nullValue())@",
"entity": "@assertThat(nullValue())@",
"sensorType": "@assertThat(nullValue())@"
}
"""

Expand Down
1 change: 1 addition & 0 deletions test/infra/activemq-address.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ spec:
addressName: ${activemq.address}
queueName: ${activemq.address}
routingType: anycast
removeFromBrokerOnDelete: true
4 changes: 4 additions & 0 deletions test/infra/amq-broker-instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: broker.amq.io/v1beta1
kind: ActiveMQArtemis
metadata:
name: artemis-broker
36 changes: 15 additions & 21 deletions test/scripts/install-amq-broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,39 @@

set -e

waitFor() {
for i in {1..30}; do
sleep 5
("$@") && return
echo "$i Waiting for command to finish"
done
exit 1
}

SOURCE=$(dirname "$0")
INFRA="${SOURCE}"/../../infra
ACTIVEMQ_VERSION=v0.19.3
INFRA="${SOURCE}"/../infra
ACTIVEMQ_VERSION=v1.0.14
URL="https://raw.githubusercontent.com/artemiscloud/activemq-artemis-operator/${ACTIVEMQ_VERSION}"

BROKER=$(kubectl get activemqartemis/broker -n ${YAKS_NAMESPACE} || echo "")
BROKER=$(kubectl get activemqartemis/artemis-broker -n ${YAKS_NAMESPACE} || echo "")

#check for existing amq-broker instance
if [ -z "$BROKER" ]; then

# Install AMQ Artemis
kubectl create -f "${URL}"/deploy/service_account.yaml
kubectl create -f "${URL}"/deploy/role.yaml
kubectl create -f "${URL}"/deploy/role_binding.yaml

kubectl create -f "${URL}"/deploy/crds/broker_activemqartemis_crd.yaml
kubectl create -f "${URL}"/deploy/crds/broker_activemqartemisaddress_crd.yaml
kubectl create -f "${URL}"/deploy/crds/broker_activemqartemisscaledown_crd.yaml
kubectl create -f "${URL}"/deploy/crds/broker_activemqartemissecurity_crd.yaml

kubectl create -f "${URL}"/deploy/service_account.yaml
kubectl create -f "${URL}"/deploy/role.yaml
kubectl create -f "${URL}"/deploy/role_binding.yaml
kubectl create -f "${URL}"/deploy/election_role.yaml
kubectl create -f "${URL}"/deploy/election_role_binding.yaml

kubectl create -f "${URL}"/deploy/operator_config.yaml
kubectl create -f "${URL}"/deploy/operator.yaml

# wait for operator to start
waitFor kubectl wait pod -l name=activemq-artemis-operator --for condition=Ready --timeout=60s -n ${YAKS_NAMESPACE}
kubectl wait pod -l name=activemq-artemis-operator --for condition=Ready --timeout=300s -n ${YAKS_NAMESPACE}

# Create AMQ broker
kubectl create -f "${INFRA}"/messaging/broker/instances/amq-broker-instance.yaml -n ${YAKS_NAMESPACE}
# create AMQ broker
kubectl create -f "${INFRA}"/amq-broker-instance.yaml -n ${YAKS_NAMESPACE}

# wait for broker to start
waitFor kubectl wait pod -l ActiveMQArtemis=broker --for condition=Ready --timeout=60s -n ${YAKS_NAMESPACE}

kubectl wait activemqartemis/artemis-broker --for condition=Deployed --timeout=300s -n ${YAKS_NAMESPACE}
else
echo "AMQ Broker instance already exists"
fi
43 changes: 43 additions & 0 deletions test/scripts/uninstall-amq-broker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

ACTIVEMQ_VERSION=v1.0.14
URL="https://raw.githubusercontent.com/artemiscloud/activemq-artemis-operator/${ACTIVEMQ_VERSION}"

BROKER=$(kubectl get activemqartemis/artemis-broker -n ${YAKS_NAMESPACE} || echo "")

#check for existing amq-broker instance
if [ -z "$BROKER" ]; then
echo "No AMQ Broker instance found"
else
# Install AMQ Artemis
kubectl delete -f "${URL}"/deploy/crds/broker_activemqartemis_crd.yaml
kubectl delete -f "${URL}"/deploy/crds/broker_activemqartemisaddress_crd.yaml
kubectl delete -f "${URL}"/deploy/crds/broker_activemqartemisscaledown_crd.yaml
kubectl delete -f "${URL}"/deploy/crds/broker_activemqartemissecurity_crd.yaml

kubectl delete -f "${URL}"/deploy/service_account.yaml
kubectl delete -f "${URL}"/deploy/role.yaml
kubectl delete -f "${URL}"/deploy/role_binding.yaml
kubectl delete -f "${URL}"/deploy/election_role.yaml
kubectl delete -f "${URL}"/deploy/election_role_binding.yaml

kubectl delete -f "${URL}"/deploy/operator_config.yaml
kubectl delete -f "${URL}"/deploy/operator.yaml
fi
4 changes: 3 additions & 1 deletion test/user-report/UserReportCrime.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: User report and gate-keeper component test

Background:
Given URL: http://user-report-system.${YAKS_NAMESPACE}.svc.cluster.local
Given URL: http://user-report-system.${YAKS_NAMESPACE}
Given HTTP request timeout is 60000 ms
Given load variables application-test.properties
Given variables
Expand All @@ -19,12 +19,14 @@ Feature: User report and gate-keeper component test
When load Camel K integration UserReportSystem.java with configuration
| traits | knative-service.min-scale=1 |
Then Camel K integration user-report-system should be running
Then Camel K integration user-report-system should print Listening on

Scenario: Run GateKeeper Camel K integration
Given Camel K integration property file application-test.properties
When load Camel K integration GateKeeper.java with configuration
| traits | knative-service.min-scale=1 |
Given Camel K integration gate-keeper should be running
Then Camel K integration gate-keeper should print Listening on

Scenario: Crime report is send to crime-data topic
Given variable user is "user1"
Expand Down
4 changes: 3 additions & 1 deletion test/user-report/UserReportHealth.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Health user report and gate-keeper component test

Background:
Given URL: http://user-report-system.${YAKS_NAMESPACE}.svc.cluster.local
Given URL: http://user-report-system.${YAKS_NAMESPACE}
Given HTTP request timeout is 60000 ms
Given load variables application-test.properties
Given variables
Expand All @@ -19,12 +19,14 @@ Feature: Health user report and gate-keeper component test
When load Camel K integration UserReportSystem.java with configuration
| traits | knative-service.min-scale=1 |
Then Camel K integration user-report-system should be running
Then Camel K integration user-report-system should print Listening on

Scenario: Run GateKeeper Camel K integration
Given Camel K integration property file application-test.properties
When load Camel K integration GateKeeper.java with configuration
| traits | knative-service.min-scale=1 |
Given Camel K integration gate-keeper should be running
Then Camel K integration gate-keeper should print Listening on

Scenario: Health report is send to health-data topic
Given variable user is "user1"
Expand Down

0 comments on commit 114621d

Please sign in to comment.