Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add integration test for app-service with external-mqtt-trigger #534

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TAF/config/global_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
APP_HTTP_EXPORT_PORT = 59704
APP_MQTT_EXPORT_PORT = 59703
APP_FUNCTIOAL_TESTS_PORT = 59705
APP_EXTERNAL_MQTT_TRIGGER_PORT = 59706
REGISTRY_PORT = 8500

if SECURITY_SERVICE_NEEDED == 'true':
Expand Down
10 changes: 10 additions & 0 deletions TAF/testData/app-service/secrets_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,15 @@
"value": "httpuser"
}
]
},
"External MQTT Trigger Auth": {
"apiVersion" : "v2",
"path" : "mqtt-trigger",
"secretData" : [
{
"key" : "api-key",
"value": "externalmqttuser"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
*** Settings ***
Library Process
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot
Resource TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot
Suite Setup Setup Suite
Suite Teardown Run Teardown Keywords
Force Tags MessageQueue=redis

*** Variables ***
${SUITE} External MQTT Trigger
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/external_mqtt_trigger.log

*** Test Cases ***
ExternalTrigger001 - Test external mqtt trigger works
Given Set Test Variable ${publish_msg} Message from mqtt publisher
And Set Test Variable ${mqtt_trigger_topic} external-request
And Set Test Variable ${mqtt_export_topic} edgex-export
And Subscribe MQTT Broker Topics
When Run process python ${WORK_DIR}/TAF/utils/src/setup/mqtt-publisher.py ${mqtt_trigger_topic} "${publish_msg}"
... shell=True
Then Message Is Recevied By ${mqtt_trigger_topic} Topic
And Message Is Recevied By ${mqtt_export_topic} Topic
[Teardown] Terminate All Processes kill=True


*** Keywords ***
Subscribe MQTT Broker Topics
${topics} Create List ${mqtt_trigger_topic} ${mqtt_export_topic}
FOR ${topic} IN @{topics}
Start process python ${WORK_DIR}/TAF/utils/src/setup/mqtt-subscriber.py ${topic} ${publish_msg} arg # Process for MQTT Subscriber
... shell=True stdout=${WORK_DIR}/TAF/testArtifacts/logs/${topic}.log
END

Message Is Recevied By ${topic} Topic
${subscribe_msg} Grep File ${WORK_DIR}/TAF/testArtifacts/logs/${topic}.log ${publish_msg}
Should Not Be Empty ${subscribe_msg}

Store Secret With ${service} To Vault
Set Test Variable ${url} http://${BASE_URL}:${APP_EXTERNAL_MQTT_TRIGGER_PORT}
Store Secret Data With ${service} Auth
13 changes: 13 additions & 0 deletions TAF/utils/src/setup/mqtt-publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

import paho.mqtt.client as mqtt
import sys

topic = sys.argv[1]
message = sys.argv[2]


client = mqtt.Client()
client.connect("localhost", 1883, 60)
client.publish(topic, message)
client.disconnect()