Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…s-for-k8s#1647)

The content of PR redhat-best-practices-for-k8s#1613 was accidentally removed from ginkgo_removal
branch by commit 1c11b94.

Co-authored-by: jmontesi <[email protected]>
  • Loading branch information
2 people authored and sebrandon1 committed Nov 21, 2023
1 parent 5955b7a commit 2b51f30
Show file tree
Hide file tree
Showing 31 changed files with 2,930 additions and 28 deletions.
10 changes: 0 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ 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`.
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/add/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/test-network-function/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

func TestReadClaim(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/compare/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim"
)

type DiffReport struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/compare/versions/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim"
)

func TestCompare(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/show/csv/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
claimschema "github.com/test-network-function/cnf-certification-test/pkg/claim"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/generate/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/generate/catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

func TestNewCommand(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/generate/qe_coverage/qe_coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

type TestCoverageSummaryReport struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/generate/qe_coverage/qe_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/test-network-function/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

type catalogEntry struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/pkg/claim/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/Masterminds/semver/v3"
officialClaimScheme "github.com/test-network-function/test-network-function-claim/pkg/claim"
officialClaimScheme "github.com/test-network-function/cnf-certification-test/pkg/claim"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cnf-certification-test/identifiers/identifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strings"

"github.com/test-network-function/cnf-certification-test/cnf-certification-test/common"
"github.com/test-network-function/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

// shared description text
Expand Down
2 changes: 1 addition & 1 deletion cnf-certification-test/identifiers/identifiers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion docs/test-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ 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
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,6 @@ github.com/test-network-function/oct v0.0.4 h1:rU4kps/gbAHkR0rc5WzVtTOcJt/NBcse8
github.com/test-network-function/oct v0.0.4/go.mod h1:oOPuUMnX6YR+cl3usBJfwCllsv7Hphw9jVi7VtniAzo=
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=
Expand Down
2 changes: 1 addition & 1 deletion pkg/checksdb/checksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/test-network-function-claim/pkg/claim"
"github.com/test-network-function/cnf-certification-test/pkg/claim"
)

var (
Expand Down
73 changes: 73 additions & 0 deletions pkg/claim/catalog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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
}
13 changes: 13 additions & 0 deletions pkg/claim/catalog_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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
16 changes: 16 additions & 0 deletions pkg/claim/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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
16 changes: 16 additions & 0 deletions pkg/claim/doc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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
Loading

0 comments on commit 2b51f30

Please sign in to comment.