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

Apache License 2.0
2 stars 3 forks source link

feat(uat): implement python paho client startup and connect #317

Closed eschastlivtsev closed 1 year ago

eschastlivtsev commented 1 year ago

Description of changes:

Why is this change necessary:

How was this change tested: Manual run of mqtt-client-control and python client. MQTT connect is successful, other commands are not implemented. Linking and shutdown steps are successful.

Test results: Python Paho client output

client-python-paho.exe paho-python-agent
asyncio: [DEBUG] Using selector: SelectSelector
GRPCLib: [INFO] Initialize gRPC library
GRPCLink: [INFO] Making gPRC client connection with 127.0.0.1:47619 as paho-python-agent...
GRPCLink: [INFO] Client connection with Control is established, local address is 127.0.0.1
grpc._cython.cygrpc: [DEBUG] Using AsyncIOEngine.POLLER as I/O engine
MQTTLib: [INFO] Initialize Paho MQTT library
GRPCLink: [INFO] Handle gRPC requests
GRPCControlServer: [INFO] Server awaiting termination
GRPCControlServer: [INFO] createMqttConnection: clientId Python_Paho_Client broker a3t8vwpkw3sltg-ats.iot.eu-west-1.amazonaws.com:8883
GRPCControlServer: [INFO] SubscribeMqtt Placeholder TODO
GRPCControlServer: [INFO] PublishMqtt Placeholder TODO
GRPCControlServer: [INFO] UnsubscribeRequest Placeholder TODO
GRPCControlServer: [INFO] CloseMqttConnection Placeholder TODO
GRPCControlServer: [INFO] shutdownAgent: reason That's it.
GRPCControlServer: [INFO] Server termination done
GRPCLink: [INFO] Shutdown gPRC link
Main: [INFO] Execution done successfully

Mqtt Client Control output

java -Dmqtt_client_id=Python_Paho_Client -Dmqtt_broker_addr=a3t8vwpkw3sltg-ats.iot.eu-west-1.amazonaws.com -Dmqtt_client_ca_file=creds_aws/rootCA.pem -Dmqtt_client_cert_file=creds_aws/thingCert.crt -Dmqtt_client_key_file=creds_aws/privKey.key -jar target/aws-greengrass-testing-mqtt-client-control.jar 47619 true true
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
[INFO ] 2023-06-15 13:22:40.037 [main] EngineControlImpl - MQTT client control gRPC server started, listening on 47619
[INFO ] 2023-06-15 13:23:10.482 [grpc-default-executor-0] GRPCDiscoveryServer - RegisterAgent: agentId paho-python-agent
[INFO ] 2023-06-15 13:23:10.512 [grpc-default-executor-0] GRPCDiscoveryServer - DiscoveryClient: agentId paho-python-agent address 127.0.0.1 port 53494
[INFO ] 2023-06-15 13:23:10.518 [grpc-default-executor-0] EngineControlImpl - Created new agent control for paho-python-agent on 127.0.0.1:53494
[INFO ] 2023-06-15 13:23:10.586 [grpc-default-executor-0] ExampleControl - Agent paho-python-agent is connected
[INFO ] 2023-06-15 13:23:10.597 [pool-2-thread-1] AgentTestScenario - Playing test scenario for agent id paho-python-agent
[INFO ] 2023-06-15 13:23:15.724 [pool-2-thread-1] AgentControlImpl - Created connection with id 0 CONNACK 'sessionPresent: false
reasonCode: 0
maximumQoS: 1
retainAvailable: true
maximumPacketSize: 149504
wildcardSubscriptionsAvailable: true
subscriptionIdentifiersAvailable: false
sharedSubscriptionsAvailable: true
serverKeepAlive: 60
'
[INFO ] 2023-06-15 13:23:15.726 [pool-2-thread-1] AgentControlImpl - createMqttConnection: MQTT connectionId 0 created
[INFO ] 2023-06-15 13:23:15.732 [pool-2-thread-1] AgentTestScenario - MQTT connection with id 0 is established
[INFO ] 2023-06-15 13:23:20.737 [pool-2-thread-1] AgentControlImpl - SubscribeMqtt: subscribe on connection 0
[INFO ] 2023-06-15 13:23:20.744 [pool-2-thread-1] AgentTestScenario - Subscribe response: connectionId 0 reason codes [] reason string ''
[INFO ] 2023-06-15 13:23:25.749 [pool-2-thread-1] AgentControlImpl - PublishMqtt: publishing on connectionId 0 topic test/topic
[INFO ] 2023-06-15 13:23:25.758 [pool-2-thread-1] AgentTestScenario - Published connectionId 0 reason code 0 reason string ''
[INFO ] 2023-06-15 13:23:30.762 [pool-2-thread-1] AgentControlImpl - UnsubscribeMqtt: unsubscribe on connectionId 0
[INFO ] 2023-06-15 13:23:30.769 [pool-2-thread-1] AgentTestScenario - Unsubscribe response: connectionId 0 reason codes [] reason string ''
[INFO ] 2023-06-15 13:23:45.775 [pool-2-thread-1] AgentControlImpl - closeMqttConnection: MQTT connectionId 0 closed
[INFO ] 2023-06-15 13:23:45.784 [pool-2-thread-1] AgentControlImpl - shutdown request sent successfully
[INFO ] 2023-06-15 13:23:45.790 [grpc-default-executor-0] GRPCDiscoveryServer - UnregisterAgent: agentId paho-python-agent reason Agent shutdown by OTF request 'That's it.'
[INFO ] 2023-06-15 13:23:45.794 [grpc-default-executor-0] ExampleControl - Agent paho-python-agent is disconnected

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.