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(uat): add T22 scenario with steps for large message #374

Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,33 @@ private void subscribe(@NonNull String clientDeviceId, @NonNull String topicFilt
}
}

/**
* Publish the large MQTT message.
*
* @param clientDeviceId user defined client device id
* @param topicString the topic to publish message
* @param qos the value of MQTT QoS for publishing
* @param messageBeginning the content of message with beginning to publish
* @param messageLength the length of message
* @throws StatusRuntimeException on gRPC errors
* @throws IllegalArgumentException on invalid QoS argument
*/
@When("I publish from {string} to {string} with qos {int} and large message with beginning of {string} "
+ "with length {int}")
public void publishLargeMessage(String clientDeviceId, String topicString, int qos,
String messageBeginning, int messageLength) {
String longMessage = generateLongMessage(messageBeginning, messageLength);

publish(clientDeviceId, topicString, qos, longMessage, PublishReasonCode.SUCCESS.getValue());
}

/**
* Publish the MQTT message.
*
* @param clientDeviceId user defined client device id
* @param topicString the topic to publish message
* @param qos the value of MQTT QoS for publishing
* @param message the the content of message to publish
* @param message the content of message to publish
* @throws StatusRuntimeException on gRPC errors
* @throws IllegalArgumentException on invalid QoS argument
*/
Expand All @@ -938,7 +958,7 @@ public void publish(String clientDeviceId, String topicString, int qos, String m
* @param clientDeviceId user defined client device id
* @param topicString the topic to publish message
* @param qos the value of MQTT QoS for publishing
* @param message the the content of message to publish
* @param message the content of message to publish
* @param expectedStatus the status of MQTT QoS for publish reply
* @throws StatusRuntimeException on gRPC errors
* @throws IllegalArgumentException on invalid QoS argument
Expand Down Expand Up @@ -1009,6 +1029,30 @@ public void receivedMessage(String message, String clientDeviceId, String topicS
receive(message, clientDeviceId, topicString, value, unit, true);
}


/**
* Verify is MQTT message is received in limited duration of time.
*
* @param message beginning of long message to receive
* @param messageLength the length of long message
* @param clientDeviceId the user defined client device id
* @param topicString the topic (not a filter) which message has been sent
* @param value the duration of time to wait for message
* @param unit the time unit to wait
* @throws TimeoutException when matched message was not received in specified duration of time
* @throws RuntimeException on internal errors
* @throws InterruptedException then thread has been interrupted
*/
@SuppressWarnings("PMD.UseObjectForClearerAPI")
@And("message beginning with {string} and with length {int} received on {string} "
+ "from {string} topic within {int} {word}")
public void receivedMessageBeginning(String message, int messageLength, String clientDeviceId, String topicString,
int value, String unit)
throws TimeoutException, InterruptedException {
String longMessage = generateLongMessage(message, messageLength);
receive(longMessage, clientDeviceId, topicString, value, unit, true);
}

/**
* Verify is MQTT message is received in limited duration of time.
*
Expand Down Expand Up @@ -1202,6 +1246,17 @@ public void unsubscribe(String clientDeviceId, String filter) {
log.info("MQTT topics filter {} has been unsubscribed", filter);
}

private String generateLongMessage(String messageBeginning, int totalLength) {
StringBuilder longMessageBuilder = new StringBuilder();
int repeatedTimes = totalLength / messageBeginning.length() + 1;

for (int i = 0; i < repeatedTimes; i++) {
longMessageBuilder.append(messageBeginning);
}

return longMessageBuilder.substring(0, totalLength);
}

private IotPolicySpec createDefaultClientDevicePolicy(String policyNameOverride) throws IOException {
return iotSteps.createPolicy(DEFAULT_CLIENT_DEVICE_POLICY_CONFIG, policyNameOverride);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,119 @@ Feature: GGMQ-1
| mqtt-v | name | agent | recipe |
| v5 | paho-python | aws.greengrass.client.Mqtt5PythonPahoClient | client_python_paho.yaml |

@GGMQ-1-T22
Scenario Outline: GGMQ-1-T22-<mqtt-v>-<name>: As a customer, I can send a message of size 128KiB to the MQTT broker
auarbekov marked this conversation as resolved.
Show resolved Hide resolved
When I create a Greengrass deployment with components
| aws.greengrass.clientdevices.Auth | LATEST |
| aws.greengrass.clientdevices.mqtt.EMQX | LATEST |
| aws.greengrass.clientdevices.IPDetector | LATEST |
| aws.greengrass.clientdevices.mqtt.Bridge | LATEST |
| <agent> | classpath:/local-store/recipes/<recipe> |
And I create client device "large_payload_publisher"
When I associate "large_payload_publisher" with ggc
And I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to:
"""
{
"MERGE":{
"deviceGroups":{
"formatVersion":"2021-03-05",
"definitions":{
"MyPermissiveDeviceGroup":{
"selectionRule":"thingName: ${large_payload_publisher}",
"policyName":"MyPermissivePolicy"
}
},
"policies":{
"MyPermissivePolicy":{
"AllowAll":{
"statementDescription":"Allow client devices to perform all actions.",
"operations":[
"*"
],
"resources":[
"*"
]
}
}
}
}
}
}
"""
And I update my Greengrass deployment configuration, setting the component <agent> configuration to:
"""
{
"MERGE":{
"controlAddresses":"${mqttControlAddresses}",
"controlPort":"${mqttControlPort}"
}
}
"""
And I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.mqtt.Bridge configuration to:
"""
{
"MERGE":{
"mqttTopicMapping":{
"mapping1:":{
"topic":"${large_payload_publisher}topic/to/iotcore",
"source":"LocalMqtt",
"target":"IotCore"
}
}
}
}
"""
And I deploy the Greengrass deployment configuration
Then the Greengrass deployment is COMPLETED on the device after 5 minutes
And the aws.greengrass.clientdevices.mqtt.EMQX log on the device contains the line "is running now!." within 1 minutes

And I discover core device broker as "default_broker" from "large_payload_publisher" in OTF
And I connect device "large_payload_publisher" on <agent> to "default_broker" using mqtt "<mqtt-v>"

And I subscribe "large_payload_publisher" to "${large_payload_publisher}topic/to/iotcore" with qos 1
When I publish from "large_payload_publisher" to "${large_payload_publisher}topic/to/iotcore" with qos 1 and large message with beginning of "Hello world1" with length 130098
auarbekov marked this conversation as resolved.
Show resolved Hide resolved
Then message beginning with "Hello world1" and with length 130098 received on "large_payload_publisher" from "${large_payload_publisher}topic/to/iotcore" topic within 10 seconds

@mqtt3 @sdk-java
Examples:
| mqtt-v | name | agent | recipe |
| v3 | sdk-java | aws.greengrass.client.Mqtt5JavaSdkClient | client_java_sdk.yaml |

@mqtt3 @mosquitto-c @SkipOnWindows
Examples:
| mqtt-v | name | agent | recipe |
| v3 | mosquitto-c | aws.greengrass.client.MqttMosquittoClient | client_mosquitto_c.yaml |

@mqtt3 @paho-java
Examples:
| mqtt-v | name | agent | recipe |
| v3 | paho-java | aws.greengrass.client.Mqtt5JavaPahoClient | client_java_paho.yaml |

@mqtt3 @paho-python @SkipOnWindows
Examples:
| mqtt-v | name | agent | recipe |
| v3 | paho-python | aws.greengrass.client.Mqtt5PythonPahoClient | client_python_paho.yaml |

@mqtt5 @sdk-java
Examples:
| mqtt-v | name | agent | recipe |
| v5 | sdk-java | aws.greengrass.client.Mqtt5JavaSdkClient | client_java_sdk.yaml |

@mqtt5 @mosquitto-c @SkipOnWindows
Examples:
| mqtt-v | name | agent | recipe |
| v5 | mosquitto-c | aws.greengrass.client.MqttMosquittoClient | client_mosquitto_c.yaml |

@mqtt5 @paho-java
Examples:
| mqtt-v | name | agent | recipe |
| v5 | paho-java | aws.greengrass.client.Mqtt5JavaPahoClient | client_java_paho.yaml |

@mqtt5 @paho-python @SkipOnWindows
Examples:
| mqtt-v | name | agent | recipe |
| v5 | paho-python | aws.greengrass.client.Mqtt5PythonPahoClient | client_python_paho.yaml |


@GGMQ-1-T101
Scenario Outline: GGMQ-1-T101-<mqtt-v>-<name>: As a customer, I can use publish retain flag using MQTT V3.1.1
Expand Down