|
3 | 3 | This folder contains the container definition which is used within the integration tests (when using the `docker` device test adapter). The image provides a `systemd` enabled multi-process container so that it can simulate a real device as much as possible.
|
4 | 4 |
|
5 | 5 | To enable `systemd` inside the container, the container needs to be launched with elevated privileges, something that is not so "normal" in the container world. For this reason, it is recommended that this image only be used for development and testing purposes and to run on a machine that is not publicly accessible (or running in a sufficiently sand-boxed environment).
|
6 |
| - |
7 |
| - |
8 |
| -## Creating a test device |
9 |
| - |
10 |
| -The image can be easily built by using the following steps |
11 |
| - |
12 |
| -1. Open a terminal and browse to the project root folder, then change directory to `tests/images/debian-systemd` |
13 |
| - |
14 |
| - ```sh |
15 |
| - cd tests/images/debian-systemd |
16 |
| - ``` |
17 |
| - |
18 |
| -2. Create a `.env` file (in the `tests/images/debian-systemd` directory) with the following contents |
19 |
| - |
20 |
| - ``` |
21 |
| - touch .env |
22 |
| - ``` |
23 |
| - |
24 |
| - **Contents** |
25 |
| - |
26 |
| - ```sh |
27 |
| - DEVICE_ID=my-tedge-01 |
28 |
| - C8Y_BASEURL=mytenant.cumulocity.com |
29 |
| - C8Y_USER=myusername@something.com |
30 |
| - C8Y_PASSWORD="mypassword" |
31 |
| - ``` |
32 |
| - |
33 |
| -3. Start the container using docker compose |
34 |
| - |
35 |
| - ```sh |
36 |
| - docker compose up -d --build |
37 |
| - ``` |
38 |
| - |
39 |
| - **Note** |
40 |
| - |
41 |
| - This example uses the newer docker compose plugin (v2) and not the older python `docker-compose` variant. |
42 |
| - |
43 |
| -4. Bootstrap the device (there is a special `bootstrap.sh` script inside the image which looks after most things for you) |
44 |
| - |
45 |
| - ```sh |
46 |
| - docker compose exec -it tedge ./bootstrap.sh |
47 |
| - ``` |
48 |
| - |
49 |
| - This will install the latest official thin-edge.io version, and connect your device to Cumulocity (using the credentials provided in the .env file) |
50 |
| - |
51 |
| - **Note** |
52 |
| - |
53 |
| - If you would like to use a randomly generated device id, then you can use: |
54 |
| - |
55 |
| - ```sh |
56 |
| - docker compose exec -it tedge ./bootstrap.sh --use-random-id |
57 |
| - ``` |
58 |
| - |
59 |
| -5. If you want to open a shell inside the container run: |
60 |
| - |
61 |
| - ``` |
62 |
| - docker compose exec -it tedge bash |
63 |
| - ``` |
64 |
| - |
65 |
| - Then check if the `tedge-mapper-c8y` is working properly |
66 |
| - |
67 |
| - ``` |
68 |
| - systemctl status tedge-mapper-c8y |
69 |
| - ``` |
70 |
| - |
71 |
| -## Stopping the test device |
72 |
| - |
73 |
| -The test device can be stopped using: |
74 |
| - |
75 |
| -```sh |
76 |
| -docker compose down |
77 |
| -``` |
78 |
| - |
79 |
| -If you would also like to remove the volumes (where the device certificate is persisted), then use: |
80 |
| - |
81 |
| -```sh |
82 |
| -docker compose down --volumes |
83 |
| -``` |
84 |
| - |
0 commit comments