Skip to content

Commit

Permalink
Update for 24.3 SR Linux and ansible 2.15, 2.16, 2.17 (#26)
Browse files Browse the repository at this point in the history
* bump srl version

* update clab, srl version and remove oc tests for now

* bump netcommon dep to 6.1.3 and retire ansible core older than 2.14

* pin ansible utils

* remove <2.14 versions form ansible sanity

* added pyenv

* fix gnmi server for 24.3

* exclude oc test

* update golden and templated config

* add 30s sleep timer for ci

* remove timer as it doesn't fix shit =(

* added pre-test sleep and dump logs

* move tests after the lab deployment

* trying debumping utils

* trying debump on netcommon

* continue on error

* bring back deps to modern versions and set clab to 0.55.1

* add inputs to start tmate before or after session

* added 2.16 and 2.17 to test and build matrixes

* bump checkout action

* remove contrinue on error as it was masking the errors

* update sanity test setup

* remove py2 dep on certificate error

* bring back import before doc exception

* update skip modules

* ignore compile on srl module

* relax collection deps to a range

* update setup python step
  • Loading branch information
hellt authored Jun 22, 2024
1 parent b697e64 commit 3f30c83
Show file tree
Hide file tree
Showing 19 changed files with 3,019 additions and 1,586 deletions.
38 changes: 31 additions & 7 deletions .github/container-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,49 @@
# SPDX-License-Identifier: BSD-3-Clause

# a matrix list of variables used in the container build process
# it is used to define what ansible core images that define both ansible core and the python interpreter
# are going to be used in the container build process for the collection.
#
# python version are taken from ansible's support matrix - https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#support-life
# ansible-core-image version is taken from https://github.com/orgs/srl-labs/packages?repo_name=ansible-core
include:
# 2.14.11
- ansible-core-image: "2.14.11:pypy3.10"
# 2.14
- ansible-core-image: "2.14.17:pypy3.10"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.14.11:py3.11"
- ansible-core-image: "2.14.17:py3.11"
runs-on: "ubuntu-22.04"
addional-tags: "latest"

# 2.15.5
- ansible-core-image: "2.15.5:pypy3.10"
# 2.15
- ansible-core-image: "2.15.12:pypy3.10"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.15.5:py3.11"
- ansible-core-image: "2.15.12:py3.11"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.15.12:py3.12"
runs-on: "ubuntu-22.04"
addional-tags: "latest"

# 2.16
- ansible-core-image: "2.16.8:pypy3.10"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.16.8:py3.11"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.16.8:py3.12"
runs-on: "ubuntu-22.04"
addional-tags: "latest"

- ansible-core-image: "2.15.5:py3.12"
# 2.17
- ansible-core-image: "2.17.1:pypy3.10"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.17.1:py3.11"
runs-on: "ubuntu-22.04"

- ansible-core-image: "2.17.1:py3.12"
runs-on: "ubuntu-22.04"
addional-tags: "latest"
62 changes: 25 additions & 37 deletions .github/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,67 @@
# SPDX-License-Identifier: BSD-3-Clause

# a matrix list of variables used in testing
# kind of a manual way of creating a testing matrix with a flexibility of selecting permuatations
# kind of a manual way of creating a testing matrix with a flexibility of selecting permutations
# support matrix for ansible control node - https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#node-requirement-summary

include:
####################
# Python 3.8
####################
- &latest-2_12
ansible-core-version: "2.12.10"
runs-on: "ubuntu-22.04"
python-version: "3.8"

- &latest-2_13
ansible-core-version: "2.13.13"
runs-on: "ubuntu-22.04"
python-version: "3.8"

####################
# Python 3.9
####################
- <<: *latest-2_12
python-version: "3.9"

- <<: *latest-2_13
python-version: "3.9"

- &latest-2_14
ansible-core-version: "2.14.11"
ansible-core-version: "2.14.17"
runs-on: "ubuntu-22.04"
python-version: "3.9"

- &latest-2_15
ansible-core-version: "2.15.5"
ansible-core-version: "2.15.12"
runs-on: "ubuntu-22.04"
python-version: "3.9"

####################
# Python 3.10
####################

# removing 2_12 and 2_13 because TLS tests are failing
# this doesn't make the collection unusable with these versions
# when 23.10 comes out with TLS 1.3 we will remove these checks and bring back 2_12 and 2_13
# - <<: *latest-2_12
# python-version: "3.10"

# - <<: *latest-2_13
# python-version: "3.10"

- <<: *latest-2_14
python-version: "3.10"

- <<: *latest-2_15
python-version: "3.10"

- &latest-2_16
ansible-core-version: "2.16.8"
runs-on: "ubuntu-22.04"
python-version: "3.10"

- &latest-2_17
ansible-core-version: "2.17.1"
runs-on: "ubuntu-22.04"
python-version: "3.10"

####################
# Python 3.11
####################

# - <<: *latest-2_12
# python-version: "3.11"

# - <<: *latest-2_13
# python-version: "3.11"

- <<: *latest-2_14
python-version: "3.11"

- <<: *latest-2_15
python-version: "3.11"

- <<: *latest-2_16
python-version: "3.11"

- <<: *latest-2_17
python-version: "3.11"

####################
# Python 3.12
####################
- <<: *latest-2_15
python-version: "3.12"

- <<: *latest-2_16
python-version: "3.12"

- <<: *latest-2_17
python-version: "3.12"
40 changes: 26 additions & 14 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ name: CICD
srlinux-version:
description: "SR Linux version"
required: true
default: "23.3.2"
start-tmate:
default: "24.3.2"
start-tmate-before-test:
description: "start tmate before running tests"
type: boolean
required: false
default: false
start-tmate-after-test:
description: "start tmate after running tests"
type: boolean
required: false
default: false
pull_request:
push:
tags:
Expand All @@ -27,7 +32,7 @@ jobs:
outputs:
matrix: ${{ steps.matrix.outputs.output }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: fabasoad/data-format-converter-action@main
id: matrix
with:
Expand All @@ -37,7 +42,8 @@ jobs:

test:
runs-on: ${{ matrix.runs-on }}
needs: [prepare-matrix]
needs:
- prepare-matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
Expand All @@ -47,41 +53,47 @@ jobs:
run: |
echo "SRLINUX_VERSION=${{ inputs.srlinux-version }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install ansible core
run: pip install ansible-core==${{ matrix.ansible-core-version }}

- name: start tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.start-tmate-before-test }}

