Merge pull request #96014 from Jefftree/remove-bdd

Remove behaviors
This commit is contained in:
Kubernetes Prow Robot 2020-10-30 21:10:51 -07:00 committed by GitHub
commit 19ae1d7edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 0 additions and 372 deletions

View File

@ -31,7 +31,6 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//test/conformance/behaviors:all-srcs",
"//test/conformance/testdata:all-srcs",
],
tags = ["automanaged"],

View File

@ -1,36 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"behaviors.go",
"types.go",
],
importpath = "k8s.io/kubernetes/test/conformance/behaviors",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/gopkg.in/yaml.v2:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["behaviors_test.go"],
data = glob(["*/*.yaml"]),
embed = [":go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -1,16 +0,0 @@
# See the OWNERS docs at https://go.k8s.io/owners
# To be owned by sig-architecture.
options:
no_parent_owners: true
reviewers:
- smarterclayton
- spiffxp
- timothysc
- dims
- johnbelamaric
approvers:
- conformance-behavior-approvers
labels:
- area/conformance
- sig/architecture

View File

@ -1,55 +0,0 @@
# Behaviors Defining Conformance
The conformance program is intended to answer the question "What is
Kubernetes?". That is, what features, functions, and APIs are needed in order to
call something "Kubernetes". Since v1.9, this has been defined as passing a
specific set of e2e tests. As part of the [conformance behavior KEP](https://git.k8s.io/enhancements/keps/sig-architecture/20190412-conformance-behaviors.md),
this instead is moved to an explicit list of "behaviors", which are captured in
this directory tree. The e2e tests are used to validate whether specific
behaviors are met, but the definition of conformance is based upon that list of
approved behaviors. This allows separate reviewers for behaviors and tests,
provides a description of conformance separate from long, complex tests with
code, and enables the definition of conformance to encompass behaviors for which
tests have not yet been written. All of this begs the question, though, "what is
a behavior?".
In behavior driven development, it is sometimes defined as the "business logic"
expected from the software. That is, it is a sequence of reactions to some
stimulus: an API call, a component failure, a network request on the data plane,
or some other action. We can classify these reactions into a few different types
in Kubernetes:
1. Transient runtime / communication state
1. Cluster state changes observable via the control plane
1. Cluster state changes observable via the data plane
Another way to think about this is that a behavior is the combination of the
question and answer to "What happens when...".
A behavior will consist of:
* A description of the initial conditions and stimulus
* A description of the resulting reactions
* If necessary, a sequencing (ordering) of those reactions
All this is still pretty vague, so it is helpful to enumerate some of the
characteristics expected of behavior descriptions for conformance in particular.
- Behaviors should be defined at the user-visible level. Things happening
behind the scenes that are not visible to the user via the API or actual data
plane execution do not need to be part of conformance.
- Behaviors should describe portable features. That is, they should be
expected to work as described across vendor systems.
- Behaviors should be defined so they are minimally constraining; if a detail is
not needed for portability, it should be left out.
- Behaviors should not be tied to specific implementations of components, or even
to the existence of specific components. If a vendor chooses to rewrite a
component or replace it with something else, they should still pass conformance
simply by meeting the expected behaviors.
- Ordered sequencing of the reactions should be avoided unless absolutely
necessary. For example, it is core to the `initContainers` functionality that
they run before the main containers, so in that case ordering is required.
<!--
TODO Examples: include example of a good behavior and a poorly written behavior
-->

View File

@ -1,78 +0,0 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package behaviors
import (
"fmt"
"io/ioutil"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v2"
)
// BehaviorFileList returns a list of eligible behavior files in or under dir
func BehaviorFileList(dir string) ([]string, error) {
var behaviorFiles []string
r, _ := regexp.Compile(".+.yaml$")
err := filepath.Walk(dir,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if r.MatchString(path) {
behaviorFiles = append(behaviorFiles, path)
}
return nil
},
)
return behaviorFiles, err
}
// LoadSuite loads a Behavior Suite from .yaml file at path
func LoadSuite(path string) (*Suite, error) {
var suite Suite
bytes, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("error loading suite %s: %v", path, err)
}
err = yaml.UnmarshalStrict(bytes, &suite)
if err != nil {
return nil, fmt.Errorf("error loading suite %s: %v", path, err)
}
return &suite, nil
}
// ValidateSuite validates that the given suite has no duplicate behavior IDs
func ValidateSuite(suite *Suite) error {
var errs []error
behaviorsByID := make(map[string]bool)
for _, b := range suite.Behaviors {
if _, ok := behaviorsByID[b.ID]; ok {
errs = append(errs, fmt.Errorf("Duplicate behavior ID: %s", b.ID))
}
if !strings.HasPrefix(b.ID, suite.Suite) {
errs = append(errs, fmt.Errorf("Invalid behavior ID: %s, must have suite name as prefix: %s", b.ID, suite.Suite))
}
behaviorsByID[b.ID] = true
}
return utilerrors.NewAggregate(errs)
}

