Skip to content

Conversation

@aggarw13
Copy link

Hygiene Changes

  • Upgrade integration tests to use TLS mutual auth. Also, update CMake build for integration tests to use command-line defined CMake variables for credentials.
  • Remove default value of BROKER_ENDPOINT as test.mosquitto.org in demo_config.h files to avoid suggesting use of the public server. (The public Mosquitto server is unreliable as mentioned in their official documentation). Instead use comment blocks to direct customers to setup Mosquitto locally.
  • Fix build warning in mqtt.c from logging call.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2020

Codecov Report

Merging #1128 into development will increase coverage by 2.30%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #1128      +/-   ##
===============================================
+ Coverage        96.54%   98.85%   +2.30%     
===============================================
  Files                9        4       -5     
  Lines             5643     1309    -4334     
  Branches           641      393     -248     
===============================================
- Hits              5448     1294    -4154     
+ Misses               9        0       -9     
+ Partials           186       15     -171     
Impacted Files Coverage Δ
libraries/standard/mqtt/src/mqtt.c 99.48% <ø> (+5.06%) ⬆️
libraries/standard/mqtt/src/mqtt_lightweight.c 97.42% <ø> (+2.90%) ⬆️
libraries/standard/mqtt/src/mqtt_state.c 98.46% <ø> (+2.52%) ⬆️
libraries/standard/http/src/http_client.c 100.00% <100.00%> (+12.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 792032c...0eae5f7. Read the comment docs.

* Instructions to run Mosquitto on Docker container can be viewed in the
* README.md of the root directory.
*
* #define BROKER_ENDPOINT "...insert here..."
Copy link
Contributor

@muneebahmed10 muneebahmed10 Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see value in being able to run the demos quickly without having the change a bunch of demo_config.h files or adding extra cmake flags. If we recommend running a broker locally, why not just change all of these to "localhost" instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether that is necessarily helpful in speeding up the experience of running demos. With localhost, the customer would need to have a broker setup on the same machine. (The customer may very well want to setup their broker on a remote host).
A default value would be more valuable in speeding up the customer experience of running the demo, if the broker is publicly available (as was the case with test.mosquitto.org).
I can instead update the comments to use localhost instead of "...insert here..."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they want to set up a broker on a remote host, that's their choice, just like they were able to choose to not use test.mosquitto.org before this change. Our wording of running the broker "locally" implies that they'd run it on the same machine as the posix demos, so localhost would be an obvious choice for a default.

If we want these demos to not build without editing these files or without specifying a cmake flag, then we don't need to make any changes; I'm just pointing out that making the change would mean one less cmake flag/one less file to edit for someone who is following our instructions on setting up a local broker

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added the default configuration back, as I don't strongly feel against it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the mosquitto broker installed and running by default on a machine? If not, when I run this demo , I will get connection refused error - at which point I need to go and debug why the connection was refused and eventually realize the that I do not have a mosquitto broker setup.

Wouldn't a #error be better telling me that I need to setup mosquitto broker.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree that having the default value of localhost can cause more developer effort in identifying the failure cause. Will remove the default value in a separate PR

@nateglims
Copy link
Member

/bot run checks

@aggarw13
Copy link
Author

Alternate option to what? Seems like the only option we give

Fixed the wording

Archit Aggarwal added 2 commits August 14, 2020 23:31
muneebahmed10
muneebahmed10 previously approved these changes Aug 14, 2020
* This certificate should be PEM-encoded.
*/
#ifndef CLIENT_IDENTIFIER
#define CLIENT_IDENTIFIER "testclient"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this meant to be removed?

Copy link
Author

@aggarw13 aggarw13 Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as this config wasn't used by the integration test. There are separate macros used by the tests


/**
* @brief Length of MQTT server host name.
* @note If using AWS IoT Core, the endpoint can be found in the AWS IoT console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the AWS IoT Core be used for all of our integration tests? Don't we have tests for the retain flag, which AWS IoT doesn't support?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, have removed all comments pointing to use of AWS IoT from the configs

muneebahmed10
muneebahmed10 previously approved these changes Aug 14, 2020
memset( &opensslCredentials, 0u, sizeof( OpensslCredentials_t ) );
opensslCredentials.pRootCaPath = SERVER_ROOT_CA_CERT_PATH;
opensslCredentials.pClientCertPath = CLIENT_CERT_PATH;
opensslCredentials.pPrivateKeyPath = CLIENT_PRIVATE_KEY_PATH;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be here? Do the system tests need mutual auth?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggested to use mutual auth by @abhidixi11. They don't strictly require, but we should run the integration tests on the transport layer that we require for connecting to AWS

if(ROOT_CA_CERT_PATH)
target_compile_definitions(
${stest_name} PRIVATE
SERVER_ROOT_CA_CERT_PATH="${ROOT_CA_CERT_PATH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an absolute path?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is supposed to be provided by the user through CMake configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the CMake configuration command passed by the user.
I don't see much value in pre-pending the absolute path with $PWD as that would pre-pend the path (to the certificate) from where the cmake command is run (which is most likely in the build directory), and can cause unexpected failure to occur due to the path pre-pending. As the CI team will be providing the absolute path to the credential files in their CMake command, I think that suffices.

muneebahmed10
muneebahmed10 previously approved these changes Aug 15, 2020
@nateglims
Copy link
Member

/bot run checks

@aggarw13 aggarw13 merged commit def655c into aws:development Aug 18, 2020
@aggarw13 aggarw13 deleted the hygiene/mqtt-demos-and-tests branch August 18, 2020 18:22
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 27, 2020
* Upgrade MQTT integration test to use mutual auth, and update its build setup to use CMake cache variables for credentials

* Fix build warning from logging

* Remove references to test.mosquitto.org from demos
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 28, 2020
* Upgrade MQTT integration test to use mutual auth, and update its build setup to use CMake cache variables for credentials

* Fix build warning from logging

* Remove references to test.mosquitto.org from demos
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 31, 2020
* Upgrade MQTT integration test to use mutual auth, and update its build setup to use CMake cache variables for credentials

* Fix build warning from logging

* Remove references to test.mosquitto.org from demos
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Sep 1, 2020
* Upgrade MQTT integration test to use mutual auth, and update its build setup to use CMake cache variables for credentials

* Fix build warning from logging

* Remove references to test.mosquitto.org from demos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants