Skip to content

Commit

Permalink
Merge branch 'main' into test-pr-tnf-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
shirmoran authored Oct 26, 2023
2 parents 07992a8 + ea83f4a commit 6255351
Show file tree
Hide file tree
Showing 23 changed files with 1,740 additions and 248 deletions.
2 changes: 2 additions & 0 deletions .checkmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[maxbodylength]
disabled = true
118 changes: 38 additions & 80 deletions .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ env:

jobs:
lint:
name: Run Linter and Vet
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-latest]
name: Run Linters and Vet
runs-on: ubuntu-latest
env:
SHELL: /bin/bash

Expand All @@ -59,84 +56,50 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

# TODO: golangci-lint team recommends using a GitHub Action to perform golangci-lint responsibilities. However
# there does not appear to be a way to honor our existing .golangci.yml. For now, mimic developer behavior.
- name: Install golangci-lint
run: make install-lint

- name: Install checkmake (Linux)
run: curl --location --output $CM_BIN --silent $CM_URL_LINUX
if: runner.os == 'Linux'

- name: Install checkmake (MacOS)
run: brew install checkmake
if: runner.os == 'macOS'

- run: chmod +x $CM_BIN
if: runner.os == 'Linux'

- name: Install hadolint (Linux)
run: |
curl \
--location \
--output /usr/local/bin/hadolint \
https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
chmod +x /usr/local/bin/hadolint
if: runner.os == 'Linux'

- name: Install hadolint (MacOS)
- name: Install checkmake
run: |
brew install hadolint
if: runner.os == 'macOS'
curl --location --output $CM_BIN --silent $CM_URL_LINUX
chmod +x $CM_BIN
- name: Install shfmt (Linux)
run: make install-shfmt
if: runner.os == 'Linux'
- name: Install Shfmt
uses: mfinelli/setup-shfmt@v3

- name: Install shfmt (MacOS)
run: brew install shfmt
if: runner.os == 'macOS'
- name: Golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout 10m0s

- name: make lint
run: make lint
- name: Checkmake
run: checkmake --config=.checkmake Makefile

- name: make vet
run: make vet
action-linters:
name: Checkmake, hadolint, markdownlint, shellcheck, shfmt, typos, yamllint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: |
curl --location --output $CM_BIN --silent $CM_URL_LINUX
chmod +x $CM_BIN
$CM_BIN Makefile
- uses: hadolint/[email protected]
- name: Hadolint
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
recursive: true
- uses: nosborn/[email protected]

- name: Shfmt
run: shfmt -d *.sh script

- name: Markdownlint
uses: nosborn/[email protected]
with:
files: .
ignore_files: cmd/tnf/generate/catalog/{INTRO,TEST_CASE_CATALOG}.md
- uses: ludeeus/action-shellcheck@master
- uses: mfinelli/setup-shfmt@v3
- run: shfmt -d *.sh script
- uses: crate-ci/typos@master
- uses: ibiqlik/action-yamllint@v3
with:
config_data: |
extends: default
rules:
line-length:
max: 180
level: warning
trailing-spaces:
level: warning
brackets:
level: warning
empty-lines:
level: warning

- name: ShellCheck
uses: ludeeus/action-shellcheck@master

- name: Typos
uses: crate-ci/typos@master

- name: Yamllint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yml

- name: Go vet
run: make vet
unit-tests:
name: Run Unit Tests
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -376,7 +339,7 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: 1.21.2
# Prepare collector to be used when running smoke tests
- name: Check out `Collector`
uses: actions/checkout@v4
with:
Expand All @@ -387,11 +350,6 @@ jobs:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Deploy collector and mysql
uses: ./collector/.github/actions/prepare-collector-for-use
with:
working_directory: collector

# Perform smoke tests using a TNF container.
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down Expand Up @@ -430,7 +388,7 @@ jobs:
- name: 'Test: Run Smoke Tests in a TNF container'
run: TNF_LOG_LEVEL=${TNF_SMOKE_TESTS_LOG_LEVEL} TNF_ENABLE_DATA_COLLECTION=true ./run-tnf-container.sh ${{ env.TESTING_CMD_PARAMS }} -l "${SMOKE_TESTS_GINKGO_LABELS_FILTER}"

# Perform tests on collector
# Prepare collector to be used when running smoke tests
- name: Check out `Collector`
uses: actions/checkout@v4
with:
Expand Down
12 changes: 12 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends: default
rules:
line-length:
max: 180
level: warning
trailing-spaces:
level: warning
brackets:
level: warning
empty-lines:
level: warning
no_warnings: true
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/ubi:8.8-1067.1696517599 AS build
FROM registry.access.redhat.com/ubi8/ubi:8.8-1067.1698056881 AS build
ENV TNF_DIR=/usr/tnf
ENV \
TNF_SRC_DIR=${TNF_DIR}/tnf-src \
Expand Down Expand Up @@ -99,7 +99,7 @@ FROM quay.io/testnetworkfunction/oct:latest AS db

# Copy the state into a new flattened image to reduce size.
# TODO run as non-root
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8-1072.1696517598
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8-1072.1697626218

ENV \
TNF_DIR=/usr/tnf \
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ LINKER_TNF_RELEASE_FLAGS+= -X github.com/test-network-function/cnf-certification
LINKER_TNF_RELEASE_FLAGS+= -X github.com/test-network-function/cnf-certification-test/cnf-certification-test.GitPreviousRelease=${GIT_PREVIOUS_RELEASE}
LINKER_TNF_RELEASE_FLAGS+= -X github.com/test-network-function/cnf-certification-test/cnf-certification-test.ClaimFormatVersion=${CLAIM_FORMAT_VERSION}
PARSER_RELEASE=$(shell jq .parserTag version.json)
BASH_SCRIPTS=$(shell find -name "*.sh" -not -path "./.git/*")