View File

@ -1,43 +0,0 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package behaviors
import (
"testing"
)
func TestValidate(t *testing.T) {
behaviorFiles, err := BehaviorFileList(".")
if err != nil {
t.Errorf("%q", err.Error())
}
for _, file := range behaviorFiles {
validateSuite(file, t)
}
}
func validateSuite(path string, t *testing.T) {
suite, err := LoadSuite(path)
if err != nil {
t.Errorf("%q", err.Error())
}
err = ValidateSuite(suite)
if err != nil {
t.Errorf("error validating %s: %q", path, err.Error())
}
}

View File

@ -1,30 +0,0 @@
suite: service/spec
description: Base suite for services
behaviors:
- id: service/spec/selector/present-during-create
description: When a Service resource is created with type "ClusterIP", "NodePort", or "LoadBalancer",
and a selector is specified, an Endpoints object is generated based with the IPs of pods with
label keys and values matching the selector.
- id: service/spec/selector/absent-during-create
description: When a Service resource is created and a no selector is specified, no changes are made
to any corresponding Endpoints object.
- id: service/spec/type/ClusterIP/empty
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is empty, a cluster-internal IP address for load-balancing to endpoints is
allocated.
- id: service/spec/type/ClusterIP/static
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is specified as an IP address in the cluster service range, and that IP is
not already assigned to another service, that IP is be allocated as a cluster-internal
IP address for load-balancing to endpoints.
- id: service/spec/type/ClusterIP/None
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is "None", no virtual IP is allocated and the endpoints are published as a
set of endpoints rather than a stable IP.
- id: service/spec/type/NodePort
description: When the Service type is specified as "NodePort" , a cluster-internal
IP address for load-balancing to endpoints is allocated as for type "ClusterIP".
Additionally, a cluster-wide port is allocated on every node, routing to the clusterIP.
- id: service/spec/type/ExternalName
description: When the Service type is specified as "ExternalName", the cluster DNS provider
publishes a CNAME pointing from the service to the specified external name.

View File

@ -1,7 +0,0 @@
suite: pod/readinessGates
description: Suite for pod readiness gates
behaviors:
- id: pod/readinessGates/single
description: If a readinessGate is specified and the corresponding condition is not "True", then the Pod Ready condition MUST be "False", even if all containers are Ready.
- id: pod/readinessGates/multiple
description: If multiple readinessGates are specified and the corresponding condition is not "True" for one or more of these, then the Pod Ready condition MUST be "False", even if all containers are Ready.

View File

