Skip to content

Commit

Permalink
Charm logging with structured fields (#2449)
Browse files Browse the repository at this point in the history
* experimenting with charm log

* adapting some logs

* fix log func call

* new log output format for execs

* adding uv

* fixing smoke test output matcher

* remove logrus mention

* use uv

* you never know with gh actions

* use uv run

* try activating venv and storing it

* move tests to use uv

remove requirements

* adapted certificate signign log

* bad stuff happened here

* massaged sros logging of scrapli

* more log alignments

* uv in the docs
  • Loading branch information
hellt authored Feb 5, 2025
1 parent d215bdb commit f861ff6
Show file tree
Hide file tree
Showing 122 changed files with 687 additions and 251 deletions.
82 changes: 67 additions & 15 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,31 @@ jobs:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -227,14 +244,31 @@ jobs:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -290,14 +324,30 @@ jobs:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Run keysight_ixia-c-one tests
run: |
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/04-basic-ixiacone
Expand Down Expand Up @@ -449,6 +499,8 @@ jobs:
- ext-container-tests
- vxlan-tests
- kind-tests
- cisco_iol-tests
- fortigate-tests
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/cisco_iol-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,29 @@ jobs:
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/fortigate-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,29 @@ jobs:
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/kind-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,29 @@ jobs:
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,33 @@ jobs:
if: matrix.runtime == 'podman'
run: sudo bash ./.github/workflows/install-podman.sh

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install robotframework
run: |
pip install -r tests/requirements.txt
- name: Install the project
run: uv sync --all-extras --dev

- name: Sanitize test-suite name
run: echo "TEST_SUITE=$(echo ${{ matrix.test-suite }} | tr -d '*')" >> $GITHUB_ENV

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Activate virtualenv
run: |
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Run smoke tests
run: |
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/01-smoke/${{ matrix.test-suite }}
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/srlinux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,29 @@ jobs:
# for available podman releases
run: sudo bash ./.github/workflows/install-podman.sh

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Sanitize test-suite name
run: echo "TEST_SUITE=$(echo ${{ matrix.test-suite }} | tr -d '*')" >> $GITHUB_ENV
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/sros-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,29 @@ jobs:
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Sanitize test-suite name
run: echo "TEST_SUITE=$(echo ${{ matrix.test-suite }} | tr -d '*')" >> $GITHUB_ENV
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/vxlan-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,29 @@ jobs:
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chown root:root /usr/bin/containerlab && sudo chmod 4755 /usr/bin/containerlab

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.28"
enable-cache: true

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_ver }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
# cache: pip
# cache-dependency-path: "tests/requirements.txt"
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras --dev

# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Install robotframework
- name: Activate virtualenv
run: |
pip install -r tests/requirements.txt
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion cert/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

log "github.com/sirupsen/logrus"
"github.com/charmbracelet/log"
"github.com/srl-labs/containerlab/utils"
)

Expand Down
2 changes: 1 addition & 1 deletion clab/authz_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"path/filepath"
"strings"

log "github.com/sirupsen/logrus"
"github.com/charmbracelet/log"
"github.com/srl-labs/containerlab/utils"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
Expand Down
Loading

0 comments on commit f861ff6

Please sign in to comment.