Skip to content

Commit 7cadf86

Browse files
authored
Merge pull request kubernetes#88770 from Jefftree/bdd-capture-behaviors
Capture conformance Behaviors in walk.go
2 parents ad2a105 + db71433 commit 7cadf86

File tree

3 files changed

+73
-68
lines changed

3 files changed

+73
-68
lines changed

test/conformance/testdata/conformance.yaml

Lines changed: 44 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
codename: '[k8s.io] Container Runtime blackbox test on terminated container should
4343
report termination message [LinuxOnly] as empty when pod succeeds and TerminationMessagePolicy
4444
FallbackToLogsOnError is set [NodeConformance] [Conformance]'
45-
description: 'Name: Container Runtime, TerminationMessage, from log output of succeeding
46-
container Create a pod with an container. Container''s output is recorded in log
47-
and container exits successfully without an error. When container is terminated,
45+
description: 'Create a pod with an container. Container''s output is recorded in
46+
log and container exits successfully without an error. When container is terminated,
4847
terminationMessage MUST have no content as container succeed. [LinuxOnly]: Cannot
4948
mount files in Windows Containers.'
5049
release: v1.15
@@ -53,9 +52,8 @@
5352
codename: '[k8s.io] Container Runtime blackbox test on terminated container should
5453
report termination message [LinuxOnly] from file when pod succeeds and TerminationMessagePolicy
5554
FallbackToLogsOnError is set [NodeConformance] [Conformance]'
56-
description: 'Name: Container Runtime, TerminationMessage, from file of succeeding
57-
container Create a pod with an container. Container''s output is recorded in a
58-
file and the container exits successfully without an error. When container is
55+
description: 'Create a pod with an container. Container''s output is recorded in
56+
a file and the container exits successfully without an error. When container is
5957
terminated, terminationMessage MUST match with the content from file. [LinuxOnly]:
6058
Cannot mount files in Windows Containers.'
6159
release: v1.15
@@ -64,23 +62,21 @@
6462
codename: '[k8s.io] Container Runtime blackbox test on terminated container should
6563
report termination message [LinuxOnly] from log output if TerminationMessagePolicy
6664
FallbackToLogsOnError is set [NodeConformance] [Conformance]'
67-
description: 'Name: Container Runtime, TerminationMessage, from container''s log
68-
output of failing container Create a pod with an container. Container''s output
69-
is recorded in log and container exits with an error. When container is terminated,
70-
termination message MUST match the expected output recorded from container''s
71-
log. [LinuxOnly]: Cannot mount files in Windows Containers.'
65+
description: 'Create a pod with an container. Container''s output is recorded in
66+
log and container exits with an error. When container is terminated, termination
67+
message MUST match the expected output recorded from container''s log. [LinuxOnly]:
68+
Cannot mount files in Windows Containers.'
7269
release: v1.15
7370
file: test/e2e/common/runtime.go
7471
- testname: ""
7572
codename: '[k8s.io] Container Runtime blackbox test on terminated container should
7673
report termination message [LinuxOnly] if TerminationMessagePath is set as non-root
7774
user and at a non-default path [NodeConformance] [Conformance]'
78-
description: 'Name: Container Runtime, TerminationMessagePath, non-root user and
79-
non-default path Create a pod with a container to run it as a non-root user with
80-
a custom TerminationMessagePath set. Pod redirects the output to the provided
81-
path successfully. When the container is terminated, the termination message MUST
82-
match the expected output logged in the provided custom path. [LinuxOnly]: Tagged
83-
LinuxOnly due to use of ''uid'' and unable to mount files in Windows Containers.'
75+
description: 'Create a pod with a container to run it as a non-root user with a
76+
custom TerminationMessagePath set. Pod redirects the output to the provided path
77+
successfully. When the container is terminated, the termination message MUST match
78+
the expected output logged in the provided custom path. [LinuxOnly]: Tagged LinuxOnly
79+
due to use of ''uid'' and unable to mount files in Windows Containers.'
8480
release: v1.15
8581
file: test/e2e/common/runtime.go
8682
- testname: Container Runtime, Restart Policy, Pod Phases
@@ -104,10 +100,9 @@
104100
- testname: Docker containers, with command
105101
codename: '[k8s.io] Docker Containers should be able to override the image''s default
106102
command (docker entrypoint) [NodeConformance] [Conformance]'
107-
description: 'Note: when you override the entrypoint, the image''s arguments (docker
108-
cmd) are ignored. Default command from the docker image entrypoint MUST NOT be
109-
used when Pod specifies the container command. Command from Pod spec MUST override
110-
the command in the image.'
103+
description: Default command from the docker image entrypoint MUST NOT be used when
104+
Pod specifies the container command. Command from Pod spec MUST override the
105+
command in the image.
111106
release: v1.9
112107
file: test/e2e/common/docker_containers.go
113108
- testname: Docker containers, with command and arguments
@@ -793,22 +788,21 @@
793788
- testname: Garbage Collector, dependency cycle
794789
codename: '[sig-api-machinery] Garbage collector should not be blocked by dependency
795790
circle [Conformance]'
796-
description: 'TODO: should be an integration test Create three pods, patch them
797-
with Owner references such that pod1 has pod3, pod2 has pod1 and pod3 has pod2
798-
as owner references respectively. Delete pod1 MUST delete all pods. The dependency
799-
cycle MUST not block the garbage collection.'
791+
description: Create three pods, patch them with Owner references such that pod1
792+
has pod3, pod2 has pod1 and pod3 has pod2 as owner references respectively. Delete
793+
pod1 MUST delete all pods. The dependency cycle MUST not block the garbage collection.
800794
release: v1.9
801795
file: test/e2e/apimachinery/garbage_collector.go
802796
- testname: Garbage Collector, multiple owners
803797
codename: '[sig-api-machinery] Garbage collector should not delete dependents that
804798
have both valid owner and owner that''s waiting for dependents to be deleted [Conformance]'
805-
description: 'TODO: this should be an integration test Create a replication controller
806-
RC1, with maximum allocatable Pods between 10 and 100 replicas. Create second
807-
replication controller RC2 and set RC2 as owner for half of those replicas. Once
808-
RC1 is created and the all Pods are created, delete RC1 with deleteOptions.PropagationPolicy
809-
set to Foreground. Half of the Pods that has RC2 as owner MUST not be deleted
810-
but have a deletion timestamp. Deleting the Replication Controller MUST not delete
811-
Pods that are owned by multiple replication controllers.'
799+
description: Create a replication controller RC1, with maximum allocatable Pods
800+
between 10 and 100 replicas. Create second replication controller RC2 and set
801+
RC2 as owner for half of those replicas. Once RC1 is created and the all Pods
802+
are created, delete RC1 with deleteOptions.PropagationPolicy set to Foreground.
803+
Half of the Pods that has RC2 as owner MUST not be deleted but have a deletion
804+
timestamp. Deleting the Replication Controller MUST not delete Pods that are owned
805+
by multiple replication controllers.
812806
release: v1.9
813807
file: test/e2e/apimachinery/garbage_collector.go
814808
- testname: Garbage Collector, delete deployment, propagation policy orphan
@@ -1385,10 +1379,9 @@
13851379
- testname: Kubectl, proxy port zero
13861380
codename: '[sig-cli] Kubectl client Proxy server should support proxy with --port
13871381
0 [Conformance]'
1388-
description: 'TODO: test proxy options (static, prefix, etc) Start a proxy server
1389-
on port zero by running ''kubectl proxy'' with --port=0. Call the proxy server
1390-
by requesting api versions from unix socket. The proxy server MUST provide at
1391-
least one version string.'
1382+
description: Start a proxy server on port zero by running 'kubectl proxy' with --port=0.
1383+
Call the proxy server by requesting api versions from unix socket. The proxy server
1384+
MUST provide at least one version string.
13921385
release: v1.9
13931386
file: test/e2e/kubectl/kubectl.go
13941387
- testname: Kubectl, replication controller
@@ -1473,13 +1466,11 @@
14731466
- testname: Networking, intra pod http
14741467
codename: '[sig-network] Networking Granular Checks: Pods should function for intra-pod
14751468
communication: http [NodeConformance] [Conformance]'
1476-
description: Try to hit all endpoints through a test container, retry 5 times, expect
1477-
exactly one unique hostname. Each of these endpoints reports its own hostname.
1478-
Create a hostexec pod that is capable of curl to netcat commands. Create a test
1479-
Pod that will act as a webserver front end exposing ports 8080 for tcp and 8081
1480-
for udp. The netserver service proxies are created on specified number of nodes.
1481-
The kubectl exec on the webserver container MUST reach a http port on the each
1482-
of service proxy endpoints in the cluster and the request MUST be successful.
1469+
description: Create a hostexec pod that is capable of curl to netcat commands. Create
1470+
a test Pod that will act as a webserver front end exposing ports 8080 for tcp
1471+
and 8081 for udp. The netserver service proxies are created on specified number
1472+
of nodes. The kubectl exec on the webserver container MUST reach a http port on
1473+
the each of service proxy endpoints in the cluster and the request MUST be successful.
14831474
Container will execute curl command to reach the service port within specified
14841475
max retry limit and MUST result in reporting unique hostnames.
14851476
release: v1.9, v1.18
@@ -1540,10 +1531,8 @@
15401531
file: test/e2e/network/proxy.go
15411532
- testname: Proxy, logs service endpoint
15421533
codename: '[sig-network] Proxy version v1 should proxy through a service and a pod [Conformance]'
1543-
description: using the porter image to serve content, access the content (of multiple
1544-
pods?) from multiple (endpoints/services?) Select any node in the cluster to invoke /logs
1545-
endpoint using the /nodes/proxy subresource from the kubelet port. This endpoint
1546-
MUST be reachable.
1534+
description: Select any node in the cluster to invoke /logs endpoint using the
1535+
/nodes/proxy subresource from the kubelet port. This endpoint MUST be reachable.
15471536
release: v1.9
15481537
file: test/e2e/network/proxy.go
15491538
- testname: Service endpoint latency, thresholds
@@ -1711,16 +1700,7 @@
17111700
- testname: Scheduler, resource limits
17121701
codename: '[sig-scheduling] SchedulerPredicates [Serial] validates resource limits
17131702
of pods that are allowed to run [Conformance]'
1714-
description: 'This test verifies we don''t allow scheduling of pods in a way that
1715-
sum of resource requests of pods is greater than machines capacity. It assumes
1716-
that cluster add-on pods stay stable and cannot be run in parallel with any other
1717-
test that touches Nodes or Pods. It is so because we need to have precise control
1718-
on what''s running in the cluster. Test scenario: 1. Find the amount CPU resources
1719-
on each node. 2. Create one pod with affinity to each node that uses 70% of the
1720-
node CPU. 3. Wait for the pods to be scheduled. 4. Create another pod with no
1721-
affinity to any node that need 50% of the largest node CPU. 5. Make sure this
1722-
additional pod is not scheduled. Scheduling Pods MUST fail if the resource requests
1723-
exceed Machine capacity.'
1703+
description: Scheduling Pods MUST fail if the resource requests exceed Machine capacity.
17241704
release: v1.9
17251705
file: test/e2e/scheduling/predicates.go
17261706
- testname: Scheduler, node selector matching
@@ -1734,10 +1714,9 @@
17341714
- testname: Scheduler, node selector not matching
17351715
codename: '[sig-scheduling] SchedulerPredicates [Serial] validates that NodeSelector
17361716
is respected if not matching [Conformance]'
1737-
description: Test Nodes does not have any label, hence it should be impossible to
1738-
schedule Pod with nonempty Selector set. Create a Pod with a NodeSelector set
1739-
to a value that does not match a node in the cluster. Since there are no nodes
1740-
matching the criteria the Pod MUST not be scheduled.
1717+
description: Create a Pod with a NodeSelector set to a value that does not match
1718+
a node in the cluster. Since there are no nodes matching the criteria the Pod
1719+
MUST not be scheduled.
17411720
release: v1.9
17421721
file: test/e2e/scheduling/predicates.go
17431722
- testname: Scheduling, HostPort and Protocol match, HostIPs different but one is
@@ -2127,11 +2106,10 @@
21272106
- testname: Projected Volume, multiple projections
21282107
codename: '[sig-storage] Projected combined should project all components that make
21292108
up the projection API [Projection][NodeConformance] [Conformance]'
2130-
description: Test multiple projections A Pod is created with a projected volume
2131-
source for secrets, configMap and downwardAPI with pod name, cpu and memory limits
2132-
and cpu and memory requests. Pod MUST be able to read the secrets, configMap values
2133-
and the cpu and memory limits as well as cpu and memory requests from the mounted
2134-
DownwardAPIVolumeFiles.
2109+
description: A Pod is created with a projected volume source for secrets, configMap
2110+
and downwardAPI with pod name, cpu and memory limits and cpu and memory requests.
2111+
Pod MUST be able to read the secrets, configMap values and the cpu and memory
2112+
limits as well as cpu and memory requests from the mounted DownwardAPIVolumeFiles.
21352113
release: v1.9
21362114
file: test/e2e/common/projected_combined.go
21372115
- testname: Projected Volume, ConfigMap, create, update and delete

