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

python/iot3: add bootstrap #250

Merged

Conversation

ymorin-orange
Copy link
Member

@ymorin-orange ymorin-orange commented Dec 16, 2024

Features:


Preparation:

  1. Start a bootstrap manager
    • edit python/iot3/tests/test-iot3-core-bootstrap and python/iot3/tests/test-iot3-mobility-bootstrap with the details of your bootstrap manager, notably the host, port, endpoint, credentials...
  2. if you do not have python 3.11 or later, you can use the following to create a container to run all the tests:
    • start a container with python 3.11:
      $ docker container run \
          --detach \
          --name iot3 \
          --rm \
          -ti \
          --network host \
          -e http_proxy \
          -e https_proxy \
          -e no_proxy \
          --user $(id -u):$(id -u) \
          --mount type=bind,source=$(pwd),destination=$(pwd) \
          --workdir $(pwd) \
          python:3.11.9-slim-bookworm \
          /bin/bash -il
    • install the necessary packages:
      $ docker container exec -u 0:0 iot3 apt update
      $ docker container exec -u 0:0 iot3 apt install -y git build-essential
    • attach to the container:
      $ docker container attach iot3

How to test:

  1. Create and activate a virtual-env to run the tests:
    [python-3.11] $ python3.11 -m venv /tmp/iot3
    [python-3.11] $ . /tmp/iot3/bin/activate
    
  2. Install the IoT3 SDK:
    🐍 $ pip install python/iot3
  3. Run the IoT3 SDK bootstrap test-suite:
    🐍 $ python/iot3/tests/test-iot3-core-bootstrap
    🐍 $ python/iot3/tests/test-iot3-mobility-bootstrap

Expected results:

  1. A python venv is created and activated
  2. The IoT3 SDK is isntalled succesfully
  3. The tests succeed; no error is reported by the test-suite:
    • core reply:
      {
        "mqtt": {
          "client_id": "some-prefix_1234abcd",
          "host": "some-host",
          "password": "some-password",
          "port": 1234,
          "tls": true,
          "username": "some-login"
        },
        "otel": {
          "auth": "basic",
          "batch_period": 5,
          "compression": "gzip",
          "endpoint": "https://some-host:443/telemetry",
          "max_backlog": 100,
          "password": "some-password",
          "service_name": "my-service",
          "username": "some-login"
        }
      }
    • mobility reply:
      {
        "mqtt": {
          "client_id": "some-prefix_1234abcd",
          "host": "some-host",
          "password": "some-password",
          "port": 1234,
          "tls": true,
          "username": "some-login"
        },
        "namespace": "default",
        "otel": {
          "auth": "basic",
          "batch_period": 5,
          "compression": "gzip",
          "endpoint": "https://some-host:443/telemetry",
          "max_backlog": 100,
          "password": "some-password",
          "service_name": "my-service",
          "username": "some-login"
        },
        "report_depth": 22,
        "roi_depth": 15,
        "station_type": 0,
        "uuid": "some-prefix_1234abcd"
      }

@ymorin-orange ymorin-orange requested review from nbuffon and removed request for nbuffon December 16, 2024 16:03
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
@ymorin-orange ymorin-orange force-pushed the nyma/gh-186.bootstrap branch 2 times, most recently from 27d97a5 to 3b3dc3a Compare January 6, 2025 08:48
@ymorin-orange ymorin-orange marked this pull request as ready for review January 6, 2025 09:15
@Hugues360
Copy link
Collaborator

A little typing error in "bootstrap" in commit dba89fe title

@Hugues360
Copy link
Collaborator

To have the expected result 3, I think we have to add something like

pprint(config)

at the end of the file tests.
It is what I did and I could check that the expected result 3. Tests are Ok with this addition.

Copy link
Collaborator

@Hugues360 Hugues360 left a comment

Choose a reason for hiding this comment

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

Code and tests are Ok for me.
Just a commit title to fix and a line to add in test files (or changing the expected result 3 to check)

@ymorin-orange ymorin-orange force-pushed the nyma/gh-186.bootstrap branch from 3b3dc3a to 6f586b1 Compare January 7, 2025 17:21
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
@ymorin-orange ymorin-orange force-pushed the nyma/gh-186.bootstrap branch from 6f586b1 to 7cdc7c4 Compare January 7, 2025 17:21
@ymorin-orange
Copy link
Member Author

To have the expected result 3, I think we have to add something like

pprint(config)

Gah, I forgot to push... :-/ There, it is in now...

(the output is JSON, not what print(config) would have printed).

@Hugues360
Copy link
Collaborator

To have the expected result 3, I think we have to add something like

pprint(config)

Gah, I forgot to push... :-/ There, it is in now...

(the output is JSON, not what print(config) would have printed).

Yes it is why I suggested 'pprint' not 'print'

@Hugues360
Copy link
Collaborator

Sorry a very little wording in a commit message I have not seen yesterday: in last commit: 'acutal' vs 'actual'

Copy link
Collaborator

@Hugues360 Hugues360 left a comment

Choose a reason for hiding this comment

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

Very little wording in a commit message

@ymorin-orange
Copy link
Member Author

ymorin-orange commented Jan 8, 2025

To have the expected result 3, I think we have to add something like

pprint(config)

Gah, I forgot to push... :-/ There, it is in now...
(the output is JSON, not what print(config) would have printed).

Yes it is why I suggested 'pprint' not 'print'

>>> pprint(config)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'pprint' is not defined. Did you mean: 'print'?

(it needs pprint to be imported, yeah... I prefer explicit json.)

We introduce a plain, basic test that just verifies that the bootstrap()
method returns an object with the expected fields. Doing a complete test
would require a stable bootstrap server that returns actual connection
details, not the stub we currently have available...

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
@ymorin-orange ymorin-orange merged commit 4ef72ea into Orange-OpenSource:master Jan 8, 2025
58 checks passed
@ymorin-orange ymorin-orange deleted the nyma/gh-186.bootstrap branch January 8, 2025 09:40
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.

Get connection information through bootstrap sequence
2 participants