From fa001e4675af5ca4544fab2fea476c59c9e28d48 Mon Sep 17 00:00:00 2001 From: aabughosh <88486034+aabughosh@users.noreply.github.com> Date: Sun, 19 Nov 2023 15:51:08 +0200 Subject: [PATCH] Revert "Merge branch 'ginkgo_removal' of https://github.com/test-network-function/cnf-certification-test into ginkgo_removal" This reverts commit 037fb46fc5dcb1bed19b0dd95a37c0dae884450b, reversing changes made to 254f3e078b486b5480b1d298fc922c720252862f. --- .github/actions/setup/action.yml | 1 - .github/workflows/pre-main.yaml | 2 +- .github/workflows/qe-hosted.yml | 29 +- .github/workflows/qe-ocp-413-intrusive.yaml | 10 +- .github/workflows/qe-ocp-413.yaml | 10 +- .github/workflows/qe-ocp-414-intrusive.yaml | 10 +- .github/workflows/qe-ocp-414.yaml | 10 +- .github/workflows/qe.yaml | 12 +- .github/workflows/tnf-image.yaml | 2 +- CONTRIBUTING.md | 10 + Dockerfile | 4 +- cmd/tnf/claim/add/add.go | 2 +- cmd/tnf/claim/add/add_test.go | 2 +- cmd/tnf/claim/compare/versions/versions.go | 2 +- .../claim/compare/versions/versions_test.go | 2 +- cmd/tnf/claim/show/csv/csv.go | 2 +- cmd/tnf/generate/catalog/catalog.go | 2 +- cmd/tnf/generate/catalog/catalog_test.go | 2 +- cmd/tnf/generate/qe_coverage/qe_coverage.go | 2 +- .../generate/qe_coverage/qe_coverage_test.go | 2 +- cmd/tnf/pkg/claim/claim.go | 2 +- cnf-certification-test/certification/suite.go | 142 +-- .../identifiers/identifiers.go | 2 +- .../identifiers/identifiers_test.go | 2 +- .../operatingsystem/files/rhcos_version_map | 4 - docs/test-output.md | 1 + generated_policy.json | 5 - go.mod | 15 +- go.sum | 30 +- main.go | 1 - pkg/checksdb/checksdb.go | 2 +- pkg/claim/catalog.go | 73 -- pkg/claim/catalog_test.go | 13 - pkg/claim/doc.go | 16 - pkg/claim/doc_test.go | 16 - pkg/claim/schema.go | 1012 ----------------- pkg/claim/schema_test.go | 254 ----- .../claim-invalid-additional-property.json | 468 -------- .../testdata/claim-invalid-bool-results.json | 220 ---- .../testdata/claim-invalid-junit-payload.json | 384 ------- .../claim-invalid-non-result-result.json | 226 ---- pkg/claim/testdata/claim-valid.json | 231 ---- pkg/claim/testdata/invalid-json.json | 1 - pkg/claim/testdata/missing-claim.json | 2 - pkg/claimhelper/claimhelper.go | 2 +- pkg/provider/isolation.go | 17 +- pkg/provider/isolation_test.go | 33 - pkg/tnf/status.go | 2 +- 48 files changed, 148 insertions(+), 3146 deletions(-) delete mode 100644 pkg/claim/catalog.go delete mode 100644 pkg/claim/catalog_test.go delete mode 100644 pkg/claim/doc.go delete mode 100644 pkg/claim/doc_test.go delete mode 100644 pkg/claim/schema.go delete mode 100644 pkg/claim/schema_test.go delete mode 100644 pkg/claim/testdata/claim-invalid-additional-property.json delete mode 100644 pkg/claim/testdata/claim-invalid-bool-results.json delete mode 100644 pkg/claim/testdata/claim-invalid-junit-payload.json delete mode 100644 pkg/claim/testdata/claim-invalid-non-result-result.json delete mode 100644 pkg/claim/testdata/claim-valid.json delete mode 100644 pkg/claim/testdata/invalid-json.json delete mode 100644 pkg/claim/testdata/missing-claim.json diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 8edb6b6b2..9a7915bc2 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -17,7 +17,6 @@ runs: uses: actions/setup-go@v4 with: go-version: 1.21.4 - cache: false - name: Disable default go problem matcher run: echo "::remove-matcher owner=go::" diff --git a/.github/workflows/pre-main.yaml b/.github/workflows/pre-main.yaml index fb41f596e..ea06fc86d 100644 --- a/.github/workflows/pre-main.yaml +++ b/.github/workflows/pre-main.yaml @@ -451,7 +451,7 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to create \`unstable\` container image from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.GCHAT_WEBHOOK_URL }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.GCHAT_WEBHOOK_URL }} # Push the new unstable TNF image to Quay.io. - name: (if on main and upstream) Authenticate against Quay.io diff --git a/.github/workflows/qe-hosted.yml b/.github/workflows/qe-hosted.yml index ae00fbdc4..833d8e910 100644 --- a/.github/workflows/qe-hosted.yml +++ b/.github/workflows/qe-hosted.yml @@ -1,8 +1,8 @@ name: QE Testing (Ubuntu-hosted) on: - pull_request: - branches: [ main ] + # pull_request: + # branches: [ main ] workflow_dispatch: # Schedule a daily cron at midnight UTC schedule: @@ -26,7 +26,6 @@ jobs: TEST_TNF_IMAGE_NAME: quay.io/testnetworkfunction/cnf-certification-test TEST_TNF_IMAGE_TAG: localtest DOCKER_CONFIG_DIR: '/home/runner/.docker/' - SKIP_PRELOAD_IMAGES: true steps: - name: Free Disk Space (Ubuntu) @@ -41,6 +40,20 @@ jobs: swap-storage: true continue-on-error: true + - name: Write temporary docker file + run: | + mkdir -p /home/runner/.docker + touch ${PFLT_DOCKERCONFIG} + echo '{ "auths": {} }' >> ${PFLT_DOCKERCONFIG} + + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: 1.21.4 + + - name: Disable default go problem matcher + run: echo "::remove-matcher owner=go::" + - name: Check out code uses: actions/checkout@v4 with: @@ -90,12 +103,10 @@ jobs: repository: ${{ env.QE_REPO }} path: cnfcert-tests-verification + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -107,4 +118,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run Github hosted QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/qe-ocp-413-intrusive.yaml b/.github/workflows/qe-ocp-413-intrusive.yaml index f6187b0a7..bee1a95c6 100644 --- a/.github/workflows/qe-ocp-413-intrusive.yaml +++ b/.github/workflows/qe-ocp-413-intrusive.yaml @@ -62,12 +62,10 @@ jobs: sudo rm -rf /tmp/tnf_config/ sudo rm -rf /tmp/tnf_report/ + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=false ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=false ENABLE_PARALLEL=false ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -79,4 +77,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run intrusive OCP 4.13 QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/qe-ocp-413.yaml b/.github/workflows/qe-ocp-413.yaml index 09c3e8266..152b186b9 100644 --- a/.github/workflows/qe-ocp-413.yaml +++ b/.github/workflows/qe-ocp-413.yaml @@ -61,12 +61,10 @@ jobs: sudo rm -rf /tmp/tnf_config/ sudo rm -rf /tmp/tnf_report/ + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -78,4 +76,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run non-intrusive OCP 4.13 QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/qe-ocp-414-intrusive.yaml b/.github/workflows/qe-ocp-414-intrusive.yaml index 6a87d0f1b..22e340a9a 100644 --- a/.github/workflows/qe-ocp-414-intrusive.yaml +++ b/.github/workflows/qe-ocp-414-intrusive.yaml @@ -62,12 +62,10 @@ jobs: sudo rm -rf /tmp/tnf_config/ sudo rm -rf /tmp/tnf_report/ + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=false ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=false ENABLE_PARALLEL=false ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -79,4 +77,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run intrusive OCP 4.14 QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/qe-ocp-414.yaml b/.github/workflows/qe-ocp-414.yaml index 2b0da85a6..eed2acbba 100644 --- a/.github/workflows/qe-ocp-414.yaml +++ b/.github/workflows/qe-ocp-414.yaml @@ -61,12 +61,10 @@ jobs: sudo rm -rf /tmp/tnf_config/ sudo rm -rf /tmp/tnf_report/ + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -78,4 +76,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run non-intrusive OCP 4.14 QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/qe.yaml b/.github/workflows/qe.yaml index 094a40e6a..1b46c4a87 100644 --- a/.github/workflows/qe.yaml +++ b/.github/workflows/qe.yaml @@ -10,6 +10,8 @@ on: env: QE_REPO: test-network-function/cnfcert-tests-verification + + jobs: qe-testing: runs-on: qe-runner @@ -103,12 +105,10 @@ jobs: run: ./scripts/delete-namespaces.sh working-directory: cnfcert-tests-verification + # Setup is complete. Time to run the QE tests. - name: Run the tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - command: cd ${GITHUB_WORKSPACE}/cnfcert-tests-verification; FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + run: FEATURES=${{matrix.suite}} TNF_REPO_PATH=${GITHUB_WORKSPACE} TNF_IMAGE=${{env.TEST_TNF_IMAGE_NAME}} TNF_IMAGE_TAG=${{env.TEST_TNF_IMAGE_TAG}} DISABLE_INTRUSIVE_TESTS=true ENABLE_PARALLEL=true ENABLE_FLAKY_RETRY=true make test-features + working-directory: cnfcert-tests-verification - name: (if on main and upstream) Send chat msg to dev team if failed to run QE tests if: ${{ failure() && github.ref == 'refs/heads/main' && github.repository_owner == 'test-network-function' }} @@ -120,4 +120,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to run Kind-based non-intrusive QE tests from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.QE_NIGHTLY_WEBHOOK }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.QE_NIGHTLY_WEBHOOK }} diff --git a/.github/workflows/tnf-image.yaml b/.github/workflows/tnf-image.yaml index 9c972e033..58c32979c 100644 --- a/.github/workflows/tnf-image.yaml +++ b/.github/workflows/tnf-image.yaml @@ -144,4 +144,4 @@ jobs: run: | curl -X POST --data "{ \"text\": \"🚨⚠️ Failed to create container image version \`$TNF_VERSION\` from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \" - }" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.GCHAT_WEBHOOK_URL }}' + }" -H 'Content-type: application/json; charset=UTF-8' ${{ secrets.GCHAT_WEBHOOK_URL }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a5643abab..da6b07caa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,6 +71,16 @@ following command: make test ``` +## Configuration guidelines + +Many Tests will require some form of extra configuration. To maintain reproducibility and auditability outcomes this +configuration must be included in a claim file. For all current configuration approaches (see the `generic` test spec) +this will be done automatically provided the `config` structure for the Test implements or inherits a working `MarshalJSON` and `UnmarshalJSON` +interface so it can be included in a +[test-network-function-claim](https://github.com/test-network-function/test-network-function-claim) JSON file. + +All configuration must adhere to these two requirements will automatically be included in the claim. + ## Documentation guidelines Each exported API, global variable or constant must have proper documentation which adheres to `gofmt`. diff --git a/Dockerfile b/Dockerfile index b3e25e058..a34ad2809 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi8/ubi:8.9-1028 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 \ @@ -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.9-1029 +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8-1072.1697626218 ENV \ TNF_DIR=/usr/tnf \ diff --git a/cmd/tnf/claim/add/add.go b/cmd/tnf/claim/add/add.go index 69ea0a3b1..c0f6c0fdc 100644 --- a/cmd/tnf/claim/add/add.go +++ b/cmd/tnf/claim/add/add.go @@ -9,8 +9,8 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/test-network-function/cnf-certification-test/pkg/claim" "github.com/test-network-function/cnf-certification-test/pkg/junit" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) var ( diff --git a/cmd/tnf/claim/add/add_test.go b/cmd/tnf/claim/add/add_test.go index e65c5a421..4ef364631 100644 --- a/cmd/tnf/claim/add/add_test.go +++ b/cmd/tnf/claim/add/add_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) func TestReadClaim(t *testing.T) { diff --git a/cmd/tnf/claim/compare/versions/versions.go b/cmd/tnf/claim/compare/versions/versions.go index 3b984cff5..14f945c9d 100644 --- a/cmd/tnf/claim/compare/versions/versions.go +++ b/cmd/tnf/claim/compare/versions/versions.go @@ -5,7 +5,7 @@ import ( "log" "github.com/test-network-function/cnf-certification-test/cmd/tnf/claim/compare/diff" - officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim" + officialClaimScheme "github.com/test-network-function/test-network-function-claim/pkg/claim" ) type DiffReport struct { diff --git a/cmd/tnf/claim/compare/versions/versions_test.go b/cmd/tnf/claim/compare/versions/versions_test.go index 0b0ea016e..2234cfb34 100644 --- a/cmd/tnf/claim/compare/versions/versions_test.go +++ b/cmd/tnf/claim/compare/versions/versions_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/test-network-function/cnf-certification-test/cmd/tnf/claim/compare/diff" - officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim" + officialClaimScheme "github.com/test-network-function/test-network-function-claim/pkg/claim" ) func TestCompare(t *testing.T) { diff --git a/cmd/tnf/claim/show/csv/csv.go b/cmd/tnf/claim/show/csv/csv.go index 0d316f047..f1f10f5c5 100644 --- a/cmd/tnf/claim/show/csv/csv.go +++ b/cmd/tnf/claim/show/csv/csv.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/cobra" "github.com/test-network-function/cnf-certification-test/cmd/tnf/pkg/claim" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" - claimschema "github.com/test-network-function/cnf-certification-test/pkg/claim" + claimschema "github.com/test-network-function/test-network-function-claim/pkg/claim" ) var ( diff --git a/cmd/tnf/generate/catalog/catalog.go b/cmd/tnf/generate/catalog/catalog.go index 0bc513ec2..7d51082c7 100644 --- a/cmd/tnf/generate/catalog/catalog.go +++ b/cmd/tnf/generate/catalog/catalog.go @@ -26,7 +26,7 @@ import ( "github.com/sirupsen/logrus" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" "github.com/test-network-function/cnf-certification-test/pkg/arrayhelper" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" "github.com/spf13/cobra" ) diff --git a/cmd/tnf/generate/catalog/catalog_test.go b/cmd/tnf/generate/catalog/catalog_test.go index 5cdf26029..78a24e9ed 100644 --- a/cmd/tnf/generate/catalog/catalog_test.go +++ b/cmd/tnf/generate/catalog/catalog_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/test-network-function/cnf-certification-test/pkg/arrayhelper" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) func TestNewCommand(t *testing.T) { diff --git a/cmd/tnf/generate/qe_coverage/qe_coverage.go b/cmd/tnf/generate/qe_coverage/qe_coverage.go index c02a8ed9d..9e4d2bc86 100644 --- a/cmd/tnf/generate/qe_coverage/qe_coverage.go +++ b/cmd/tnf/generate/qe_coverage/qe_coverage.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) type TestCoverageSummaryReport struct { diff --git a/cmd/tnf/generate/qe_coverage/qe_coverage_test.go b/cmd/tnf/generate/qe_coverage/qe_coverage_test.go index cdcb2e15b..eb90c4407 100644 --- a/cmd/tnf/generate/qe_coverage/qe_coverage_test.go +++ b/cmd/tnf/generate/qe_coverage/qe_coverage_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) type catalogEntry struct { diff --git a/cmd/tnf/pkg/claim/claim.go b/cmd/tnf/pkg/claim/claim.go index f948afc0d..db9d92012 100644 --- a/cmd/tnf/pkg/claim/claim.go +++ b/cmd/tnf/pkg/claim/claim.go @@ -6,7 +6,7 @@ import ( "os" "github.com/Masterminds/semver/v3" - officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim" + officialClaimScheme "github.com/test-network-function/test-network-function-claim/pkg/claim" ) const ( diff --git a/cnf-certification-test/certification/suite.go b/cnf-certification-test/certification/suite.go index 748e243bc..b27610b08 100644 --- a/cnf-certification-test/certification/suite.go +++ b/cnf-certification-test/certification/suite.go @@ -23,12 +23,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/onsi/ginkgo/v2" "github.com/sirupsen/logrus" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/common" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" "github.com/test-network-function/cnf-certification-test/internal/clientsholder" - "github.com/test-network-function/cnf-certification-test/pkg/checksdb" "github.com/test-network-function/cnf-certification-test/pkg/provider" "github.com/test-network-function/cnf-certification-test/pkg/testhelper" "github.com/test-network-function/cnf-certification-test/pkg/tnf" @@ -41,83 +41,41 @@ const ( Online = "online" ) -var ( - env provider.TestEnvironment - validator certdb.CertificationStatusValidator - - beforeEachFn = func(check *checksdb.Check) error { - logrus.Infof("Check %s: getting test environment and certdb validator.", check.ID) - env = provider.GetTestEnvironment() - +var _ = ginkgo.Describe(common.AffiliatedCertTestKey, func() { + logrus.Debugf("Entering %s suite", common.AffiliatedCertTestKey) + var env provider.TestEnvironment + var validator certdb.CertificationStatusValidator + ginkgo.BeforeEach(func() { var err error + env = provider.GetTestEnvironment() validator, err = certdb.GetValidator(env.GetOfflineDBPath()) if err != nil { - return fmt.Errorf("cannot access the certification DB, err: %v", err) + errMsg := fmt.Sprintf("Cannot access the certification DB, err: %v", err) + ginkgo.Fail(errMsg) } - - return nil - } - - skipIfNoOperatorsFn = func() (bool, string) { - if len(env.Operators) == 0 { - return true, "There are no operators to check. Please check under test labels." - } - - return false, "" - } - - skipIfNoHelmChartReleasesFn = func() (bool, string) { - if len(env.HelmChartReleases) == 0 { - return true, "There are no helm chart releases to check." - } - - return false, "" - } -) - -func init() { - logrus.Debugf("Entering %s suite", common.AffiliatedCertTestKey) - - checksGroup := checksdb.NewChecksGroup(common.AffiliatedCertTestKey). - WithBeforeEachFn(beforeEachFn) + }) testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmVersionIdentifier) - check := checksdb.NewCheck(testID, tags). - WithSkipCheckFn(skipIfNoHelmChartReleasesFn). - WithCheckFn(testHelmVersion) - - checksGroup.Add(check) + ginkgo.It(testID, ginkgo.Label(tags...), func() { + testHelmVersion() + }) + // Query API for certification status of listed operators testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestOperatorIsCertifiedIdentifier) - check = checksdb.NewCheck(testID, tags). - WithSkipCheckFn(skipIfNoOperatorsFn). - WithCheckFn(func(c *checksdb.Check) error { - testAllOperatorCertified(c, &env, validator) - return nil - }) - - checksGroup.Add(check) + ginkgo.It(testID, ginkgo.Label(tags...), func() { + testAllOperatorCertified(&env, validator) + }) testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestHelmIsCertifiedIdentifier) - check = checksdb.NewCheck(testID, tags). - WithSkipCheckFn(skipIfNoHelmChartReleasesFn). - WithCheckFn(func(c *checksdb.Check) error { - testHelmCertified(c, &env, validator) - return nil - }) - - checksGroup.Add(check) - + ginkgo.It(testID, ginkgo.Label(tags...), func() { + testHelmCertified(&env, validator) + }) + // Query API for certification status by digest of listed containers testID, tags = identifiers.GetGinkgoTestIDAndLabels(identifiers.TestContainerIsCertifiedDigestIdentifier) - check = checksdb.NewCheck(testID, tags). - WithSkipCheckFn(testhelper.GetNoContainersUnderTestSkipFn(&env)). - WithCheckFn(func(c *checksdb.Check) error { - testContainerCertificationStatusByDigest(c, &env, validator) - return nil - }) - - checksGroup.Add(check) -} + ginkgo.It(testID, ginkgo.Label(tags...), func() { + testContainerCertificationStatusByDigest(&env, validator) + }) +}) func getContainersToQuery(env *provider.TestEnvironment) map[provider.ContainerImageIdentifier]bool { containersToQuery := make(map[provider.ContainerImageIdentifier]bool) @@ -135,13 +93,12 @@ func testContainerCertification(c provider.ContainerImageIdentifier, validator c return ans } -func testAllOperatorCertified(check *checksdb.Check, env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { +func testAllOperatorCertified(env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { operatorsUnderTest := env.Operators - tnf.Logf(logrus.InfoLevel, "Verify operator as certified. Number of operators to check: %d", len(operatorsUnderTest)) - + testhelper.SkipIfEmptyAny(ginkgo.Skip, testhelper.NewSkipObject(operatorsUnderTest, "operatorsUnderTest")) + ginkgo.By(fmt.Sprintf("Verify operator as certified. Number of operators to check: %d", len(operatorsUnderTest))) var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject - ocpMinorVersion := "" if provider.IsOCPCluster() { // Converts major.minor.patch version format to major.minor @@ -165,13 +122,12 @@ func testAllOperatorCertified(check *checksdb.Check, env *provider.TestEnvironme AddField(testhelper.OCPChannel, channel)) } } - - check.SetResult(compliantObjects, nonCompliantObjects) + testhelper.AddTestResultReason(compliantObjects, nonCompliantObjects, tnf.ClaimFilePrintf, ginkgo.Fail) } -func testHelmCertified(check *checksdb.Check, env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { +func testHelmCertified(env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { helmchartsReleases := env.HelmChartReleases - + testhelper.SkipIfEmptyAny(ginkgo.Skip, testhelper.NewSkipObject(helmchartsReleases, "helmchartsReleases")) // Collect all of the failed helm charts var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject @@ -188,11 +144,10 @@ func testHelmCertified(check *checksdb.Check, env *provider.TestEnvironment, val AddField(testhelper.Version, helm.Chart.Metadata.Version)) } } - - check.SetResult(compliantObjects, nonCompliantObjects) + testhelper.AddTestResultReason(compliantObjects, nonCompliantObjects, tnf.ClaimFilePrintf, ginkgo.Fail) } -func testContainerCertificationStatusByDigest(check *checksdb.Check, env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { +func testContainerCertificationStatusByDigest(env *provider.TestEnvironment, validator certdb.CertificationStatusValidator) { var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, c := range env.Containers { @@ -213,39 +168,28 @@ func testContainerCertificationStatusByDigest(check *checksdb.Check, env *provid compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(c.Namespace, c.Podname, c.Name, "Container is certified", true)) } } - - check.SetResult(compliantObjects, nonCompliantObjects) + testhelper.AddTestResultReason(compliantObjects, nonCompliantObjects, tnf.ClaimFilePrintf, ginkgo.Fail) } -func testHelmVersion(check *checksdb.Check) error { +func testHelmVersion() { var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject - clients := clientsholder.GetClientsHolder() // Get the Tiller pod in the specified namespace podList, err := clients.K8sClient.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{ LabelSelector: "app=helm,name=tiller", }) if err != nil { - return fmt.Errorf("failed getting Tiller pod: %v", err) + ginkgo.Fail(fmt.Sprintf("Error getting Tiller pod: %v\n", err)) } - if len(podList.Items) == 0 { - tnf.ClaimFilePrintf("Tiller pod not found in any namespaces. Helm version is v3.") - for _, helm := range env.HelmChartReleases { - compliantObjects = append(compliantObjects, testhelper.NewHelmChartReportObject(helm.Namespace, helm.Name, "helm chart was installed with helm v3", true)) + tnf.ClaimFilePrintf("Tiller pod is not found in all namespaces helm version is v3\n") + } else { + tnf.ClaimFilePrintf("Tiller pod found, helm version is v2") + for i := range podList.Items { + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewPodReportObject(podList.Items[i].Namespace, podList.Items[i].Name, + "This pod is a Tiller pod. Helm Chart version is v2 but needs to be v3 due to the security risks associated with Tiller", false)) } - - return nil - } - - tnf.ClaimFilePrintf("Tiller pod found, helm version is v2.") - for i := range podList.Items { - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewPodReportObject(podList.Items[i].Namespace, podList.Items[i].Name, - "This pod is a Tiller pod. Helm Chart version is v2 but needs to be v3 due to the security risks associated with Tiller", false)) } - - check.SetResult(compliantObjects, nonCompliantObjects) - - return nil + testhelper.AddTestResultReason(compliantObjects, nonCompliantObjects, tnf.ClaimFilePrintf, ginkgo.Fail) } diff --git a/cnf-certification-test/identifiers/identifiers.go b/cnf-certification-test/identifiers/identifiers.go index ff56bc8ef..457162716 100644 --- a/cnf-certification-test/identifiers/identifiers.go +++ b/cnf-certification-test/identifiers/identifiers.go @@ -20,7 +20,7 @@ import ( "strings" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/common" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) // shared description text diff --git a/cnf-certification-test/identifiers/identifiers_test.go b/cnf-certification-test/identifiers/identifiers_test.go index df3bbf378..b0d404d1f 100644 --- a/cnf-certification-test/identifiers/identifiers_test.go +++ b/cnf-certification-test/identifiers/identifiers_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/test-network-function/cnf-certification-test/pkg/claim" "github.com/test-network-function/cnf-certification-test/pkg/stringhelper" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) func TestGetGinkgoTestIDAndLabels(t *testing.T) { diff --git a/cnf-certification-test/platform/operatingsystem/files/rhcos_version_map b/cnf-certification-test/platform/operatingsystem/files/rhcos_version_map index 2a777aa7c..61db0b362 100644 --- a/cnf-certification-test/platform/operatingsystem/files/rhcos_version_map +++ b/cnf-certification-test/platform/operatingsystem/files/rhcos_version_map @@ -189,7 +189,6 @@ 4.12.41 / 412.86.202310210217-0 4.12.42 / 412.86.202310302215-0 4.12.43 / 412.86.202311051457-0 -4.12.44 / 412.86.202311092041-0 4.12.5 / 412.86.202302170236-0 4.12.6 / 412.86.202302282003-0 4.12.7 / 412.86.202303011010-0 @@ -221,8 +220,6 @@ 4.13.19 / 413.92.202310210500-0 4.13.2 / 413.92.202305302312-0 4.13.21 / 413.92.202310210500-0 -4.13.22 / 413.92.202311061658-0 -4.13.23 / 413.92.202311151359-0 4.13.3 / 413.92.202306070210-0 4.13.4 / 413.92.202306141213-0 4.13.5 / 413.92.202307140015-0 @@ -246,7 +243,6 @@ 4.14.0-rc.7 / 414.92.202310210434-0 4.14.1 / 414.92.202310270216-0 4.14.2 / 414.92.202311061957-0 -4.14.3 / 414.92.202311150705-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 diff --git a/docs/test-output.md b/docs/test-output.md index ff5f3d208..b5468a81b 100644 --- a/docs/test-output.md +++ b/docs/test-output.md @@ -44,6 +44,7 @@ go run cmd/tools/cmd/main.go claim-add --claimfile=claim.json For more details on the contents of the claim file +* [schema](https://github.com/test-network-function/test-network-function-claim/blob/main/schemas/claim.schema.json). * [Guide](https://redhat-connect.gitbook.io/openshift-badges/badges/cloud-native-network-functions-cnf). ## Execution logs diff --git a/generated_policy.json b/generated_policy.json index 2475a8768..d4ab257bd 100644 --- a/generated_policy.json +++ b/generated_policy.json @@ -1,11 +1,6 @@ { "grades": { "requiredPassingTests": [ - { - "id": "affiliated-certification-operator-is-certified", - "suite": "affiliated-certification", - "tags": "common" - }, { "id": "manageability-container-port-name-format", "suite": "manageability", diff --git a/go.mod b/go.mod index 2a29fe471..c6d05e62f 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,12 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.8.4 + github.com/test-network-function/test-network-function-claim v1.0.30 github.com/xeipuuv/gojsonschema v1.2.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) -require k8s.io/client-go v0.28.4 +require k8s.io/client-go v0.28.3 require ( github.com/kelseyhightower/envconfig v1.4.0 @@ -24,8 +25,8 @@ require ( github.com/operator-framework/operator-lifecycle-manager v0.20.0 github.com/pkg/errors v0.9.1 // indirect helm.sh/helm/v3 v3.13.2 - k8s.io/api v0.28.4 - k8s.io/apimachinery v0.28.4 + k8s.io/api v0.28.3 + k8s.io/apimachinery v0.28.3 k8s.io/klog/v2 v2.100.1 // indirect ) @@ -182,8 +183,8 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect k8s.io/apiserver v0.28.3 // indirect - k8s.io/cli-runtime v0.28.4 // indirect - k8s.io/component-base v0.28.4 // indirect + k8s.io/cli-runtime v0.28.3 // indirect + k8s.io/component-base v0.28.3 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect modernc.org/libc v1.22.5 // indirect @@ -216,11 +217,11 @@ require ( github.com/openshift/machine-config-operator v0.0.1-0.20230515070935-49f32d46538e github.com/redhat-openshift-ecosystem/openshift-preflight v0.0.0-20231018165107-f04b78186455 github.com/robert-nix/ansihtml v1.0.1 - github.com/test-network-function/oct v0.0.4 + github.com/test-network-function/oct v0.0.3 github.com/test-network-function/privileged-daemonset v1.0.15 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 - k8s.io/kubectl v0.28.4 + k8s.io/kubectl v0.28.3 ) replace github.com/redhat-openshift-ecosystem/openshift-preflight => github.com/redhat-openshift-ecosystem/openshift-preflight v0.0.0-20231018165107-f04b78186455 diff --git a/go.sum b/go.sum index 123584c80..a5eddf3a0 100644 --- a/go.sum +++ b/go.sum @@ -573,10 +573,12 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/test-network-function/oct v0.0.4 h1:rU4kps/gbAHkR0rc5WzVtTOcJt/NBcse85RaG7WTuYw= -github.com/test-network-function/oct v0.0.4/go.mod h1:oOPuUMnX6YR+cl3usBJfwCllsv7Hphw9jVi7VtniAzo= +github.com/test-network-function/oct v0.0.3 h1:jcVf+LVhN7FhKXjSqNUG1hsH6FrNwD9I/i6xowEZhB4= +github.com/test-network-function/oct v0.0.3/go.mod h1:Sz+lcJPXHge6VVs7bPtz9s0q8wcrMeQ4WA2PUGCyeok= github.com/test-network-function/privileged-daemonset v1.0.15 h1:Jgjf3sa4d9OuhZRTj3oLhaaGV7PtQLVeLK/LSd9YgdE= github.com/test-network-function/privileged-daemonset v1.0.15/go.mod h1:rDiFimleKbW2E501cNgHMYCrR52+w5Sg0a6trF2HZTo= +github.com/test-network-function/test-network-function-claim v1.0.30 h1:Pi0H1utIQ6WXmzD7+R2F/YYHmchEyT6LiAf6WEZm0J0= +github.com/test-network-function/test-network-function-claim v1.0.30/go.mod h1:qu/HJnmC5SzCsxS2mULGCdv5SWwjoMGlgQpjUOtQiEs= github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= @@ -1012,26 +1014,26 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= -k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= +k8s.io/api v0.28.3 h1:Gj1HtbSdB4P08C8rs9AR94MfSGpRhJgsS+GF9V26xMM= +k8s.io/api v0.28.3/go.mod h1:MRCV/jr1dW87/qJnZ57U5Pak65LGmQVkKTzf3AtKFHc= k8s.io/apiextensions-apiserver v0.28.3 h1:Od7DEnhXHnHPZG+W9I97/fSQkVpVPQx2diy+2EtmY08= k8s.io/apiextensions-apiserver v0.28.3/go.mod h1:NE1XJZ4On0hS11aWWJUTNkmVB03j9LM7gJSisbRt8Lc= -k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= -k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= +k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A= +k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8= k8s.io/apiserver v0.28.3 h1:8Ov47O1cMyeDzTXz0rwcfIIGAP/dP7L8rWbEljRcg5w= k8s.io/apiserver v0.28.3/go.mod h1:YIpM+9wngNAv8Ctt0rHG4vQuX/I5rvkEMtZtsxW2rNM= -k8s.io/cli-runtime v0.28.4 h1:IW3aqSNFXiGDllJF4KVYM90YX4cXPGxuCxCVqCD8X+Q= -k8s.io/cli-runtime v0.28.4/go.mod h1:MLGRB7LWTIYyYR3d/DOgtUC8ihsAPA3P8K8FDNIqJ0k= -k8s.io/client-go v0.28.4 h1:Np5ocjlZcTrkyRJ3+T3PkXDpe4UpatQxj85+xjaD2wY= -k8s.io/client-go v0.28.4/go.mod h1:0VDZFpgoZfelyP5Wqu0/r/TRYcLYuJ2U1KEeoaPa1N4= -k8s.io/component-base v0.28.4 h1:c/iQLWPdUgI90O+T9TeECg8o7N3YJTiuz2sKxILYcYo= -k8s.io/component-base v0.28.4/go.mod h1:m9hR0uvqXDybiGL2nf/3Lf0MerAfQXzkfWhUY58JUbU= +k8s.io/cli-runtime v0.28.3 h1:lvuJYVkwCqHEvpS6KuTZsUVwPePFjBfSGvuaLl2SxzA= +k8s.io/cli-runtime v0.28.3/go.mod h1:jeX37ZPjIcENVuXDDTskG3+FnVuZms5D9omDXS/2Jjc= +k8s.io/client-go v0.28.3 h1:2OqNb72ZuTZPKCl+4gTKvqao0AMOl9f3o2ijbAj3LI4= +k8s.io/client-go v0.28.3/go.mod h1:LTykbBp9gsA7SwqirlCXBWtK0guzfhpoW4qSm7i9dxo= +k8s.io/component-base v0.28.3 h1:rDy68eHKxq/80RiMb2Ld/tbH8uAE75JdCqJyi6lXMzI= +k8s.io/component-base v0.28.3/go.mod h1:fDJ6vpVNSk6cRo5wmDa6eKIG7UlIQkaFmZN2fYgIUD8= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/kubectl v0.28.4 h1:gWpUXW/T7aFne+rchYeHkyB8eVDl5UZce8G4X//kjUQ= -k8s.io/kubectl v0.28.4/go.mod h1:CKOccVx3l+3MmDbkXtIUtibq93nN2hkDR99XDCn7c/c= +k8s.io/kubectl v0.28.3 h1:H1Peu1O3EbN9zHkJCcvhiJ4NUj6lb88sGPO5wrWIM6k= +k8s.io/kubectl v0.28.3/go.mod h1:RDAudrth/2wQ3Sg46fbKKl4/g+XImzvbsSRZdP2RiyE= k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE= diff --git a/main.go b/main.go index 6bde03473..655f92050 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,6 @@ import ( "github.com/test-network-function/cnf-certification-test/pkg/loghelper" "github.com/test-network-function/cnf-certification-test/pkg/versions" - _ "github.com/test-network-function/cnf-certification-test/cnf-certification-test/certification" _ "github.com/test-network-function/cnf-certification-test/cnf-certification-test/manageability" _ "github.com/test-network-function/cnf-certification-test/cnf-certification-test/observability" _ "github.com/test-network-function/cnf-certification-test/cnf-certification-test/performance" diff --git a/pkg/checksdb/checksdb.go b/pkg/checksdb/checksdb.go index 1e75937f1..b2ca1af31 100644 --- a/pkg/checksdb/checksdb.go +++ b/pkg/checksdb/checksdb.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" - "github.com/test-network-function/cnf-certification-test/pkg/claim" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) var ( diff --git a/pkg/claim/catalog.go b/pkg/claim/catalog.go deleted file mode 100644 index 0ab73d2d6..000000000 --- a/pkg/claim/catalog.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2023 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -package claim - -import ( - "strings" -) - -// TestCaseDescription describes a JUnit test case. -type TestCaseDescription struct { - // Identifier is the unique test identifier. - Identifier Identifier `json:"identifier" yaml:"identifier"` - - // Description is a helpful description of the purpose of the test case. - Description string `json:"description" yaml:"description"` - - // Remediation is an optional suggested remediation for passing the test. - Remediation string `json:"remediation,omitempty" yaml:"remediation,omitempty"` - - // BestPracticeReference is a helpful best practice references of the test case. - BestPracticeReference string `json:"BestPracticeReference" yaml:"BestPracticeReference"` - - // ExceptionProcess will show any possible exception processes documented for partners to follow. - ExceptionProcess string `json:"exceptionProcess,omitempty" yaml:"exceptionProcess,omitempty"` - - // Tags will show all of the ginkgo tags that the test case applies to - Tags string `json:"tags,omitempty" yaml:"tags,omitempty"` - - // Whether or not automated tests exist for the test case. Not to be rendered. - Qe bool `json:"qe" yaml:"qe"` - - // classification for each test case - CategoryClassification map[string]string `json:"categoryclassification" yaml:"categoryclassification"` - /* an example to how it CategoryClassification would be - { - "ForTelco": "Mandatory", - "FarEdge" : "Optional", - "ForNonTelco": "Optional", - "ForVZ": "Mandatory" - }*/ -} - -func formTestTags(tags ...string) string { - return strings.Join(tags, ",") -} - -func BuildTestCaseDescription(testID, suiteName, description, remediation, exception, reference string, qe bool, categoryclassification map[string]string, tags ...string) (TestCaseDescription, Identifier) { - aID := Identifier{ - Tags: formTestTags(tags...), - Id: suiteName + "-" + testID, - Suite: suiteName, - } - aTCDescription := TestCaseDescription{} - aTCDescription.Identifier = aID - aTCDescription.Description = description - aTCDescription.Remediation = remediation - aTCDescription.ExceptionProcess = exception - aTCDescription.BestPracticeReference = reference - aTCDescription.Tags = strings.Join(tags, ",") - aTCDescription.Qe = qe - aTCDescription.CategoryClassification = categoryclassification - return aTCDescription, aID -} diff --git a/pkg/claim/catalog_test.go b/pkg/claim/catalog_test.go deleted file mode 100644 index 6e740f114..000000000 --- a/pkg/claim/catalog_test.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -package claim diff --git a/pkg/claim/doc.go b/pkg/claim/doc.go deleted file mode 100644 index fe257facd..000000000 --- a/pkg/claim/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2020 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -/* -Package claim provides a test-network-definition claim schema. -*/ -package claim diff --git a/pkg/claim/doc_test.go b/pkg/claim/doc_test.go deleted file mode 100644 index fe257facd..000000000 --- a/pkg/claim/doc_test.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2020 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -/* -Package claim provides a test-network-definition claim schema. -*/ -package claim diff --git a/pkg/claim/schema.go b/pkg/claim/schema.go deleted file mode 100644 index bc19785e2..000000000 --- a/pkg/claim/schema.go +++ /dev/null @@ -1,1012 +0,0 @@ -// Copyright (C) 2023 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -package claim - -import ( - "bytes" - "encoding/json" - "errors" -) - -// CatalogInfo test specific information from the catalog -type CatalogInfo struct { - - // Link to the best practice document supporting this test case - BestPracticeReference string `json:"bestPracticeReference"` - - // The test description. - Description string `json:"description"` - - // Indicates the exception process if defined - ExceptionProcess string `json:"exceptionProcess"` - - // steps required to fix a failing test case - Remediation string `json:"remediation"` -} - -// CategoryClassification categoryClassification is the classification for a single test case. -type CategoryClassification struct { - - // indicates whether this test case is mandatory or optional in the Extended scenario - Extended string `json:"Extended,omitempty"` - - // indicates whether this test case is mandatory or optional in the FarEdge scenario - FarEdge string `json:"FarEdge,omitempty"` - - // indicates whether this test case is mandatory or optional in the NonTelco scenario - NonTelco string `json:"NonTelco,omitempty"` - - // indicates whether this test case is mandatory or optional in the Telco scenario - Telco string `json:"Telco,omitempty"` -} - -// Claim -type Claim struct { - - // Tests within test-network-function often require configuration. For example, the generic test suite requires listing all CNF containers. - // This information is used to derive per-container IP address information, which is then used as input to the connectivity test suite. - // Test suites within test-network-function may use multiple configurations, but each with a unique name. - Configurations map[string]interface{} `json:"configurations"` - Metadata *Metadata `json:"metadata"` - - // An OpenShift cluster is composed of an arbitrary number of Nodes used for platform and application services. - // Since a claim must be reproducible, a variety of per-Node information must be collected and stored in the claim. - // Node names are unique within a given OpenShift cluster. - Nodes map[string]interface{} `json:"nodes"` - - // The test-network-function test results. Results are a JSON representation of the JUnit output. - RawResults map[string]interface{} `json:"rawResults"` - - // The results for each unique test case. - Results map[string]interface{} `json:"results,omitempty"` - Versions *Versions `json:"versions"` -} - -// Identifier identifier is a per testcase unique identifier. -type Identifier struct { - - // id stores a unique id for the testcase. - Id string `json:"id"` //nolint:revive, stylecheck - - // suite stores the test suite name for the testcase. - Suite string `json:"suite"` - - // tags stores the different tags applied to a test. - Tags string `json:"tags,omitempty"` -} - -// Metadata -type Metadata struct { - - // The UTC end time of a claim evaluation. This is recorded when the test-network-function test suite completes. - EndTime string `json:"endTime"` - - // The UTC start time of a claim evaluation. This is recorded when the test-network-function test suite is invoked. - StartTime string `json:"startTime"` -} - -// Result result is the result of running a testcase. -type Result struct { - - // Ginkgo writer output during the test run. - CapturedTestOutput string `json:"capturedTestOutput"` - - // Test detailed information from catalog - CatalogInfo *CatalogInfo `json:"catalogInfo"` - - // Category classification for the test - CategoryClassification *CategoryClassification `json:"categoryClassification"` - - // The duration of the test in nanoseconds. - Duration int `json:"duration"` - - // The end time of the test. - EndTime string `json:"endTime,omitempty"` - - // The content of the line where the failure happened - FailureLineContent string `json:"failureLineContent"` - - // The Filename and line number where the failure happened - FailureLocation string `json:"failureLocation"` - - // Describes the test failure in detail. - FailureReason string `json:"failureReason"` - - // The start time of the test. - StartTime string `json:"startTime"` - - // The test result state: INVALID SPEC STATE, pending,skipped,passed,failed,aborted,panicked,interrupted - State string `json:"state"` - - // The test identifier - TestID *Identifier `json:"testID"` -} - -// Root A test-network-function claim is an attestation of the tests performed, the results and the various configurations. Since a claim must be reproducible, it also includes an overview of the systems under test and their physical configurations. -type Root struct { - Claim *Claim `json:"claim"` -} - -// Versions -type Versions struct { - - // The claim file format version. - ClaimFormat string `json:"claimFormat"` - - // The Kubernetes release version. - K8s string `json:"k8s,omitempty"` - - // The oc client release version. - OcClient string `json:"ocClient,omitempty"` - - // OCP cluster release version. - Ocp string `json:"ocp,omitempty"` - - // The test-network-function (tnf) release version. - Tnf string `json:"tnf"` - - // The test-network-function (tnf) Git Commit. - TnfGitCommit string `json:"tnfGitCommit,omitempty"` -} - -func (strct *CatalogInfo) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "BestPracticeReference" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "bestPracticeReference" field - buf.WriteString("\"bestPracticeReference\": ") - tmp, err := json.Marshal(strct.BestPracticeReference) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Description" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "description" field - buf.WriteString(",") - buf.WriteString("\"description\": ") - tmp, err = json.Marshal(strct.Description) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "ExceptionProcess" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "exceptionProcess" field - buf.WriteString(",") - buf.WriteString("\"exceptionProcess\": ") - tmp, err = json.Marshal(strct.ExceptionProcess) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Remediation" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "remediation" field - buf.WriteString(",") - buf.WriteString("\"remediation\": ") - tmp, err = json.Marshal(strct.Remediation) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *CatalogInfo) UnmarshalJSON(b []byte) error { - bestPracticeReferenceReceived := false - descriptionReceived := false - exceptionProcessReceived := false - remediationReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "bestPracticeReference": - if err := json.Unmarshal([]byte(v), &strct.BestPracticeReference); err != nil { - return err - } - bestPracticeReferenceReceived = true - case "description": - if err := json.Unmarshal([]byte(v), &strct.Description); err != nil { - return err - } - descriptionReceived = true - case "exceptionProcess": - if err := json.Unmarshal([]byte(v), &strct.ExceptionProcess); err != nil { - return err - } - exceptionProcessReceived = true - case "remediation": - if err := json.Unmarshal([]byte(v), &strct.Remediation); err != nil { - return err - } - remediationReceived = true - default: - return errors.New("additional property not allowed: \"" + k + "\"") //nolint:goconst - } - } - // check if bestPracticeReference (a required property) was received - if !bestPracticeReferenceReceived { - return errors.New("\"bestPracticeReference\" is required but was not present") - } - // check if description (a required property) was received - if !descriptionReceived { - return errors.New("\"description\" is required but was not present") - } - // check if exceptionProcess (a required property) was received - if !exceptionProcessReceived { - return errors.New("\"exceptionProcess\" is required but was not present") - } - // check if remediation (a required property) was received - if !remediationReceived { - return errors.New("\"remediation\" is required but was not present") - } - return nil -} - -func (strct *CategoryClassification) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // Marshal the "Extended" field - buf.WriteString("\"Extended\": ") - tmp, err := json.Marshal(strct.Extended) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "FarEdge" field - buf.WriteString(",") - buf.WriteString("\"FarEdge\": ") - tmp, err = json.Marshal(strct.FarEdge) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "NonTelco" field - buf.WriteString(",") - buf.WriteString("\"NonTelco\": ") - tmp, err = json.Marshal(strct.NonTelco) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "Telco" field - buf.WriteString(",") - buf.WriteString("\"Telco\": ") - tmp, err = json.Marshal(strct.Telco) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *CategoryClassification) UnmarshalJSON(b []byte) error { - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "Extended": - if err := json.Unmarshal([]byte(v), &strct.Extended); err != nil { - return err - } - case "FarEdge": - if err := json.Unmarshal([]byte(v), &strct.FarEdge); err != nil { - return err - } - case "NonTelco": - if err := json.Unmarshal([]byte(v), &strct.NonTelco); err != nil { - return err - } - case "Telco": - if err := json.Unmarshal([]byte(v), &strct.Telco); err != nil { - return err - } - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - return nil -} - -//nolint:funlen -func (strct *Claim) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "Configurations" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "configurations" field - buf.WriteString("\"configurations\": ") - tmp, err := json.Marshal(strct.Configurations) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Metadata" field is required - if strct.Metadata == nil { - return nil, errors.New("metadata is a required field") - } - // Marshal the "metadata" field - buf.WriteString(",") - buf.WriteString("\"metadata\": ") - tmp, err = json.Marshal(strct.Metadata) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Nodes" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "nodes" field - buf.WriteString(",") - buf.WriteString("\"nodes\": ") - tmp, err = json.Marshal(strct.Nodes) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "RawResults" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "rawResults" field - buf.WriteString(",") - buf.WriteString("\"rawResults\": ") - tmp, err = json.Marshal(strct.RawResults) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "results" field - buf.WriteString(",") - buf.WriteString("\"results\": ") - tmp, err = json.Marshal(strct.Results) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Versions" field is required - if strct.Versions == nil { - return nil, errors.New("versions is a required field") - } - // Marshal the "versions" field - buf.WriteString(",") - buf.WriteString("\"versions\": ") - tmp, err = json.Marshal(strct.Versions) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -//nolint:funlen -func (strct *Claim) UnmarshalJSON(b []byte) error { - configurationsReceived := false - metadataReceived := false - nodesReceived := false - rawResultsReceived := false - versionsReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "configurations": - if err := json.Unmarshal([]byte(v), &strct.Configurations); err != nil { - return err - } - configurationsReceived = true - case "metadata": - if err := json.Unmarshal([]byte(v), &strct.Metadata); err != nil { - return err - } - metadataReceived = true - case "nodes": - if err := json.Unmarshal([]byte(v), &strct.Nodes); err != nil { - return err - } - nodesReceived = true - case "rawResults": - if err := json.Unmarshal([]byte(v), &strct.RawResults); err != nil { - return err - } - rawResultsReceived = true - case "results": - if err := json.Unmarshal([]byte(v), &strct.Results); err != nil { - return err - } - case "versions": - if err := json.Unmarshal([]byte(v), &strct.Versions); err != nil { - return err - } - versionsReceived = true - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if configurations (a required property) was received - if !configurationsReceived { - return errors.New("\"configurations\" is required but was not present") - } - // check if metadata (a required property) was received - if !metadataReceived { - return errors.New("\"metadata\" is required but was not present") - } - // check if nodes (a required property) was received - if !nodesReceived { - return errors.New("\"nodes\" is required but was not present") - } - // check if rawResults (a required property) was received - if !rawResultsReceived { - return errors.New("\"rawResults\" is required but was not present") - } - // check if versions (a required property) was received - if !versionsReceived { - return errors.New("\"versions\" is required but was not present") - } - return nil -} - -func (strct *Identifier) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "Id" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "id" field - buf.WriteString("\"id\": ") - tmp, err := json.Marshal(strct.Id) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Suite" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "suite" field - buf.WriteString(",") - buf.WriteString("\"suite\": ") - tmp, err = json.Marshal(strct.Suite) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "tags" field - buf.WriteString(",") - buf.WriteString("\"tags\": ") - tmp, err = json.Marshal(strct.Tags) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *Identifier) UnmarshalJSON(b []byte) error { - idReceived := false - suiteReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "id": - if err := json.Unmarshal([]byte(v), &strct.Id); err != nil { - return err - } - idReceived = true - case "suite": - if err := json.Unmarshal([]byte(v), &strct.Suite); err != nil { - return err - } - suiteReceived = true - case "tags": - if err := json.Unmarshal([]byte(v), &strct.Tags); err != nil { - return err - } - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if id (a required property) was received - if !idReceived { - return errors.New("\"id\" is required but was not present") - } - // check if suite (a required property) was received - if !suiteReceived { - return errors.New("\"suite\" is required but was not present") - } - return nil -} - -func (strct *Metadata) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "EndTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "endTime" field - buf.WriteString("\"endTime\": ") - tmp, err := json.Marshal(strct.EndTime) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "StartTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "startTime" field - buf.WriteString(",") - buf.WriteString("\"startTime\": ") - tmp, err = json.Marshal(strct.StartTime) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *Metadata) UnmarshalJSON(b []byte) error { - endTimeReceived := false - startTimeReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "endTime": //nolint:goconst - if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { - return err - } - endTimeReceived = true - case "startTime": //nolint:goconst - if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { - return err - } - startTimeReceived = true - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if endTime (a required property) was received - if !endTimeReceived { - return errors.New("\"endTime\" is required but was not present") - } - // check if startTime (a required property) was received - if !startTimeReceived { - return errors.New("\"startTime\" is required but was not present") - } - return nil -} - -//nolint:funlen -func (strct *Result) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "CapturedTestOutput" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "capturedTestOutput" field - buf.WriteString("\"capturedTestOutput\": ") - tmp, err := json.Marshal(strct.CapturedTestOutput) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "CatalogInfo" field is required - if strct.CatalogInfo == nil { - return nil, errors.New("catalogInfo is a required field") - } - // Marshal the "catalogInfo" field - buf.WriteString(",") - buf.WriteString("\"catalogInfo\": ") - tmp, err = json.Marshal(strct.CatalogInfo) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "CategoryClassification" field is required - if strct.CategoryClassification == nil { - return nil, errors.New("categoryClassification is a required field") - } - // Marshal the "categoryClassification" field - buf.WriteString(",") - buf.WriteString("\"categoryClassification\": ") - tmp, err = json.Marshal(strct.CategoryClassification) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Duration" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "duration" field - buf.WriteString(",") - buf.WriteString("\"duration\": ") - tmp, err = json.Marshal(strct.Duration) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "endTime" field - buf.WriteString(",") - buf.WriteString("\"endTime\": ") - tmp, err = json.Marshal(strct.EndTime) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "FailureLineContent" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "failureLineContent" field - buf.WriteString(",") - buf.WriteString("\"failureLineContent\": ") - tmp, err = json.Marshal(strct.FailureLineContent) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "FailureLocation" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "failureLocation" field - buf.WriteString(",") - buf.WriteString("\"failureLocation\": ") - tmp, err = json.Marshal(strct.FailureLocation) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "FailureReason" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "failureReason" field - buf.WriteString(",") - buf.WriteString("\"failureReason\": ") - tmp, err = json.Marshal(strct.FailureReason) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "StartTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "startTime" field - buf.WriteString(",") - buf.WriteString("\"startTime\": ") - tmp, err = json.Marshal(strct.StartTime) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "State" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "state" field - buf.WriteString(",") - buf.WriteString("\"state\": ") - tmp, err = json.Marshal(strct.State) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "TestID" field is required - if strct.TestID == nil { - return nil, errors.New("testID is a required field") - } - // Marshal the "testID" field - buf.WriteString(",") - buf.WriteString("\"testID\": ") - tmp, err = json.Marshal(strct.TestID) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -//nolint:funlen,gocyclo -func (strct *Result) UnmarshalJSON(b []byte) error { - capturedTestOutputReceived := false - catalogInfoReceived := false - categoryClassificationReceived := false - durationReceived := false - failureLineContentReceived := false - failureLocationReceived := false - failureReasonReceived := false - startTimeReceived := false - stateReceived := false - testIDReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "capturedTestOutput": - if err := json.Unmarshal([]byte(v), &strct.CapturedTestOutput); err != nil { - return err - } - capturedTestOutputReceived = true - case "catalogInfo": - if err := json.Unmarshal([]byte(v), &strct.CatalogInfo); err != nil { - return err - } - catalogInfoReceived = true - case "categoryClassification": - if err := json.Unmarshal([]byte(v), &strct.CategoryClassification); err != nil { - return err - } - categoryClassificationReceived = true - case "duration": - if err := json.Unmarshal([]byte(v), &strct.Duration); err != nil { - return err - } - durationReceived = true - case "endTime": - if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { - return err - } - case "failureLineContent": - if err := json.Unmarshal([]byte(v), &strct.FailureLineContent); err != nil { - return err - } - failureLineContentReceived = true - case "failureLocation": - if err := json.Unmarshal([]byte(v), &strct.FailureLocation); err != nil { - return err - } - failureLocationReceived = true - case "failureReason": - if err := json.Unmarshal([]byte(v), &strct.FailureReason); err != nil { - return err - } - failureReasonReceived = true - case "startTime": - if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { - return err - } - startTimeReceived = true - case "state": - if err := json.Unmarshal([]byte(v), &strct.State); err != nil { - return err - } - stateReceived = true - case "testID": - if err := json.Unmarshal([]byte(v), &strct.TestID); err != nil { - return err - } - testIDReceived = true - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if capturedTestOutput (a required property) was received - if !capturedTestOutputReceived { - return errors.New("\"capturedTestOutput\" is required but was not present") - } - // check if catalogInfo (a required property) was received - if !catalogInfoReceived { - return errors.New("\"catalogInfo\" is required but was not present") - } - // check if categoryClassification (a required property) was received - if !categoryClassificationReceived { - return errors.New("\"categoryClassification\" is required but was not present") - } - // check if duration (a required property) was received - if !durationReceived { - return errors.New("\"duration\" is required but was not present") - } - // check if failureLineContent (a required property) was received - if !failureLineContentReceived { - return errors.New("\"failureLineContent\" is required but was not present") - } - // check if failureLocation (a required property) was received - if !failureLocationReceived { - return errors.New("\"failureLocation\" is required but was not present") - } - // check if failureReason (a required property) was received - if !failureReasonReceived { - return errors.New("\"failureReason\" is required but was not present") - } - // check if startTime (a required property) was received - if !startTimeReceived { - return errors.New("\"startTime\" is required but was not present") - } - // check if state (a required property) was received - if !stateReceived { - return errors.New("\"state\" is required but was not present") - } - // check if testID (a required property) was received - if !testIDReceived { - return errors.New("\"testID\" is required but was not present") - } - return nil -} - -func (strct *Root) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "Claim" field is required - if strct.Claim == nil { - return nil, errors.New("claim is a required field") - } - // Marshal the "claim" field - buf.WriteString("\"claim\": ") - tmp, err := json.Marshal(strct.Claim) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *Root) UnmarshalJSON(b []byte) error { - claimReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "claim": - if err := json.Unmarshal([]byte(v), &strct.Claim); err != nil { - return err - } - claimReceived = true - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if claim (a required property) was received - if !claimReceived { - return errors.New("\"claim\" is required but was not present") - } - return nil -} - -func (strct *Versions) MarshalJSON() ([]byte, error) { - buf := bytes.NewBuffer(make([]byte, 0)) - buf.WriteString("{") - // "ClaimFormat" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "claimFormat" field - buf.WriteString("\"claimFormat\": ") - tmp, err := json.Marshal(strct.ClaimFormat) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "k8s" field - buf.WriteString(",") - buf.WriteString("\"k8s\": ") - tmp, err = json.Marshal(strct.K8s) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "ocClient" field - buf.WriteString(",") - buf.WriteString("\"ocClient\": ") - tmp, err = json.Marshal(strct.OcClient) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "ocp" field - buf.WriteString(",") - buf.WriteString("\"ocp\": ") - tmp, err = json.Marshal(strct.Ocp) - if err != nil { - return nil, err - } - buf.Write(tmp) - // "Tnf" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "tnf" field - buf.WriteString(",") - buf.WriteString("\"tnf\": ") - tmp, err = json.Marshal(strct.Tnf) - if err != nil { - return nil, err - } - buf.Write(tmp) - // Marshal the "tnfGitCommit" field - buf.WriteString(",") - buf.WriteString("\"tnfGitCommit\": ") - tmp, err = json.Marshal(strct.TnfGitCommit) - if err != nil { - return nil, err - } - buf.Write(tmp) - - buf.WriteString("}") - rv := buf.Bytes() - return rv, nil -} - -func (strct *Versions) UnmarshalJSON(b []byte) error { - claimFormatReceived := false - tnfReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "claimFormat": - if err := json.Unmarshal([]byte(v), &strct.ClaimFormat); err != nil { - return err - } - claimFormatReceived = true - case "k8s": - if err := json.Unmarshal([]byte(v), &strct.K8s); err != nil { - return err - } - case "ocClient": - if err := json.Unmarshal([]byte(v), &strct.OcClient); err != nil { - return err - } - case "ocp": - if err := json.Unmarshal([]byte(v), &strct.Ocp); err != nil { - return err - } - case "tnf": - if err := json.Unmarshal([]byte(v), &strct.Tnf); err != nil { - return err - } - tnfReceived = true - case "tnfGitCommit": - if err := json.Unmarshal([]byte(v), &strct.TnfGitCommit); err != nil { - return err - } - default: - return errors.New("additional property not allowed: \"" + k + "\"") - } - } - // check if claimFormat (a required property) was received - if !claimFormatReceived { - return errors.New("\"claimFormat\" is required but was not present") - } - // check if tnf (a required property) was received - if !tnfReceived { - return errors.New("\"tnf\" is required but was not present") - } - return nil -} diff --git a/pkg/claim/schema_test.go b/pkg/claim/schema_test.go deleted file mode 100644 index 5298766d0..000000000 --- a/pkg/claim/schema_test.go +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (C) 2020 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -package claim - -import ( - "encoding/json" - "fmt" - "os" - "path" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" -) - -type testCase struct { - expectedMarshallJSONError bool - expectedStartTime string - expectedEndTime string -} - -var testCases = map[string]*testCase{ - "claim-valid": { - expectedMarshallJSONError: false, - expectedStartTime: "1970-01-01T10:05:08+01:00", - expectedEndTime: "1970-01-01T10:05:08+01:00", - }, - "claim-invalid-junit-payload": { - expectedMarshallJSONError: true, - }, - "claim-invalid-additional-property": { - expectedMarshallJSONError: true, - }, - "claim-invalid-bool-results": { - expectedMarshallJSONError: true, - }, - // A little confusing; since we remap the "results" field, this interface{} value is not actually checked. - // This is a limitation of the JSON Schema go client generator, and is perfectly fine for this context. - "claim-invalid-non-result-result": { - expectedMarshallJSONError: false, - }, - "invalid-json": { - expectedMarshallJSONError: true, - }, - "missing-claim": { - expectedMarshallJSONError: true, - }, -} - -func getTestFile(testCaseName string) string { - return path.Join("testdata", testCaseName+".json") -} - -func getTestFileContents(testCaseName string) ([]byte, error) { - testFilePath := getTestFile(testCaseName) - return os.ReadFile(testFilePath) -} - -func TestRoot_MarshalJSON(t *testing.T) { - for testCaseName, testCaseDefinition := range testCases { - contents, err := getTestFileContents(testCaseName) - - // raw data read tests - assert.Nil(t, err) - assert.NotNil(t, contents) - - // try to UnmarshallJSON the input - root := &Root{} - err = json.Unmarshal(contents, root) - fmt.Println(testCaseName) - assert.Equal(t, testCaseDefinition.expectedMarshallJSONError, err != nil) - - if testCaseDefinition.expectedMarshallJSONError == false { - // start time assertion - assert.Equal(t, "1970-01-01T10:05:08+01:00", root.Claim.Metadata.StartTime) - assert.Equal(t, "1970-01-01T10:05:08+01:00", root.Claim.Metadata.EndTime) - - generatedContents, err := json.Marshal(root) - assert.Nil(t, err) - assert.NotNil(t, generatedContents) - } - } -} - -func TestResult_MarshalJSON(t *testing.T) { - type fields struct { - CapturedTestOutput string - CatalogInfo *CatalogInfo - CategoryClassification *CategoryClassification - Duration int - EndTime string - FailureLineContent string - FailureLocation string - FailureReason string - StartTime string - State string - TestID *Identifier - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - // TODO: Add test cases - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - strct := &Result{ - CapturedTestOutput: tt.fields.CapturedTestOutput, - CatalogInfo: tt.fields.CatalogInfo, - CategoryClassification: tt.fields.CategoryClassification, - Duration: tt.fields.Duration, - EndTime: tt.fields.EndTime, - FailureLineContent: tt.fields.FailureLineContent, - FailureLocation: tt.fields.FailureLocation, - FailureReason: tt.fields.FailureReason, - StartTime: tt.fields.StartTime, - State: tt.fields.State, - TestID: tt.fields.TestID, - } - got, err := strct.MarshalJSON() - if (err != nil) != tt.wantErr { - t.Errorf("Result.MarshalJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Result.MarshalJSON() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestResult_UnmarshalJSON(t *testing.T) { - type args struct { - b []byte - } - tests := []struct { - name string - want *Result - args args - wantErr bool - }{ - { - name: "ok", - want: &Result{ - //nolint:lll - CapturedTestOutput: "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", - CatalogInfo: &CatalogInfo{ - BestPracticeReference: "https://test-network-function.github.io/cnf-best-practices/#cnf-best-practices-image-standards", - //nolint:lll - Description: "Ensures that the Container Base Image is not altered post-startup. This test is a heuristic, and ensures that there are no changes to the following directories: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64", - ExceptionProcess: "No exceptions", - //nolint:lll - Remediation: "Ensure that Container applications do not modify the Container Base Image. In particular, ensure that the following directories are not modified: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64 Ensure that all required binaries are built directly into the container image, and are not installed post startup.", - }, - CategoryClassification: &CategoryClassification{ - Extended: "Mandatory", - FarEdge: "Mandatory", - NonTelco: "Mandatory", - Telco: "Mandatory", - }, - Duration: 7745320473, - EndTime: "2023-07-25 09:10:25.557493221 -0500 CDT m=+51.038323513", - FailureLineContent: "", - FailureLocation: ":0", - FailureReason: "", - StartTime: "2023-07-25 09:10:17.812172748 -0500 CDT m=+43.293003040", - State: "passed", - TestID: &Identifier{ - Id: "platform-alteration-base-image", - Suite: "platform-alteration", - Tags: "common", - }, - }, - //nolint:lll - args: args{b: []byte(` - { - "capturedTestOutput": "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", - "catalogInfo": { - "bestPracticeReference": "https://test-network-function.github.io/cnf-best-practices/#cnf-best-practices-image-standards", - "description": "Ensures that the Container Base Image is not altered post-startup. This test is a heuristic, and ensures that there are no changes to the following directories: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64", - "exceptionProcess": "No exceptions", - "remediation": "Ensure that Container applications do not modify the Container Base Image. In particular, ensure that the following directories are not modified: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64 Ensure that all required binaries are built directly into the container image, and are not installed post startup." - }, - "categoryClassification": { - "Extended": "Mandatory", - "FarEdge": "Mandatory", - "NonTelco": "Mandatory", - "Telco": "Mandatory" - }, - "duration": 7745320473, - "endTime": "2023-07-25 09:10:25.557493221 -0500 CDT m=+51.038323513", - "failureLineContent": "", - "failureLocation": ":0", - "failureReason": "", - "startTime": "2023-07-25 09:10:17.812172748 -0500 CDT m=+43.293003040", - "state": "passed", - "testID": { - "id": "platform-alteration-base-image", - "suite": "platform-alteration", - "tags": "common" - } - } - `)}, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := &Result{} - if err := got.UnmarshalJSON(tt.args.b); (err != nil) != tt.wantErr { - t.Errorf("Result.UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) - } - deepEqual(got, tt.want) - }) - } -} - -func deepEqual(r1, r2 *Result) bool { - r1Nil, r2Nil := r1, r2 - r1Nil.TestID = nil - r1Nil.CategoryClassification = nil - r1Nil.CatalogInfo = nil - r2Nil.TestID = nil - r2Nil.CategoryClassification = nil - r2Nil.CatalogInfo = nil - - equal := reflect.DeepEqual(r1, r2) - if !equal { - return false - } - equal = reflect.DeepEqual(r1.CategoryClassification, r2.CategoryClassification) - if !equal { - return false - } - reflect.DeepEqual(r1.TestID, r2.TestID) - if !equal { - return false - } - reflect.DeepEqual(r1.CatalogInfo, r2.CatalogInfo) - - return equal -} diff --git a/pkg/claim/testdata/claim-invalid-additional-property.json b/pkg/claim/testdata/claim-invalid-additional-property.json deleted file mode 100644 index 0f52ee9c7..000000000 --- a/pkg/claim/testdata/claim-invalid-additional-property.json +++ /dev/null @@ -1,468 +0,0 @@ -{ - "anAdditionalPropertyInTheRootPayload": "shouldCauseAMarshalError", - "claim": { - "metadata": { - "startTime": "1970-01-01T10:05:08+01:00", - "endTime": "1970-01-01T10:05:08+01:00" - }, - "versions": { - "tnf": "v0.0.1", - "claimFormat":"v0.0.1" - }, - "configurations": {}, - "rawResults": { - "name": "CNF Certification Test Suite", - "tests": "7", - "failures": "1", - "errors": "0", - "time": "16.374", - "testcase": [ - { - "name": "cisco_kiknos when partner(partner) creates an IPSEC tunnel should report the tunnel was created through the CLI", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - }, - { - "name": "cisco_kiknos when partner(partner) creates an IPSEC tunnel should pass ICMP traffic", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - }, - { - "name": "cisco_kiknos when partner(partner) creates an IPSEC tunnel should pass UDP traffic", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - }, - { - "name": "generic Both Pods are on the Default network when a Ping is issued from ikester(ikester) to partner(partner) 172.17.0.6 partner(partner) should reply", - "classname": "CNF Certification Test Suite", - "time": "4.078620157" - }, - { - "name": "generic Both Pods are on the Default network when a Ping is issued from partner(partner) to ikester(ikester) 172.17.0.4 ikester(ikester) should reply", - "classname": "CNF Certification Test Suite", - "time": "4.095576392" - }, - { - "name": "generic Both Pods are on the Default network when a Ping is issued from test(test) to partner(partner) 172.17.0.6 partner(partner) should reply", - "classname": "CNF Certification Test Suite", - "time": "4.096696259" - }, - { - "name": "generic Both Pods are on the Default network when a Ping is issued from partner(partner) to test(test) 172.17.0.7 test(test) should reply", - "classname": "CNF Certification Test Suite", - "time": "4.096464621" - }, - { - "name": "generic when test(test) is checked for Red Hat version Should report a proper Red Hat version", - "classname": "CNF Certification Test Suite", - "time": "0.002463245" - }, - { - "name": "generic when ikester(ikester) is checked for Red Hat version Should report a proper Red Hat version", - "classname": "CNF Certification Test Suite", - "time": "0.001596069", - "failure": { - "type": "Failure", - "#text": "/Users/ryangoulding/workspace/test-network-function/test-network-function/generic/generic_cnf_tests.go:135\nExpected\n : 1\nto equal\n : 0\n/Users/ryangoulding/workspace/test-network-function/test-network-function/generic/generic_cnf_tests.go:140" - } - }, - { - "name": "generic when partner(partner) is checked for Red Hat version Should report a proper Red Hat version", - "classname": "CNF Certification Test Suite", - "time": "0.002391653" - }, - { - "name": "casa-cnf when Registrations are polled from the \"nfregistrations.mgmt.casa.io\" Custom Resource The appropriate registrations should be reported", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - }, - { - "name": "casa-cnf when nrf1(AMF) is checked for registration Should be registered", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - }, - { - "name": "casa-cnf when nrf1(SMF) is checked for registration Should be registered", - "classname": "CNF Certification Test Suite", - "time": "0", - "skipped": [] - } - ] - }, - "results": { - "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - }, - "nodes": { - "host1": { - "lshwOutput": { - "id": "raspberrypi", - "class": "system", - "claimed": true, - "description": "ARMv7 Processor rev 4 (v7l)", - "product": "Raspberry Pi 3 Model B Plus Rev 1.3", - "serial": "000000006b968331", - "width": 32, - "capabilities": { - "smp": "Symmetric Multi-Processing" - }, - "children": [ - { - "id": "core", - "class": "bus", - "claimed": true, - "description": "Motherboard", - "physid": "0", - "children": [ - { - "id": "cpu:0", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "0", - "businfo": "cpu@0", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:1", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "1", - "businfo": "cpu@1", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:2", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "2", - "businfo": "cpu@2", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:3", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "3", - "businfo": "cpu@3", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "memory", - "class": "memory", - "claimed": true, - "description": "System memory", - "physid": "4", - "units": "bytes", - "size": 971063296 - } - ] - }, - { - "id": "usbhost", - "class": "bus", - "claimed": true, - "handle": "USB:1:1", - "product": "DWC OTG Controller", - "vendor": "Linux 4.19.66-v7+ dwc_otg_hcd", - "physid": "1", - "businfo": "usb@1", - "logicalname": "usb1", - "version": "4.19", - "configuration": { - "driver": "hub", - "slots": "1", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb", - "class": "bus", - "claimed": true, - "handle": "USB:1:2", - "description": "USB hub", - "product": "USB 2.0 Hub", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1", - "version": "b.b3", - "configuration": { - "driver": "hub", - "maxpower": "2mA", - "slots": "4", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb:0", - "class": "bus", - "claimed": true, - "handle": "USB:1:3", - "description": "USB hub", - "product": "USB 2.0 Hub", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1.1", - "version": "b.b3", - "configuration": { - "driver": "hub", - "maxpower": "2mA", - "slots": "3", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb", - "class": "generic", - "claimed": true, - "handle": "USB:1:5", - "description": "Generic USB device", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1.1.1", - "version": "3.00", - "configuration": { - "driver": "lan78xx", - "maxpower": "2mA", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.10": true - } - } - ] - }, - { - "id": "usb:1", - "class": "printer", - "claimed": true, - "handle": "USB:1:4", - "description": "Printer", - "product": "MP490 series", - "vendor": "Canon", - "physid": "2", - "businfo": "usb@1:1.2", - "logicalname": "scsi0", - "version": "0.02", - "serial": "0217F4", - "configuration": { - "driver": "usb-storage", - "maxpower": "2mA", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0", - "bidirectional": "Bidirectional", - "emulated": "Emulated device" - }, - "children": [ - { - "id": "disk", - "class": "disk", - "claimed": true, - "handle": "SCSI:00:00:00:00", - "description": "SCSI Disk", - "product": "MP490 series", - "vendor": "Canon", - "physid": "0.0.0", - "businfo": "scsi@0:0.0.0", - "logicalname": "/dev/sda", - "dev": "8:0", - "version": "0102", - "configuration": { - "ansiversion": "2", - "logicalsectorsize": "512", - "sectorsize": "512" - }, - "capabilities": { - "removable": "support is removable" - }, - "children": [ - { - "id": "medium", - "class": "disk", - "claimed": true, - "physid": "0", - "logicalname": "/dev/sda", - "dev": "8:0" - } - ] - } - ] - } - ] - } - ] - }, - { - "id": "network:0", - "class": "network", - "claimed": true, - "description": "Ethernet interface", - "physid": "2", - "logicalname": "eth0", - "serial": "b8:27:eb:96:83:31", - "units": "bit/s", - "size": 10000000, - "capacity": 1000000000, - "configuration": { - "autonegotiation": "on", - "broadcast": "yes", - "driver": "lan78xx", - "duplex": "half", - "link": "no", - "multicast": "yes", - "port": "MII", - "speed": "10Mbit/s" - }, - "capabilities": { - "ethernet": true, - "physical": "Physical interface", - "tp": "twisted pair", - "mii": "Media Independent Interface", - "10bt": "10Mbit/s", - "10bt-fd": "10Mbit/s (full duplex)", - "100bt": "100Mbit/s", - "100bt-fd": "100Mbit/s (full duplex)", - "1000bt-fd": "1Gbit/s (full duplex)", - "autonegotiation": "Auto-negotiation" - } - }, - { - "id": "network:1", - "class": "network", - "claimed": true, - "description": "Wireless interface", - "physid": "3", - "logicalname": "wlan0", - "serial": "b8:27:eb:c3:d6:64", - "configuration": { - "broadcast": "yes", - "driver": "brcmfmac", - "driverversion": "7.45.154", - "firmware": "01-4fbe0b04", - "ip": "192.168.1.5", - "multicast": "yes", - "wireless": "IEEE 802.11" - }, - "capabilities": { - "ethernet": true, - "physical": "Physical interface", - "wireless": "Wireless-LAN" - } - } - ] - } - } - } - } -} diff --git a/pkg/claim/testdata/claim-invalid-bool-results.json b/pkg/claim/testdata/claim-invalid-bool-results.json deleted file mode 100644 index ac26f4d6a..000000000 --- a/pkg/claim/testdata/claim-invalid-bool-results.json +++ /dev/null @@ -1,220 +0,0 @@ -{ - "claim": { - "configurations": { - "generic": { - "containersUnderTest": { - "{\"namespace\":\"default\",\"podName\":\"vendor-container1-649d949d4c-stxcc\",\"containerName\":\"vendor-container1\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - }, - "{\"namespace\":\"default\",\"podName\":\"vendor-container2-98f77dfbc-6c6dc\",\"containerName\":\"vendor-container2\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - } - }, - "partnerContainers": { - "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.1" - ] - } - }, - "testOrchestrator": "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}" - } - }, - "metadata": { - "endTime": "1970-01-01T10:05:08+01:00", - "startTime": "1970-01-01T10:05:08+01:00" - }, - "nodes": { - "apiVersion": "v1", - "items": [ - { - "apiVersion": "v1", - "kind": "Node", - "metadata": { - "annotations": { - "machineconfiguration.openshift.io/currentConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/desiredConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/reason": "", - "machineconfiguration.openshift.io/state": "Done", - "volumes.kubernetes.io/controller-managed-attach-detach": "true" - }, - "creationTimestamp": "2020-11-13T16:42:44Z", - "labels": { - "beta.kubernetes.io/arch": "amd64", - "beta.kubernetes.io/os": "linux", - "kubernetes.io/arch": "amd64", - "kubernetes.io/hostname": "master-0", - "kubernetes.io/os": "linux", - "node-role.kubernetes.io/master": "", - "node.openshift.io/os_id": "rhcos" - }, - "name": "master-0", - "resourceVersion": "22191357", - "selfLink": "/api/v1/nodes/master-0", - "uid": "e0c8fac4-07dd-4dd3-a181-9415d30f4235" - }, - "spec": {}, - "status": { - "addresses": [ - { - "address": "192.168.1.110", - "type": "InternalIP" - }, - { - "address": "master-0", - "type": "Hostname" - } - ], - "allocatable": { - "cpu": "79500m", - "ephemeral-storage": "1078575967288", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "190981Mi", - "pods": "250" - }, - "capacity": { - "cpu": "80", - "ephemeral-storage": "1144038Mi", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "192105Mi", - "pods": "250" - }, - "conditions": [ - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient memory available", - "reason": "KubeletHasSufficientMemory", - "status": "False", - "type": "MemoryPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has no disk pressure", - "reason": "KubeletHasNoDiskPressure", - "status": "False", - "type": "DiskPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient PID available", - "reason": "KubeletHasSufficientPID", - "status": "False", - "type": "PIDPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet is posting ready status", - "reason": "KubeletReady", - "status": "True", - "type": "Ready" - } - ], - "daemonEndpoints": { - "kubeletEndpoint": { - "Port": 10250 - } - }, - "images": [ - { - "names": [ - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:8cea2679f40cd5e5bb95b7f511d444ea7ad74800bcc366d0129eb682459cdffd", - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:" - ], - "sizeBytes": 819896785 - } - ], - "nodeInfo": { - "architecture": "amd64", - "bootID": "f24d12e7-202b-4978-bf70-f96f1b5ea3bd", - "containerRuntimeVersion": "cri-o://1.17.4-8.dev.rhaos4.4.git5f5c5e4.el8", - "kernelVersion": "4.18.0-147.8.1.el8_1.x86_64", - "kubeProxyVersion": "v1.17.1", - "kubeletVersion": "v1.17.1", - "machineID": "89842748b08741f99dd5db5433ae16b6", - "operatingSystem": "linux", - "osImage": "Red Hat Enterprise Linux CoreOS 44.81.202004260825-0 (Ootpa)", - "systemUUID": "80ff6508-d095-e711-906e-0017a4403562" - } - } - } - ], - "kind": "List", - "metadata": { - "resourceVersion": "", - "selfLink": "" - } - }, - "results": { - "identifier": { - "url": "https://test-network-function.com/tnf/test", - "version": "v1.0.0" - }, - "results": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - }, - "rawResults": { - "cnf-certification-tests_junit": { - "testsuite": { - "-errors": "0", - "-failures": "0", - "-name": "CNF Certification Test Suite", - "-tests": "5", - "-time": "8.376", - "testcase": [ - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from test(test) to partner(partner) 10.130.4.64 partner(partner) should reply", - "-time": "4.132041197" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from partner(partner) to test(test) 10.128.8.3 test(test) should reply", - "-time": "4.102927471" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when test(test) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002270972" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when partner(partner) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002174817" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "diagnostic when a cluster is set up and installed with OpenShift should report all available nodeSummary", - "-time": "0.133763681" - } - ] - } - } - }, - "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" - }, - "results": false - } -} \ No newline at end of file diff --git a/pkg/claim/testdata/claim-invalid-junit-payload.json b/pkg/claim/testdata/claim-invalid-junit-payload.json deleted file mode 100644 index 60a201aa3..000000000 --- a/pkg/claim/testdata/claim-invalid-junit-payload.json +++ /dev/null @@ -1,384 +0,0 @@ -{ - "claim": { - "metadata": { - "startTime": "1970-01-01T10:05:08+01:00", - "endTime": "1970-01-01T10:05:08+01:00" - }, - "versions": { - "tnf": "v0.0.1", - "claimFormat":"v0.0.1" - }, - "configurations": {}, - "rawResults": false, - "results": { - "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - }, - "nodes": { - "host1": { - "lshwOutput": { - "id": "raspberrypi", - "class": "system", - "claimed": true, - "description": "ARMv7 Processor rev 4 (v7l)", - "product": "Raspberry Pi 3 Model B Plus Rev 1.3", - "serial": "000000006b968331", - "width": 32, - "capabilities": { - "smp": "Symmetric Multi-Processing" - }, - "children": [ - { - "id": "core", - "class": "bus", - "claimed": true, - "description": "Motherboard", - "physid": "0", - "children": [ - { - "id": "cpu:0", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "0", - "businfo": "cpu@0", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:1", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "1", - "businfo": "cpu@1", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:2", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "2", - "businfo": "cpu@2", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "cpu:3", - "class": "processor", - "claimed": true, - "description": "CPU", - "product": "cpu", - "physid": "3", - "businfo": "cpu@3", - "units": "Hz", - "size": 1400000000, - "capacity": 1400000000, - "capabilities": { - "half": "Unknown", - "thumb": "Thumb instruction set", - "fastmult": "Fast Multiplication", - "vfp": "VFP (vector floating point instructions)", - "edsp": "DSP extensions", - "neon": "NEON aka MPE - Media Processing Engine", - "vfpv3": "VFP version 3", - "tls": "TLS register", - "vfpv4": "VFP version 4", - "idiva": "SDIV and UDIV hardware division in ARM mode", - "idivt": "SDIV and UDIV hardware division in Thumb mode", - "vfpd32": "Unknown", - "lpae": "Large Physical Address Extension architecture", - "evtstrm": "Unknown", - "crc32": true, - "cpufreq": "CPU Frequency scaling" - } - }, - { - "id": "memory", - "class": "memory", - "claimed": true, - "description": "System memory", - "physid": "4", - "units": "bytes", - "size": 971063296 - } - ] - }, - { - "id": "usbhost", - "class": "bus", - "claimed": true, - "handle": "USB:1:1", - "product": "DWC OTG Controller", - "vendor": "Linux 4.19.66-v7+ dwc_otg_hcd", - "physid": "1", - "businfo": "usb@1", - "logicalname": "usb1", - "version": "4.19", - "configuration": { - "driver": "hub", - "slots": "1", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb", - "class": "bus", - "claimed": true, - "handle": "USB:1:2", - "description": "USB hub", - "product": "USB 2.0 Hub", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1", - "version": "b.b3", - "configuration": { - "driver": "hub", - "maxpower": "2mA", - "slots": "4", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb:0", - "class": "bus", - "claimed": true, - "handle": "USB:1:3", - "description": "USB hub", - "product": "USB 2.0 Hub", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1.1", - "version": "b.b3", - "configuration": { - "driver": "hub", - "maxpower": "2mA", - "slots": "3", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0" - }, - "children": [ - { - "id": "usb", - "class": "generic", - "claimed": true, - "handle": "USB:1:5", - "description": "Generic USB device", - "vendor": "Standard Microsystems Corp.", - "physid": "1", - "businfo": "usb@1:1.1.1", - "version": "3.00", - "configuration": { - "driver": "lan78xx", - "maxpower": "2mA", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.10": true - } - } - ] - }, - { - "id": "usb:1", - "class": "printer", - "claimed": true, - "handle": "USB:1:4", - "description": "Printer", - "product": "MP490 series", - "vendor": "Canon", - "physid": "2", - "businfo": "usb@1:1.2", - "logicalname": "scsi0", - "version": "0.02", - "serial": "0217F4", - "configuration": { - "driver": "usb-storage", - "maxpower": "2mA", - "speed": "480Mbit/s" - }, - "capabilities": { - "usb-2.00": "USB 2.0", - "bidirectional": "Bidirectional", - "emulated": "Emulated device" - }, - "children": [ - { - "id": "disk", - "class": "disk", - "claimed": true, - "handle": "SCSI:00:00:00:00", - "description": "SCSI Disk", - "product": "MP490 series", - "vendor": "Canon", - "physid": "0.0.0", - "businfo": "scsi@0:0.0.0", - "logicalname": "/dev/sda", - "dev": "8:0", - "version": "0102", - "configuration": { - "ansiversion": "2", - "logicalsectorsize": "512", - "sectorsize": "512" - }, - "capabilities": { - "removable": "support is removable" - }, - "children": [ - { - "id": "medium", - "class": "disk", - "claimed": true, - "physid": "0", - "logicalname": "/dev/sda", - "dev": "8:0" - } - ] - } - ] - } - ] - } - ] - }, - { - "id": "network:0", - "class": "network", - "claimed": true, - "description": "Ethernet interface", - "physid": "2", - "logicalname": "eth0", - "serial": "b8:27:eb:96:83:31", - "units": "bit/s", - "size": 10000000, - "capacity": 1000000000, - "configuration": { - "autonegotiation": "on", - "broadcast": "yes", - "driver": "lan78xx", - "duplex": "half", - "link": "no", - "multicast": "yes", - "port": "MII", - "speed": "10Mbit/s" - }, - "capabilities": { - "ethernet": true, - "physical": "Physical interface", - "tp": "twisted pair", - "mii": "Media Independent Interface", - "10bt": "10Mbit/s", - "10bt-fd": "10Mbit/s (full duplex)", - "100bt": "100Mbit/s", - "100bt-fd": "100Mbit/s (full duplex)", - "1000bt-fd": "1Gbit/s (full duplex)", - "autonegotiation": "Auto-negotiation" - } - }, - { - "id": "network:1", - "class": "network", - "claimed": true, - "description": "Wireless interface", - "physid": "3", - "logicalname": "wlan0", - "serial": "b8:27:eb:c3:d6:64", - "configuration": { - "broadcast": "yes", - "driver": "brcmfmac", - "driverversion": "7.45.154", - "firmware": "01-4fbe0b04", - "ip": "192.168.1.5", - "multicast": "yes", - "wireless": "IEEE 802.11" - }, - "capabilities": { - "ethernet": true, - "physical": "Physical interface", - "wireless": "Wireless-LAN" - } - } - ] - } - } - } - } -} diff --git a/pkg/claim/testdata/claim-invalid-non-result-result.json b/pkg/claim/testdata/claim-invalid-non-result-result.json deleted file mode 100644 index 6008bcf71..000000000 --- a/pkg/claim/testdata/claim-invalid-non-result-result.json +++ /dev/null @@ -1,226 +0,0 @@ -{ - "claim": { - "configurations": { - "generic": { - "containersUnderTest": { - "{\"namespace\":\"default\",\"podName\":\"vendor-container1-649d949d4c-stxcc\",\"containerName\":\"vendor-container1\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - }, - "{\"namespace\":\"default\",\"podName\":\"vendor-container2-98f77dfbc-6c6dc\",\"containerName\":\"vendor-container2\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - } - }, - "partnerContainers": { - "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.1" - ] - } - }, - "testOrchestrator": "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}" - } - }, - "metadata": { - "endTime": "1970-01-01T10:05:08+01:00", - "startTime": "1970-01-01T10:05:08+01:00" - }, - "nodes": { - "apiVersion": "v1", - "items": [ - { - "apiVersion": "v1", - "kind": "Node", - "metadata": { - "annotations": { - "machineconfiguration.openshift.io/currentConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/desiredConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/reason": "", - "machineconfiguration.openshift.io/state": "Done", - "volumes.kubernetes.io/controller-managed-attach-detach": "true" - }, - "creationTimestamp": "2020-11-13T16:42:44Z", - "labels": { - "beta.kubernetes.io/arch": "amd64", - "beta.kubernetes.io/os": "linux", - "kubernetes.io/arch": "amd64", - "kubernetes.io/hostname": "master-0", - "kubernetes.io/os": "linux", - "node-role.kubernetes.io/master": "", - "node.openshift.io/os_id": "rhcos" - }, - "name": "master-0", - "resourceVersion": "22191357", - "selfLink": "/api/v1/nodes/master-0", - "uid": "e0c8fac4-07dd-4dd3-a181-9415d30f4235" - }, - "spec": {}, - "status": { - "addresses": [ - { - "address": "192.168.1.110", - "type": "InternalIP" - }, - { - "address": "master-0", - "type": "Hostname" - } - ], - "allocatable": { - "cpu": "79500m", - "ephemeral-storage": "1078575967288", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "190981Mi", - "pods": "250" - }, - "capacity": { - "cpu": "80", - "ephemeral-storage": "1144038Mi", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "192105Mi", - "pods": "250" - }, - "conditions": [ - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient memory available", - "reason": "KubeletHasSufficientMemory", - "status": "False", - "type": "MemoryPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has no disk pressure", - "reason": "KubeletHasNoDiskPressure", - "status": "False", - "type": "DiskPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient PID available", - "reason": "KubeletHasSufficientPID", - "status": "False", - "type": "PIDPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet is posting ready status", - "reason": "KubeletReady", - "status": "True", - "type": "Ready" - } - ], - "daemonEndpoints": { - "kubeletEndpoint": { - "Port": 10250 - } - }, - "images": [ - { - "names": [ - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:8cea2679f40cd5e5bb95b7f511d444ea7ad74800bcc366d0129eb682459cdffd", - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:" - ], - "sizeBytes": 819896785 - } - ], - "nodeInfo": { - "architecture": "amd64", - "bootID": "f24d12e7-202b-4978-bf70-f96f1b5ea3bd", - "containerRuntimeVersion": "cri-o://1.17.4-8.dev.rhaos4.4.git5f5c5e4.el8", - "kernelVersion": "4.18.0-147.8.1.el8_1.x86_64", - "kubeProxyVersion": "v1.17.1", - "kubeletVersion": "v1.17.1", - "machineID": "89842748b08741f99dd5db5433ae16b6", - "operatingSystem": "linux", - "osImage": "Red Hat Enterprise Linux CoreOS 44.81.202004260825-0 (Ootpa)", - "systemUUID": "80ff6508-d095-e711-906e-0017a4403562" - } - } - } - ], - "kind": "List", - "metadata": { - "resourceVersion": "", - "selfLink": "" - } - }, - "results": { - "identifier": { - "url": "https://test-network-function.com/tnf/test", - "version": "v1.0.0" - }, - "results": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - }, - "rawResults": { - "cnf-certification-tests_junit": { - "testsuite": { - "-errors": "0", - "-failures": "0", - "-name": "CNF Certification Test Suite", - "-tests": "5", - "-time": "8.376", - "testcase": [ - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from test(test) to partner(partner) 10.130.4.64 partner(partner) should reply", - "-time": "4.132041197" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from partner(partner) to test(test) 10.128.8.3 test(test) should reply", - "-time": "4.102927471" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when test(test) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002270972" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when partner(partner) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002174817" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "diagnostic when a cluster is set up and installed with OpenShift should report all available nodeSummary", - "-time": "0.133763681" - } - ] - } - } - }, - "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" - }, - "results": { - "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ - { - "notaresult": "absolutelynot" - } - ] - } - } -} \ No newline at end of file diff --git a/pkg/claim/testdata/claim-valid.json b/pkg/claim/testdata/claim-valid.json deleted file mode 100644 index c3144642c..000000000 --- a/pkg/claim/testdata/claim-valid.json +++ /dev/null @@ -1,231 +0,0 @@ -{ - "claim": { - "configurations": { - "generic": { - "containersUnderTest": { - "{\"namespace\":\"default\",\"podName\":\"vendor-container1-649d949d4c-stxcc\",\"containerName\":\"vendor-container1\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - }, - "{\"namespace\":\"default\",\"podName\":\"vendor-container2-98f77dfbc-6c6dc\",\"containerName\":\"vendor-container2\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.3" - ] - } - }, - "partnerContainers": { - "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}": { - "defaultNetworkDevice": "eth0", - "multusIpAddresses": [ - "192.168.1.1" - ] - } - }, - "testOrchestrator": "{\"namespace\":\"default\",\"podName\":\"partner\",\"containerName\":\"partner\"}" - } - }, - "metadata": { - "endTime": "1970-01-01T10:05:08+01:00", - "startTime": "1970-01-01T10:05:08+01:00" - }, - "nodes": { - "apiVersion": "v1", - "items": [ - { - "apiVersion": "v1", - "kind": "Node", - "metadata": { - "annotations": { - "machineconfiguration.openshift.io/currentConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/desiredConfig": "rendered-master-c780491175691e89d2b3b34c86baf1a6", - "machineconfiguration.openshift.io/reason": "", - "machineconfiguration.openshift.io/state": "Done", - "volumes.kubernetes.io/controller-managed-attach-detach": "true" - }, - "creationTimestamp": "2020-11-13T16:42:44Z", - "labels": { - "beta.kubernetes.io/arch": "amd64", - "beta.kubernetes.io/os": "linux", - "kubernetes.io/arch": "amd64", - "kubernetes.io/hostname": "master-0", - "kubernetes.io/os": "linux", - "node-role.kubernetes.io/master": "", - "node.openshift.io/os_id": "rhcos" - }, - "name": "master-0", - "resourceVersion": "22191357", - "selfLink": "/api/v1/nodes/master-0", - "uid": "e0c8fac4-07dd-4dd3-a181-9415d30f4235" - }, - "spec": {}, - "status": { - "addresses": [ - { - "address": "192.168.1.110", - "type": "InternalIP" - }, - { - "address": "master-0", - "type": "Hostname" - } - ], - "allocatable": { - "cpu": "79500m", - "ephemeral-storage": "1078575967288", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "190981Mi", - "pods": "250" - }, - "capacity": { - "cpu": "80", - "ephemeral-storage": "1144038Mi", - "hugepages-1Gi": "0", - "hugepages-2Mi": "0", - "memory": "192105Mi", - "pods": "250" - }, - "conditions": [ - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient memory available", - "reason": "KubeletHasSufficientMemory", - "status": "False", - "type": "MemoryPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has no disk pressure", - "reason": "KubeletHasNoDiskPressure", - "status": "False", - "type": "DiskPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet has sufficient PID available", - "reason": "KubeletHasSufficientPID", - "status": "False", - "type": "PIDPressure" - }, - { - "lastHeartbeatTime": "2020-12-14T19:23:17Z", - "lastTransitionTime": "2020-11-19T21:02:44Z", - "message": "kubelet is posting ready status", - "reason": "KubeletReady", - "status": "True", - "type": "Ready" - } - ], - "daemonEndpoints": { - "kubeletEndpoint": { - "Port": 10250 - } - }, - "images": [ - { - "names": [ - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:8cea2679f40cd5e5bb95b7f511d444ea7ad74800bcc366d0129eb682459cdffd", - "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:" - ], - "sizeBytes": 819896785 - } - ], - "nodeInfo": { - "architecture": "amd64", - "bootID": "f24d12e7-202b-4978-bf70-f96f1b5ea3bd", - "containerRuntimeVersion": "cri-o://1.17.4-8.dev.rhaos4.4.git5f5c5e4.el8", - "kernelVersion": "4.18.0-147.8.1.el8_1.x86_64", - "kubeProxyVersion": "v1.17.1", - "kubeletVersion": "v1.17.1", - "machineID": "89842748b08741f99dd5db5433ae16b6", - "operatingSystem": "linux", - "osImage": "Red Hat Enterprise Linux CoreOS 44.81.202004260825-0 (Ootpa)", - "systemUUID": "80ff6508-d095-e711-906e-0017a4403562" - } - } - } - ], - "kind": "List", - "metadata": { - "resourceVersion": "", - "selfLink": "" - } - }, - "results": { - "identifier": { - "url": "https://test-network-function.com/tnf/test", - "version": "v1.0.0" - }, - "results": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - }, - "rawResults": { - "cnf-certification-tests_junit": { - "testsuite": { - "-errors": "0", - "-failures": "0", - "-name": "CNF Certification Test Suite", - "-tests": "5", - "-time": "8.376", - "testcase": [ - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from test(test) to partner(partner) 10.130.4.64 partner(partner) should reply", - "-time": "4.132041197" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic Both Pods are on the Default network when a Ping is issued from partner(partner) to test(test) 10.128.8.3 test(test) should reply", - "-time": "4.102927471" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when test(test) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002270972" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "generic when partner(partner) is checked for Red Hat version Should report a proper Red Hat version", - "-time": "0.002174817" - }, - { - "-classname": "CNF Certification Test Suite", - "-name": "diagnostic when a cluster is set up and installed with OpenShift should report all available nodeSummary", - "-time": "0.133763681" - } - ] - } - } - }, - "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" - }, - "results": { - "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ - { - "testText": "someText", - "isMeasurement": false, - "filename": "/dev/null", - "lineNumber": 4, - "passed": true, - "duration": 100 - } - ] - } - } -} \ No newline at end of file diff --git a/pkg/claim/testdata/invalid-json.json b/pkg/claim/testdata/invalid-json.json deleted file mode 100644 index 7f8c66c66..000000000 --- a/pkg/claim/testdata/invalid-json.json +++ /dev/null @@ -1 +0,0 @@ -this is not JSON diff --git a/pkg/claim/testdata/missing-claim.json b/pkg/claim/testdata/missing-claim.json deleted file mode 100644 index 7a73a41bf..000000000 --- a/pkg/claim/testdata/missing-claim.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/pkg/claimhelper/claimhelper.go b/pkg/claimhelper/claimhelper.go index 9fd49a23c..f1c740378 100644 --- a/pkg/claimhelper/claimhelper.go +++ b/pkg/claimhelper/claimhelper.go @@ -27,11 +27,11 @@ import ( log "github.com/sirupsen/logrus" "github.com/test-network-function/cnf-certification-test/pkg/checksdb" - "github.com/test-network-function/cnf-certification-test/pkg/claim" "github.com/test-network-function/cnf-certification-test/pkg/diagnostics" "github.com/test-network-function/cnf-certification-test/pkg/junit" "github.com/test-network-function/cnf-certification-test/pkg/provider" "github.com/test-network-function/cnf-certification-test/pkg/versions" + "github.com/test-network-function/test-network-function-claim/pkg/claim" ) const ( diff --git a/pkg/provider/isolation.go b/pkg/provider/isolation.go index b47760a00..e14bdb3e8 100644 --- a/pkg/provider/isolation.go +++ b/pkg/provider/isolation.go @@ -58,20 +58,21 @@ func AreCPUResourcesWholeUnits(p *Pod) bool { // Pods may contain more than one container. All containers must conform to the CPU isolation requirements. for _, cut := range p.Containers { // Resources must be specified - cpuRequestsMillis := cut.Resources.Requests.Cpu().MilliValue() - cpuLimitsMillis := cut.Resources.Limits.Cpu().MilliValue() - - if cpuRequestsMillis == 0 || cpuLimitsMillis == 0 { + if len(cut.Resources.Requests) == 0 || len(cut.Resources.Limits) == 0 { logrus.Debugf("%s has been found with undefined requests or limits.", cut.String()) return false } - if !isInteger(cpuRequestsMillis) { - logrus.Debugf("%s has CPU requests %d (milli) that has to be a whole unit.", cut.String(), cpuRequestsMillis) + // Gather the values + cpuRequests := cut.Resources.Requests.Cpu().MilliValue() + cpuLimits := cut.Resources.Limits.Cpu().MilliValue() + + if !isInteger(cpuRequests) { + logrus.Debugf("%s has CPU requests %d (milli) that has to be a whole unit.", cut.String(), cpuRequests) return false } - if !isInteger(cpuLimitsMillis) { - logrus.Debugf("%s has CPU limits %d (milli) that has to be a whole unit.", cut.String(), cpuLimitsMillis) + if !isInteger(cpuLimits) { + logrus.Debugf("%s has CPU limits %d (milli) that has to be a whole unit.", cut.String(), cpuLimits) return false } } diff --git a/pkg/provider/isolation_test.go b/pkg/provider/isolation_test.go index ffd4bba33..91b79ac6f 100644 --- a/pkg/provider/isolation_test.go +++ b/pkg/provider/isolation_test.go @@ -218,39 +218,6 @@ func TestCPUIsolation(t *testing.T) { runtimeClassNameResult: true, loadBalancingResult: false, }, - { // Test Case #6 - Mem reqs/limit set, but no Cpu limits/reqs set. - testPod: &Pod{ - Containers: []*Container{ - { - Container: &corev1.Container{ - Resources: corev1.ResourceRequirements{ - Requests: corev1.ResourceList{ - "memory": resource.MustParse(validMemLimit), - }, - Limits: corev1.ResourceList{ - "memory": resource.MustParse(validMemLimit), - }, - }, - }, - }, - }, - Pod: &corev1.Pod{ - Spec: corev1.PodSpec{ - RuntimeClassName: &testClassName, - }, - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - "cpu-load-balancing.crio.io": "disable", - "irq-load-balancing.crio.io": "disable", - }, - }, - }, - }, - resourcesIdenticalResult: true, - wholeUnitsResult: false, - runtimeClassNameResult: true, - loadBalancingResult: true, - }, } for _, tc := range testCases { diff --git a/pkg/tnf/status.go b/pkg/tnf/status.go index d823af49e..b3fff47ba 100644 --- a/pkg/tnf/status.go +++ b/pkg/tnf/status.go @@ -9,7 +9,7 @@ import ( // ClaimFilePrintf prints to stdout. // ToDo: Remove? func ClaimFilePrintf(format string, args ...interface{}) { - Logf(logrus.TraceLevel, format, args...) + Logf(logrus.TraceLevel, format, args) } // Logf prints to stdout.