aws-greengrass / aws-greengrass-client-device-auth

Apache License 2.0
2 stars 3 forks source link

feat(uat): add message expiry control to java-sdk-client #359

Closed auarbekov closed 1 year ago

auarbekov commented 1 year ago

Issue #, if available: Set message expiry interval for java-sdk-client

Description of changes:

Why is this change necessary: New MQTT v5.0 feature message expiry interval should be handled

How was this change tested: Currently manually by running Control as application with hard-coded scenario. Later by adding new cucumber scenario.

Test results: Control:

2023-07-05 12:10:15.343 [com.aws.greengrass.testing.mqtt.client.control.ExampleControl.main()] EngineControlImpl - MQTT client control gRPC server started, listening on 47619
[INFO ] 2023-07-05 12:10:27.228 [grpc-default-executor-0] GRPCDiscoveryServer - RegisterAgent: agentId best-thing-akezhan
[INFO ] 2023-07-05 12:10:27.330 [grpc-default-executor-0] GRPCDiscoveryServer - DiscoveryClient: agentId best-thing-akezhan address 127.0.0.1 port 46809
[INFO ] 2023-07-05 12:10:27.332 [grpc-default-executor-0] EngineControlImpl - Created new agent control for best-thing-akezhan on 127.0.0.1:46809
[INFO ] 2023-07-05 12:10:27.365 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is connected
[INFO ] 2023-07-05 12:10:27.369 [pool-2-thread-1] AgentTestScenario - Playing test scenario for agent id best-thing-akezhan
[INFO ] 2023-07-05 12:10:30.376 [pool-2-thread-1] AgentTestScenario - Connect Set user property: region, US
[INFO ] 2023-07-05 12:10:30.376 [pool-2-thread-1] AgentTestScenario - Connect Set user property: type, JSON
[INFO ] 2023-07-05 12:10:31.893 [pool-2-thread-1] AgentControlImpl - Created connection with id 1 CONNACK 'sessionPresent: false
reasonCode: 0
receiveMaximum: 100
maximumQoS: 1
retainAvailable: true
maximumPacketSize: 149504
wildcardSubscriptionsAvailable: true
subscriptionIdentifiersAvailable: false
sharedSubscriptionsAvailable: true
serverKeepAlive: 60
'
[INFO ] 2023-07-05 12:10:31.893 [pool-2-thread-1] AgentControlImpl - createMqttConnection: MQTT connectionId 1 created
[INFO ] 2023-07-05 12:10:31.893 [pool-2-thread-1] AgentTestScenario - MQTT connection with id 1 is established
[INFO ] 2023-07-05 12:10:36.895 [pool-2-thread-1] AgentTestScenario - Subscribe Set user property: region, US
[INFO ] 2023-07-05 12:10:36.895 [pool-2-thread-1] AgentTestScenario - Subscribe Set user property: type, JSON
[INFO ] 2023-07-05 12:10:36.896 [pool-2-thread-1] AgentControlImpl - SubscribeMqtt: subscribe on connection 1
[INFO ] 2023-07-05 12:10:37.177 [pool-2-thread-1] AgentTestScenario - Subscribe response: connectionId 1 reason codes [0] reason string ''
[INFO ] 2023-07-05 12:10:47.180 [pool-2-thread-1] AgentTestScenario - Set property payload format indicator true
[INFO ] 2023-07-05 12:10:47.181 [pool-2-thread-1] AgentTestScenario - Set property message expiry interval 3600
[INFO ] 2023-07-05 12:10:47.181 [pool-2-thread-1] AgentTestScenario - Publish Set user property: region, US
[INFO ] 2023-07-05 12:10:47.181 [pool-2-thread-1] AgentTestScenario - Publish Set user property: type, JSON
[INFO ] 2023-07-05 12:10:47.181 [pool-2-thread-1] AgentTestScenario - Set property content type text/plain; charset=utf-8
[INFO ] 2023-07-05 12:10:47.183 [pool-2-thread-1] AgentControlImpl - PublishMqtt: publishing on connectionId 1 topic test/topic
[INFO ] 2023-07-05 12:10:47.399 [pool-2-thread-1] AgentTestScenario - Published connectionId 1 reason code 0 reason string ''
[INFO ] 2023-07-05 12:10:47.408 [grpc-default-executor-0] GRPCDiscoveryServer - OnReceiveMessage: agentId best-thing-akezhan connectionId 1 topic test/topic QoS 0
[INFO ] 2023-07-05 12:10:47.409 [grpc-default-executor-0] AgentTestScenario - Message received on agentId best-thing-akezhan connectionId 1 topic test/topic QoS 0 content <ByteString@647e6974 size=12 contents="Hello World!">
[INFO ] 2023-07-05 12:10:47.409 [grpc-default-executor-0] AgentTestScenario - Message has payload format indicator true
[INFO ] 2023-07-05 12:10:47.410 [grpc-default-executor-0] AgentTestScenario - Message has user property key region value US
[INFO ] 2023-07-05 12:10:47.410 [grpc-default-executor-0] AgentTestScenario - Message has user property key type value JSON
[INFO ] 2023-07-05 12:10:47.410 [grpc-default-executor-0] AgentTestScenario - Message has content type 'text/plain; charset=utf-8'
[INFO ] 2023-07-05 12:10:52.400 [pool-2-thread-1] AgentTestScenario - Unsubscribe Set user property: region, US
[INFO ] 2023-07-05 12:10:52.400 [pool-2-thread-1] AgentTestScenario - Unsubscribe Set user property: type, JSON
[INFO ] 2023-07-05 12:10:52.404 [pool-2-thread-1] AgentControlImpl - UnsubscribeMqtt: unsubscribe on connectionId 1
[INFO ] 2023-07-05 12:10:52.614 [pool-2-thread-1] AgentTestScenario - Unsubscribe response: connectionId 1 reason codes [0] reason string ''
[INFO ] 2023-07-05 12:11:02.614 [pool-2-thread-1] AgentTestScenario - Disconnect Set user property: region, US
[INFO ] 2023-07-05 12:11:02.615 [pool-2-thread-1] AgentTestScenario - Disconnect Set user property: type, JSON
[INFO ] 2023-07-05 12:11:02.645 [grpc-default-executor-0] GRPCDiscoveryServer - OnMqttDisconnect: agentId best-thing-akezhan connectionId 1 disconnect '' error 'Mqtt5 client connection interrupted by user request.'
[INFO ] 2023-07-05 12:11:02.645 [grpc-default-executor-0] AgentTestScenario - MQTT disconnected on agentId best-thing-akezhan connectionId 1 disconnect '' error 'Mqtt5 client connection interrupted by user request.'
[INFO ] 2023-07-05 12:11:02.651 [pool-2-thread-1] AgentControlImpl - closeMqttConnection: MQTT connectionId 1 closed
[INFO ] 2023-07-05 12:11:02.658 [pool-2-thread-1] AgentControlImpl - shutdown request sent successfully
[INFO ] 2023-07-05 12:11:02.668 [grpc-default-executor-0] GRPCDiscoveryServer - UnregisterAgent: agentId best-thing-akezhan reason Agent shutdown by OTF request 'That's it.'
[INFO ] 2023-07-05 12:11:02.669 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is disconnected

