|
| 1 | +# Expected Output for Snap CI Job (`snap-test`) |
| 2 | + |
| 3 | +This document outlines the expected output for the key commands executed in the `snap-test` CI job defined in `ci.yml`. This is intended to help users and developers understand the build and deployment process of the xTeVe snap. |
| 4 | + |
| 5 | +**Note:** The exact output for some commands (like `lxd init` or `snapcraft`) can be verbose and might vary slightly between runner environments or versions. This guide focuses on the key indicators of success. |
| 6 | + |
| 7 | +## 1. Install snapcraft and lxd |
| 8 | + |
| 9 | +Commands: |
| 10 | +``` |
| 11 | +sudo apt-get update |
| 12 | +sudo apt-get install -y qemu-kvm |
| 13 | +sudo snap install snapcraft --classic |
| 14 | +sudo snap install lxd |
| 15 | +``` |
| 16 | + |
| 17 | +Expected output: |
| 18 | +- Standard package installation messages from `apt-get` for `qemu-kvm`. |
| 19 | +- Successful installation messages from `snap` for `snapcraft` and `lxd`. |
| 20 | +- Example snippet (actual output will be much longer): |
| 21 | + ``` |
| 22 | + ... (apt output for qemu-kvm) ... |
| 23 | + snap "snapcraft" installed |
| 24 | + snap "lxd" installed |
| 25 | + ``` |
| 26 | + |
| 27 | +## 2. Configure LXD Group |
| 28 | + |
| 29 | +Commands: |
| 30 | +```bash |
| 31 | +sudo groupadd --system lxd || true |
| 32 | +sudo usermod -a -G lxd $USER || true |
| 33 | +``` |
| 34 | + |
| 35 | +Expected output: |
| 36 | +- These commands typically don't produce output if successful unless the group or user membership is actually changed. |
| 37 | +- `groupadd: group 'lxd' already exists` (if it exists, due to `|| true`) |
| 38 | +- (No output if user is already in group or successfully added, due to `|| true`) |
| 39 | +- A comment in the CI script notes that `sg lxd -c "snapcraft"` handles the new group membership for the build step. |
| 40 | + |
| 41 | +## 3. Initialize LXD |
| 42 | + |
| 43 | +Command: `sudo lxd init --auto` |
| 44 | + |
| 45 | +Expected output: |
| 46 | +- Messages indicating successful LXD initialization. |
| 47 | +- Example snippet: |
| 48 | + ``` |
| 49 | + If you're unsure, go with the defaults. |
| 50 | + Would you like to use LXD clustering? (yes/no) [default=no]: |
| 51 | + Do you want to configure a new storage pool? (yes/no) [default=yes]: |
| 52 | + Name of the new storage pool [default=default]: |
| 53 | + Name of the storage backend to use (btrfs, dir, lvm, zfs) [default=zfs]: dir |
| 54 | + Would you like to connect to a MAAS server? (yes/no) [default=no]: |
| 55 | + Would you like to create a new local network bridge? (yes/no) [default=yes]: |
| 56 | + What should the new bridge be called? [default=lxdbr0]: |
| 57 | + What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: |
| 58 | + What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: |
| 59 | + Would you like LXD to be available over the network? (yes/no) [default=no]: |
| 60 | + Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: |
| 61 | + Would you like a YAML representation of your LXD configuration to be printed? (yes/no) [default=no]: |
| 62 | + ``` |
| 63 | + *(Note: `--auto` might produce less interactive output, but should indicate success)* |
| 64 | + |
| 65 | +## 4. Build the snap |
| 66 | + |
| 67 | +Command: `sudo snapcraft --destructive-mode` |
| 68 | +*(Note: `--destructive-mode` runs the build process directly on the host machine, not within an LXD container.)* |
| 69 | + |
| 70 | +Expected output: |
| 71 | +- `snapcraft` build logs, showing progress. |
| 72 | +- Indication of steps like `pull`, `build`, `stage`, `prime`. |
| 73 | +- A final message indicating successful snap creation. |
| 74 | +- Example snippet of success: |
| 75 | + ``` |
| 76 | + ... |
| 77 | + Snapped <snap-name>_<version>_<arch>.snap |
| 78 | + ``` |
| 79 | + For xTeVe, this would look something like: |
| 80 | + ``` |
| 81 | + Snapped xteve_X.Y.Z_amd64.snap |
| 82 | + ``` |
| 83 | + |
| 84 | +## 5. Install the snap |
| 85 | + |
| 86 | +Command: `sudo snap install --dangerous xteve*.snap` |
| 87 | + |
| 88 | +Expected output: |
| 89 | +- Message indicating the snap was installed. |
| 90 | +- Example: |
| 91 | + ``` |
| 92 | + xteve <version> installed |
| 93 | + ``` |
| 94 | + |
| 95 | +## 6. Check service status and dump logs |
| 96 | + |
| 97 | +Commands: |
| 98 | +```bash |
| 99 | +echo "--- Checking xteve service status ---" |
| 100 | +snap services xteve |
| 101 | +echo "--- Dumping xteve service logs ---" |
| 102 | +sudo snap logs xteve || echo "No logs yet or logs not accessible" |
| 103 | +echo "--- Verifying xteve service is active ---" |
| 104 | +snap services xteve | grep -E "^xteve\.xteve\s+.*active" |
| 105 | +``` |
| 106 | + |
| 107 | +Expected output: |
| 108 | + |
| 109 | +``` |
| 110 | +--- Checking xteve service status --- |
| 111 | +Service Startup Current Notes |
| 112 | +xteve.xteve enabled active - |
| 113 | +
|
| 114 | +--- Dumping xteve service logs --- |
| 115 | +YYYY-MM-DDTHH:MM:SSZ xteve.daemon[PID]: <Log message 1 from xteve> |
| 116 | +YYYY-MM-DDTHH:MM:SSZ xteve.daemon[PID]: <Log message 2 from xteve> |
| 117 | +... (more logs) ... |
| 118 | +
|
| 119 | +--- Verifying xteve service is active --- |
| 120 | +xteve.xteve enabled active - |
| 121 | +``` |
| 122 | + |
| 123 | +- **`snap services xteve`**: Shows the `xteve.xteve` service as `enabled` and `active`. (Note: `snap services <snapname>` lists services associated with the snap, and for xTeVe, the service is `xteve.xteve`). |
| 124 | +- **`sudo snap logs xteve`**: Outputs the logs from the `xteve` snap's services. The exact log content will vary depending on the application's activity. If the service just started, logs might be minimal. The `|| echo "No logs yet or logs not accessible"` part is a fallback in case the logs command fails for some reason. |
| 125 | +- **`snap services xteve | grep -E "^xteve\.xteve\s+.*active"`**: This command is used to programmatically check if the `xteve.xteve` service is active. If it's active, it will print the line containing "xteve.xteve" and "active", and the CI step will pass. If it's not active, `grep` will not find a match and will return a non-zero exit code, causing the CI step to fail. |
| 126 | + |
| 127 | +This documentation should help in understanding the CI process for the xTeVe snap. |
0 commit comments