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

Apache License 2.0
2 stars 3 forks source link

feat(uat): added subscribe to java-paho-agent #290

Closed auarbekov closed 1 year ago

auarbekov commented 1 year ago

Issue #, if available: Added subscribe to paho client

Description of changes:

Why is this change necessary:

How was this change tested: run command mvn exec:java in paho-agent module

Test results: Control:

[INFO ] 2023-05-19 21:05:58.116 [grpc-default-executor-0] GRPCDiscoveryServer - RegisterAgent: agentId best-thing-akezhan
[INFO ] 2023-05-19 21:05:58.187 [grpc-default-executor-0] GRPCDiscoveryServer - DiscoveryClient: agentId best-thing-akezhan address 127.0.0.1 port 34815
[INFO ] 2023-05-19 21:05:58.192 [grpc-default-executor-0] EngineControlImpl - Created new agent control for best-thing-akezhan on 127.0.0.1:34815
[INFO ] 2023-05-19 21:05:58.215 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is connected
[INFO ] 2023-05-19 21:05:58.220 [pool-2-thread-1] AgentTestScenario - Playing test scenario for agent id best-thing-akezhan
[INFO ] 2023-05-19 21:06:03.194 [pool-2-thread-1] AgentControlImpl - Created connection with id 1 CONNACK 'sessionPresent: false
receiveMaximum: 100
maximumQoS: 1
retainAvailable: true
maximumPacketSize: 149504
serverKeepAlive: 60
'
[INFO ] 2023-05-19 21:06:03.194 [pool-2-thread-1] AgentControlImpl - createMqttConnection: MQTT connectionId 1 created
[INFO ] 2023-05-19 21:06:03.194 [pool-2-thread-1] AgentTestScenario - MQTT connection with id 1 is established
[INFO ] 2023-05-19 21:06:08.201 [pool-2-thread-1] AgentControlImpl - SubscribeMqtt: subscribe on connection 1
[INFO ] 2023-05-19 21:06:08.372 [pool-2-thread-1] AgentTestScenario - Subscribe response: connectionId 1 reason codes [0] reason string ''
[INFO ] 2023-05-19 21:06:13.389 [pool-2-thread-1] AgentControlImpl - PublishMqtt: publishing on connectionId 1 topic test/topic
[ERROR] 2023-05-19 21:06:13.414 [pool-2-thread-1] AgentTestScenario - gRPC error code UNIMPLEMENTED: description: Method ClientControl.MqttClientControl/PublishMqtt is unimplemented
io.grpc.StatusRuntimeException: UNIMPLEMENTED: Method ClientControl.MqttClientControl/PublishMqtt is unimplemented
        at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271) ~[grpc-stub-1.53.0.jar:1.53.0]
        at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252) ~[grpc-stub-1.53.0.jar:1.53.0]
        at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165) ~[grpc-stub-1.53.0.jar:1.53.0]
        at com.aws.greengrass.testing.mqtt.client.MqttClientControlGrpc$MqttClientControlBlockingStub.publishMqtt(MqttClientControlGrpc.java:531) ~[classes/:?]
        at com.aws.greengrass.testing.mqtt.client.control.implementation.AgentControlImpl.publishMqtt(AgentControlImpl.java:236) ~[classes/:?]
        at com.aws.greengrass.testing.mqtt.client.control.implementation.ConnectionControlImpl.publishMqtt(ConnectionControlImpl.java:133) ~[classes/:?]
        at com.aws.greengrass.testing.mqtt.client.control.AgentTestScenario.testPublish(AgentTestScenario.java:218) ~[classes/:?]
        at com.aws.greengrass.testing.mqtt.client.control.AgentTestScenario.run(AgentTestScenario.java:150) [classes/:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]
[INFO ] 2023-05-19 21:06:13.547 [pool-2-thread-1] AgentControlImpl - closeMqttConnection: MQTT connectionId 1 closed
[INFO ] 2023-05-19 21:06:13.558 [pool-2-thread-1] AgentControlImpl - shutdown request sent successfully
[INFO ] 2023-05-19 21:06:13.570 [grpc-default-executor-0] GRPCDiscoveryServer - UnregisterAgent: agentId best-thing-akezhan reason Agent shutdown by OTF request 'That's it.'
[INFO ] 2023-05-19 21:06:13.572 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is disconnected

Client:

[INFO ] 2023-05-19 13:55:36.456 [main] GRPCLinkImpl - Making gPRC client connection with 127.0.0.1:47619 as best-thing-akezhan...
[INFO ] 2023-05-19 13:55:37.162 [main] GRPCLinkImpl - Client connection with Control is established, local address is 127.0.0.1
[INFO ] 2023-05-19 13:55:37.195 [main] GRPCControlServer - GRPCControlServer created and listed on 127.0.0.1:35763
[INFO ] 2023-05-19 13:55:37.249 [main] GRPCLinkImpl - Handle gRPC requests
[INFO ] 2023-05-19 13:55:37.249 [main] GRPCControlServer - Server awaitTermination
[INFO ] 2023-05-19 13:55:40.252 [grpc-default-executor-0] GRPCControlServer - createMqttConnection: clientId best-thing-akezhan broker a2rytmonq5cblh-ats.iot.eu-central-1.amazonaws.com:8883
[INFO ] 2023-05-19 13:55:47.221 [grpc-default-executor-0] GRPCControlServer - Subscription: filter test/topic QoS 0 noLocal false retainAsPublished false retainHandling 2
[INFO ] 2023-05-19 13:55:47.221 [grpc-default-executor-0] GRPCControlServer - Subscribe: connectionId 1 subscriptionId null for 1 filters
[INFO ] 2023-05-19 13:55:47.614 [grpc-default-executor-0] GRPCControlServer - Subscribe response: connectionId 1 reason codes [0] reason string 
[INFO ] 2023-05-19 13:55:52.660 [grpc-default-executor-0] GRPCControlServer - closeMqttConnection: connectionId 1 reason 4
[INFO ] 2023-05-19 13:55:52.781 [grpc-default-executor-0] GRPCControlServer - shutdownAgent: reason That's it.
[INFO ] 2023-05-19 13:55:52.792 [main] GRPCControlServer - Server awaitTermination done
[INFO ] 2023-05-19 13:55:52.792 [main] GRPCLinkImpl - Shutdown gPRC link
[INFO ] 2023-05-19 13:55:52.801 [main] Main - Execution done successfully
Disconnected from the target VM, address: '127.0.0.1:46337', transport: 'socket'

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.