java-paho client:

[INFO ] 2023-07-05 12:10:30.454 [grpc-default-executor-0] GRPCControlServer - createMqttConnection: clientId best-thing-akezhan broker a2rytmonq5cblh-ats.iot.eu-central-1.amazonaws.com:8883
[INFO ] 2023-07-05 12:10:30.461 [grpc-default-executor-0] MqttConnectionImpl - Creating Mqtt5Client with TLS
[INFO ] 2023-07-05 12:10:30.608 [grpc-default-executor-0] MqttConnectionImpl - CONNECT MQTT userProperties: region, US
[INFO ] 2023-07-05 12:10:30.608 [grpc-default-executor-0] MqttConnectionImpl - CONNECT MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:10:30.611 [Thread-2] MqttConnectionImpl - MQTT connectionId 1 connecting...
[INFO ] 2023-07-05 12:10:31.826 [Thread-2] MqttConnectionImpl - MQTT connectionId 1 connected, client id best-thing-akezhan
[INFO ] 2023-07-05 12:10:36.905 [grpc-default-executor-0] GRPCControlServer - Subscription: filter test/topic QoS 0 noLocal false retainAsPublished false retainHandling 2
[INFO ] 2023-07-05 12:10:36.905 [grpc-default-executor-0] GRPCControlServer - Subscribe: connectionId 1 subscriptionId null for 1 filters
[INFO ] 2023-07-05 12:10:36.906 [grpc-default-executor-0] MqttConnectionImpl - SUBSCRIBE MQTT userProperties: region, US
[INFO ] 2023-07-05 12:10:36.906 [grpc-default-executor-0] MqttConnectionImpl - SUBSCRIBE MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:10:37.172 [grpc-default-executor-0] GRPCControlServer - Subscribe response: connectionId 1 reason codes [0] reason string null
[INFO ] 2023-07-05 12:10:47.198 [grpc-default-executor-0] GRPCControlServer - Publish: connectionId 1 topic test/topic QoS 1 retain false
[INFO ] 2023-07-05 12:10:47.202 [grpc-default-executor-0] MqttConnectionImpl - TX PUBLISH MQTT userProperties: region, US
[INFO ] 2023-07-05 12:10:47.202 [grpc-default-executor-0] MqttConnectionImpl - TX PUBLISH MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:10:47.202 [grpc-default-executor-0] MqttConnectionImpl - Publish content type: 'text/plain; charset=utf-8'
[INFO ] 2023-07-05 12:10:47.202 [grpc-default-executor-0] MqttConnectionImpl - Publish payload format indicator: true
[INFO ] 2023-07-05 12:10:47.202 [grpc-default-executor-0] MqttConnectionImpl - Publish message expiry interval: 3600
[INFO ] 2023-07-05 12:10:47.391 [Thread-2] MqttConnectionImpl - Received MQTT userProperties: region, US
[INFO ] 2023-07-05 12:10:47.394 [Thread-2] MqttConnectionImpl - Received MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:10:47.395 [Thread-2] MqttConnectionImpl - RX content type: 'text/plain; charset=utf-8'
[INFO ] 2023-07-05 12:10:47.395 [Thread-2] MqttConnectionImpl - RX payload format indicator: true
[INFO ] 2023-07-05 12:10:47.395 [grpc-default-executor-0] GRPCControlServer - Publish response: connectionId 1 reason code 0 reason string null
[INFO ] 2023-07-05 12:10:47.395 [Thread-2] MqttConnectionImpl - RX message expiry interval: 3599
[INFO ] 2023-07-05 12:10:47.397 [Thread-2] MqttConnectionImpl - Received MQTT message: connectionId 1 topic test/topic QoS 0 retain false
[INFO ] 2023-07-05 12:10:52.412 [grpc-default-executor-0] GRPCControlServer - Unsubscribe: connectionId 1 for [test/topic] filters
[INFO ] 2023-07-05 12:10:52.412 [grpc-default-executor-0] MqttConnectionImpl - UNSUBSCRIBE MQTT userProperties: region, US
[INFO ] 2023-07-05 12:10:52.412 [grpc-default-executor-0] MqttConnectionImpl - UNSUBSCRIBE MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:10:52.611 [grpc-default-executor-0] GRPCControlServer - Unsubscribe response: connectionId 1 reason codes [0] reason string null
[INFO ] 2023-07-05 12:11:02.625 [grpc-default-executor-0] GRPCControlServer - closeMqttConnection: connectionId 1 reason 4
[INFO ] 2023-07-05 12:11:02.626 [grpc-default-executor-0] MqttConnectionImpl - TX DISCONNECT MQTT userProperties: region, US
[INFO ] 2023-07-05 12:11:02.626 [grpc-default-executor-0] MqttConnectionImpl - TX DISCONNECT MQTT userProperties: type, JSON
[INFO ] 2023-07-05 12:11:02.629 [Thread-2] MqttConnectionImpl - MQTT connectionId 1 disconnected error 'Mqtt5 client connection interrupted by user request.' disconnectPacket 'null'
[INFO ] 2023-07-05 12:11:02.629 [Thread-2] MqttConnectionImpl - MQTT connectionId 1 stopped
[INFO ] 2023-07-05 12:11:02.655 [grpc-default-executor-0] GRPCControlServer - shutdownAgent: reason That's it.
[INFO ] 2023-07-05 12:11:02.664 [main] GRPCControlServer - Server awaitTermination done
[INFO ] 2023-07-05 12:11:02.664 [main] GRPCLinkImpl - Shutdown gPRC link
[INFO ] 2023-07-05 12:11:02.672 [main] Main - Execution done successfully

Any additional information or context required to review the change:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.