Skip to content

Commit f7e9b37

Browse files
authored
Merge pull request #142 from tssurya/implement-conformance-profiles
Add Conformance Profiles Test Reporting System
2 parents 7a4cc74 + 7e9c9b4 commit f7e9b37

18 files changed

+1131
-425
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ crd-e2e:
5353

5454
.PHONY: conformance
5555
conformance:
56-
go test -v ./conformance/... -args ${CONFORMANCE_FLAGS}
56+
go test ${GO_TEST_FLAGS} -v ./conformance -run TestConformance -args ${CONFORMANCE_FLAGS}
57+
58+
.PHONY: conformance-profiles
59+
conformance-profiles:
60+
go test ${GO_TEST_FLAGS} -v ./conformance -run TestConformanceProfiles -args ${CONFORMANCE_FLAGS}
61+
62+
.PHONY: conformance-profiles-default
63+
conformance-profiles-default:
64+
go test ${GO_TEST_FLAGS} -v ./conformance -run TestConformanceProfiles -args --conformance-profiles=AdminNetworkPolicy,BaselineAdminNetworkPolicy
5765

5866
##@ Deployment
5967
install: generate ## Install CRDs into the K8s cluster specified in ~/.kube/config.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// ConformanceReport is a report of conformance testing results including the
24+
// specific conformance profiles that were tested and the results of the tests
25+
// with summaries and statistics.
26+
type ConformanceReport struct {
27+
metav1.TypeMeta `json:",inline"`
28+
Implementation `json:"implementation"`
29+
30+
// Date indicates the date that this report was generated.
31+
Date string `json:"date"`
32+
33+
// NetworkPolicyV2APIVersion indicates which release version of NetworkPolicy API this
34+
// test report was made for.
35+
NetworkPolicyV2APIVersion string `json:"networkPolicyV2APIVersion"`
36+
37+
// ProfileReports is a list of the individual reports for each conformance
38+
// profile that was enabled for a test run.
39+
ProfileReports []ProfileReport `json:"profiles"`
40+
}
41+
42+
// Implementation provides metadata information on the downstream
43+
// implementation of Network Policy V2 API which ran conformance tests.
44+
type Implementation struct {
45+
// Organization refers to the company, group or individual which maintains
46+
// the named implementation. Organizations can provide reports for any
47+
// number of distinct Network Policy API implementations they maintain, but need
48+
// to identify themselves using this organization field for grouping.
49+
Organization string `json:"organization"`
50+
51+
// Project indicates the name of the project or repository for a Network Policy API
52+
// implementation.
53+
Project string `json:"project"`
54+
55+
// URL indicates a human-usable URL where more information about the
56+
// implementation can be found. For open source projects this should
57+
// generally link to the code repository.
58+
URL string `json:"url"`
59+
60+
// Version indicates the version of the implementation that was used for
61+
// testing. This should generally be a semver version when applicable.
62+
Version string `json:"version"`
63+
64+
// Contact is contact information for the maintainers so that Network Policy API
65+
// maintainers can get ahold of them as needed. Ideally this should be
66+
// Github usernames (in the form of `@<username>`) or team names (in the
67+
// form of `@<team>/<name>`), but when that's not possible it can be email
68+
// addresses.
69+
// Rather than Github usernames or email addresses you can provide a URL to the relevant
70+
// support pages for the project. Ideally this would be something like the issue creation page
71+
// on a repository, but for projects without a publicly exposed repository a general support
72+
// page URL can be provided.
73+
Contact []string `json:"contact"`
74+
75+
// AdditionalInformation field must be used by implementations to provide a link to
76+
// the implementation of the APIs OR github actions OR jenkins or any other CI/CD job
77+
// definition that shows proof of what was used to generate the report. This will help
78+
// maintainers make an informed decision on merging reports into the NetworkPolicyAPI project.
79+
AdditionalInformation string `json:"additionalInformation"`
80+
}