all: build

Expand All @@ -77,10 +78,14 @@ clean:

# Runs configured linters
lint:
checkmake Makefile
checkmake --config=.checkmake Makefile
golangci-lint run --timeout 10m0s
hadolint Dockerfile
shfmt -d *.sh script
typos
markdownlint '**/*.md'
yamllint --no-warnings .
shellcheck --format=gcc ${BASH_SCRIPTS}

# Builds and runs unit tests
test: coverage-qe
Expand Down
2 changes: 1 addition & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
iif = "iif"

[files]
extend-exclude = ["go.mod", "results.html", "cmd/tnf/claim/compare/testdata", "docs/assets/images/demo-config.svg"]
extend-exclude = ["go.mod", "results.html", "cmd/tnf/claim/compare/testdata", "docs/assets/images/*.svg"]
67 changes: 64 additions & 3 deletions cmd/tnf/claim/compare/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,75 @@ import (
"github.com/test-network-function/cnf-certification-test/cmd/tnf/pkg/claim"
)

const longHelp = `Compares sections of both claim files and the differences are shown in a table per section.
This tool can be helpful when the result of some test cases is different between two (consecutive) runs, as it shows
configuration differences in both the CNF Cert Suite config and the cluster nodes that could be the root cause for
some of the test cases results discrepancy.
All the compared sections, except the test cases results are compared blindly, traversing the whole json tree and
substrees to get a list of all the fields and their values. Three tables are shown:
- Differences: same fields with different values.
- Fields in claim 1 only: json fields in claim file 1 that don't exist in claim 2.
- Fields in claim 2 only: json fields in claim file 2 that don't exist in claim 1.
Let's say one of the nodes of the claim.json file contains this struct:
{
"field1": "value1",
"field2": {
"field3": "value2",
"field4": {
"field5": "value3",
"field6": "value4"
}
}
}
When parsing that json struct fields, it will produce a list of fields like this:
/field1=value1
/field2/field3=value2
/field2/field4/field5=value3
/field2/field4/field6=finalvalue2
Once this list of field's path+value strings has been obtained from both claim files,
it is compared in order to find the differences or the fields that only exist on each file.
This is a fake example of a node "clus0-0" whose first CNI (index 0) has a different cniVersion
and the ipMask flag of its first plugin (also index 0) has changed to false in the second run.
Also, the plugin has another "newFakeFlag" config flag in claim 2 that didn't exist in clam file 1.
...
CNIs: Differences
FIELD CLAIM 1 CLAIM 2
/clus0-0/0/cniVersion 1.0.0 1.0.1
/clus0-1/0/plugins/0/ipMasq true false
CNIs: Only in CLAIM 1
<none>
CNIs: Only in CLAIM 2
/clus0-1/0/plugins/0/newFakeFlag=true
...
Currently, the following sections are compared, in this order:
- claim.versions
- claim.Results
- claim.configurations.Config
- claim.nodes.cniPlugins
- claim.nodes.csiDriver
- claim.nodes.nodesHwInfo
- claim.nodes.nodeSummary
`

var (
Claim1FilePathFlag string
Claim2FilePathFlag string

claimCompareFiles = &cobra.Command{
Use: "compare",
Short: "Compare two claim files.",
RunE: claimCompare,
Use: "compare",
Short: "Compare two claim files.",
Long: longHelp,
Example: "claim compare -1 claim1.json -2 claim2.json",
RunE: claimCompare,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
4.11.5 / 411.86.202209140028-0
4.11.50 / 411.86.202309200611-0
4.11.51 / 411.86.202310091037-0
4.11.52 / 411.86.202310140407-0
4.11.6 / 411.86.202209211811-0
4.11.7 / 411.86.202209211811-0
4.11.8 / 411.86.202210032349-0
Expand Down Expand Up @@ -181,7 +182,9 @@
4.12.36 / 412.86.202309200923-0
4.12.37 / 412.86.202309281644-0
4.12.38 / 412.86.202310111011-0
4.12.39 / 412.86.202310141028-0
4.12.4 / 412.86.202302091419-0
4.12.40 / 412.86.202310170023-0
4.12.5 / 412.86.202302170236-0
4.12.6 / 412.86.202302282003-0
4.12.7 / 412.86.202303011010-0
Expand Down Expand Up @@ -209,6 +212,7 @@
4.13.15 / 413.92.202310021538-0
4.13.16 / 413.92.202310100714-0
4.13.17 / 413.92.202310141129-0
4.13.18 / 413.92.202310170351-0
4.13.2 / 413.92.202305302312-0
4.13.3 / 413.92.202306070210-0
4.13.4 / 413.92.202306141213-0
Expand All @@ -229,6 +233,7 @@
4.14.0-rc.4 / 414.92.202309282257-0
4.14.0-rc.5 / 414.92.202310100209-0
4.14.0-rc.6 / 414.92.202310121638-0
4.14.0-rc.7 / 414.92.202310210434-0
4.4.0 / 44.81.202004260825-0
4.4.0-rc.0 / 44.81.202003110830-0
4.4.0-rc.1 / 44.81.202003130330-0
Expand Down
Loading

0 comments on commit 6255351

Please sign in to comment.