@ -1,49 +0,0 @@
suite: pod/spec
description: Base suite for pods
behaviors:
- id: pod/spec/basic-create
description: When a Pod resource is created with a single container and sufficient resources, a Pod MUST be created on a node with the specified container image.
- id: pod/spec/basic-delete
description: When a Pod resource is delete, the Pod containers must receive a TERM signal and the Pod MUST be deleted.
- id: pod/spec/hostname
description: When the hostname field is set, a container running in the Pod MUST report the hostname as the specified value.
- id: pod/spec/subdomain
description: If specified, the fully qualified Pod hostname will be "<hostname>.<subdomain>.<pod
namespace>.svc.<cluster domain>". If not specified, the pod will not have a
domainname at all.
- id: pod/spec/terminationGracePeriodSeconds/in-spec
description: When the terminationGracePeriodSeconds is specified in the spec,
processes running in the Pod MUST NOT receive a hard termination signal for at
least that number of seconds after a delete request.
- id: pod/spec/terminationGracePeriodSeconds/in-delete
description: When the terminationGracePeriodSeconds is specified in a delete request,
processes running in the Pod MUST NOT receive a hard termination signal for at
least that number of seconds after the delete request.
- id: pod/spec/activeDeadlineSeconds
description: Optional duration in seconds the pod may be active on the node relative
to StartTime before the system will actively try to mark it failed and kill
associated containers. Value must be a positive integer.
- id: pod/spec/hostNetwork/true
description: When hostNetwork is set to true, the Pod MUST use the host's network
namespace.
- id: pod/spec/hostNetwork/false
description: When hostNetwork is set to false, the Pod MUST NOT use the host's network
namespace.
- id: pod/spec/hostPID/true
description: When hostPID is set to true, the Pod MUST use the host's process
namespace.
- id: pod/spec/hostPID/false
description: When hostPID is set to false, the Pod MUST NOT use the host's process
namespace.
- id: pod/spec/hostIPC/true
description: When hostIPC is set to true, the Pod MUST use the host's inter-process
communication namespace.
- id: pod/spec/hostIPC/false
description: When hostIPC is set to false, the Pod MUST NOT use the host's inter-process
communication namespace.
- id: pod/spec/label/create
description: Create a Pod with a unique label. Query for the Pod with the label as selector MUST be successful.
- id: pod/spec/label/patch
description: A patch request must be able to update the pod to change the value of an existing Label. Query for the Pod with the new value for the label MUST be successful.
- id: pod/spec/container/resources
description: Create a Pod with CPU and Memory request and limits. Pod status MUST have QOSClass set to PodQOSGuaranteed.

View File

@ -1,57 +0,0 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package behaviors
// Area is a conformance area composed of a list of test suites
type Area struct {
Area string `json:"area,omitempty"`
Suites []Suite `json:"suites,omitempty"`
}
// Suite is a conformance test suite composed of a list of behaviors
type Suite struct {
Suite string `json:"suite,omitempty"`
Description string `json:"description,omitempty"`
Behaviors []Behavior `json:"behaviors,omitempty"`
}
// Behavior describes the set of properties for a conformance behavior
type Behavior struct {
ID string `json:"id,omitempty"`
APIObject string `json:"apiObject,omitempty"`
APIField string `json:"apiField,omitempty"`
APIType string `json:"apiType,omitempty"`
Description string `json:"description,omitempty"`
}
// ConformanceData describes the structure of the conformance.yaml file
type ConformanceData struct {
// A URL to the line of code in the kube src repo for the test. Omitted from the YAML to avoid exposing line number.
URL string `yaml:"-"`
// Extracted from the "Testname:" comment before the test
TestName string
// CodeName is taken from the actual ginkgo descriptions, e.g. `[sig-apps] Foo should bar [Conformance]`
CodeName string
// Extracted from the "Description:" comment before the test
Description string
// Version when this test is added or modified ex: v1.12, v1.13
Release string
// File is the filename where the test is defined. We intentionally don't save the line here to avoid meaningless changes.
File string
// Behaviors is the list of conformance behaviors tested by a particular e2e test
Behaviors []string `yaml:"behaviors,omitempty"`
}