conformance/apis/v1alpha1/doc.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// V1alpha1 includes alpha maturity API types and utilities for creating and
18+
// handling the results of conformance test runs. These types are _only_
19+
// intended for use by the conformance test suite OR external test suites that
20+
// are written in Golang and execute the conformance test suite as a Golang
21+
// library.
22+
//
23+
// Note that currently all sub-packages are not intended for general use or
24+
// to be distributed as part of a release so there is no way to use them by
25+
// default when using the Golang library at this time. If you don't know for
26+
// sure that you want to use these features, then you should not use them.
27+
// If you would like to opt into these unreleased features use Go build tags
28+
// to enable them, e.g.:
29+
//
30+
// $ GOFLAGS='-tags=experimental' go test ./conformance/... -args ${CONFORMANCE_ARGS}
31+
//
32+
// Please note that everything here is considered experimental and subject to
33+
// change. Expect breaking changes and/or complete removals if you start using
34+
// them.
35+
36+
package v1alpha1
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
// ProfileReport is the generated report for the test results of a specific
20+
// named conformance profile.
21+
type ProfileReport struct {
22+
// Name indicates the name of the conformance profile
23+
// (e.g. "AdminNetworkPolicy", "BaselineAdminNetworkPolicy")
24+
Name string `json:"name"`
25+
26+
// Core indicates the core support level which includes the set of tests
27+
// which are the minimum the implementation must pass to be considered at
28+
// all conformant.
29+
Core Status `json:"core"`
30+
31+
// Extended indicates the extended support level which includes additional
32+
// optional features which the implementation may choose to implement
33+
// support for, but are not required.
34+
Extended *ExtendedStatus `json:"extended,omitempty"`
35+
}
36+
37+
// ExtendedStatus shows the testing results for the extended support level.
38+
type ExtendedStatus struct {
39+
Status `json:",inline"`
40+
41+
// SupportedFeatures indicates which extended features were flagged as
42+
// supported by the implementation and tests will be attempted for.
43+
SupportedFeatures []string `json:"supportedFeatures,omitempty"`
44+
45+
// UnsupportedFeatures indicates which extended features the implementation
46+
// does not have support for and therefore will not attempt to test.
47+
UnsupportedFeatures []string `json:"unsupportedFeatures,omitempty"`
48+
}
49+
50+
// Status includes details on the results of a test.
51+
type Status struct {
52+
Result `json:"result"`
53+
54+
// Summary is a human-readable message intended for end-users to understand
55+
// the overall status at a glance.
56+
Summary string `json:"summary"`
57+
58+
// Statistics includes numerical statistics on the result of the test run.
59+
Statistics `json:"statistics"`
60+
61+
// SkippedTests indicates which tests were explicitly disabled in the test
62+
// suite. Skipping tests for Core level support implicitly identifies the
63+
// results as being partial and the implementation will not be considered
64+
// conformant at any level.
65+
SkippedTests []string `json:"skippedTests,omitempty"`
66+
67+
// FailedTests indicates which tests were failing during the execution of
68+
// test suite.
69+
FailedTests []string `json:"failedTests,omitempty"`
70+
}

conformance/apis/v1alpha1/result.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
// Result is a simple high-level summary describing the conclusion of a test
20+
// run.
21+
type Result string
22+
23+
var (
24+
// Success indicates that the test run concluded in all required tests
25+
// passing.
26+
Success Result = "success"
27+
28+
// Partial indicates that the test run concluded in some of the required
29+
// tests passing without any failures, but some were skipped.
30+
Partial Result = "partial"
31+
32+
// Failure indicates that the test run concluded in one ore more tests
33+
// failing to complete successfully.
34+
Failure Result = "failure"
35+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
// Statistics includes numerical summaries of the number of conformance tests
20+
// that passed, failed or were intentionally skipped.
21+
type Statistics struct {
22+
// Passed indicates how many tests completed successfully.
23+
Passed uint32
24+
25+
// Skipped indicates how many tests were intentionally not run, whether due
26+
// to lack of feature support or whether they were explicitly disabled in
27+
// the test suite.
28+
Skipped uint32
29+
30+
// Failed indicates how many tests were unsuccessful.
31+
Failed uint32
32+
}

0 commit comments

Comments
 (0)