# Uncomment this section to use private images
# - name: ghcr.io login
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Test
run: ./run.sh ci-test
# uncomment this line when you want to continue on error
# and run tmate after it
# continue-on-error: true

- name: start tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.start-tmate }}

- name: Test
run: ./run.sh ci-test
if: ${{ inputs.start-tmate-after-test }}

ansible-sanity-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11

- name: Install ansible core
run: pip install ansible-core==2.13.8
run: pip install ansible-core==2.15.12

- name: Ansible sanity test
run: ./run.sh sanity-test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
3 changes: 2 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ tags:
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
# range specifiers can be set and are separated by ','
dependencies:
"ansible.netcommon": ">=5.2.0"
"ansible.netcommon": ">=5.2.0,<=6.1.3"
"ansible.utils": ">=3.0.0,<5.0.0"

# The URL of the originating SCM repository
repository: https://github.com/nokia/srlinux-ansible-collection
Expand Down
8 changes: 2 additions & 6 deletions plugins/module_utils/srlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

""" srlinux module utils """
"""srlinux module utils"""
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function
Expand All @@ -13,7 +13,6 @@

from ansible.module_utils._text import to_text
from ansible.module_utils.connection import Connection
from ansible.module_utils.urls import CertificateError


class JSONRPCClient:
Expand Down Expand Up @@ -47,10 +46,7 @@ def _httpapi_error_handle(self, method="POST", path="/jsonrpc", payload=None):
self.module.fail_json(
msg=f"connection error occurred: {e}",
)
except CertificateError as e:
self.module.fail_json(
msg=f"certificate error occurred: {e}",
)

except ValueError as e:
try:
self.module.fail_json(msg=f"certificate not found: {e}")
Expand Down
46 changes: 30 additions & 16 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ SCRIPTS_DIR="scripts"
# Directory where the tests are located.
TESTS_DIR="$(pwd)/tests"

# Containerlab version to use in CI tests
CLAB_VERSION="0.55.1"

# -----------------------------------------------------------------------------
# Helper functions start with _ and aren't listed in this script's help menu.
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -57,10 +60,6 @@ function remove-local-collection {
rm -rf ~/.ansible/collections/ansible_collections/nokia
}

# Install a netcommon dependency in case ansible-core is installed.
function install-netcommon {
ansible-galaxy collection install --force ansible.netcommon:==4.1.0
}

# Deploy test lab.
function deploy-lab {
Expand All @@ -87,14 +86,7 @@ function revert-to-checkpoint {
docker exec ${NODE_NAME} sr_cli /tools system configuration checkpoint initial revert
}

# copy sanity ignore files from ignore-2.10.txt to all other supported ansible versions
function copy-sanity-ignore {
_cdTests
cd sanity
for version in 2.11 2.12 2.13 2.14; do
cp ignore-2.10.txt ignore-${version}.txt
done
}


# -----------------------------------------------------------------------------
# Test functions.
Expand Down Expand Up @@ -297,9 +289,12 @@ function _run-tests {
test-commit-confirm "$@"

# OC-related tests
test-get-oc-container "$@"
test-set-oc-leaf "$@"
test-oc-validate "$@"
if [[ " $* " == *" oc-tests "* ]]; then
# OC-related tests
test-get-oc-container "$@"
test-set-oc-leaf "$@"
test-oc-validate "$@"
fi
}

# prepare local dev environment and run tests
Expand All @@ -311,18 +306,37 @@ function test {
_run-tests "$@"
}

function dump-logs {
ansible-galaxy collection list
echo
pip list
python --version
}

# ci-test is a wrapper for testing in CI which first setups the environment.
function ci-test {
install-containerlab 0.48.6
install-containerlab ${CLAB_VERSION}
install-local-collection
deploy-lab

dump-logs


# at this point we are already in ./tests dir
# since we changed into it in deploy-lab
# we use ci-ansible.cfg to make sure default collections paths is used
ANSIBLE_CONFIG=ci-ansible.cfg _run-tests "$@"
}

# copy sanity ignore files from ignore-2.10.txt to all other supported ansible versions
function copy-sanity-ignore {
_cdTests
cd sanity
for version in 2.14 2.15 2.16 2.17; do
cp ignore-2.10.txt ignore-${version}.txt
done
}

# sanity-test runs ansible-test tool with sanity checks.
function sanity-test {
install-local-collection
Expand Down
Loading

0 comments on commit 3f30c83

Please sign in to comment.