test/conformance/walk.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ type conformanceData struct {
7676
Release string
7777
// File is the filename where the test is defined. We intentionally don't save the line here to avoid meaningless changes.
7878
File string
79+
// Behaviors is the list of conformance behaviors tested by a particular e2e test
80+
Behaviors []string `yaml:"behaviors,omitempty"`
7981
}
8082

8183
func main() {
@@ -292,23 +294,40 @@ func commentToConformanceData(comment string) *conformanceData {
292294
lines := strings.Split(comment, "\n")
293295
descLines := []string{}
294296
cd := &conformanceData{}
297+
var curLine string
295298
for _, line := range lines {
296299
line = strings.TrimSpace(line)
297300
if len(line) == 0 {
298301
continue
299302
}
300303
if sline := regexp.MustCompile("^Testname\\s*:\\s*").Split(line, -1); len(sline) == 2 {
304+
curLine = "Testname"
301305
cd.TestName = sline[1]
302306
continue
303307
}
304308
if sline := regexp.MustCompile("^Release\\s*:\\s*").Split(line, -1); len(sline) == 2 {
309+
curLine = "Release"
305310
cd.Release = sline[1]
306311
continue
307312
}
308313
if sline := regexp.MustCompile("^Description\\s*:\\s*").Split(line, -1); len(sline) == 2 {
309-
line = sline[1]
314+
curLine = "Description"
315+
descLines = append(descLines, sline[1])
316+
continue
317+
}
318+
if sline := regexp.MustCompile("^Behaviors\\s*:\\s*").Split(line, -1); len(sline) == 2 {
319+
curLine = "Behaviors"
320+
continue
321+
}
322+
323+
// Line has no header
324+
if curLine == "Behaviors" {
325+
if sline := regexp.MustCompile("^-\\s").Split(line, -1); len(sline) == 2 {
326+
cd.Behaviors = append(cd.Behaviors, sline[1])
327+
}
328+
} else if curLine == "Description" {
329+
descLines = append(descLines, line)
310330
}
311-
descLines = append(descLines, line)
312331
}
313332
if cd.Release == "" && cd.TestName == "" {
314333
return nil

test/conformance/walk_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ func TestCommentToConformanceData(t *testing.T) {
158158
desc: "All fields parsed and newlines and whitespace removed from description",
159159
input: "Release: v1.1\n\t\tTestname: mytest\n\t\tDescription: foo\n\t\tbar\ndone",
160160
expected: &conformanceData{TestName: "mytest", Release: "v1.1", Description: "foo bar done"},
161+
}, {
162+
desc: "Behaviors are read",
163+
input: "Testname: behaviors\nBehaviors:\n- should behave\n- second behavior",
164+
expected: &conformanceData{TestName: "behaviors", Behaviors: []string{"should behave", "second behavior"}},
165+
}, {
166+
desc: "Multiple behaviors are parsed",
167+
input: "Testname: behaviors2\nBehaviors:\n- first behavior\n- second behavior",
168+
expected: &conformanceData{TestName: "behaviors2", Behaviors: []string{"first behavior", "second behavior"}},
161169
},
162170
}
163171

0 commit comments

Comments
 (0)