Skip to content

Commit 0ca98de

Browse files
committed
Updates to the solution overview section
1 parent 2bb4f43 commit 0ca98de

File tree

1 file changed

+76
-88
lines changed
  • keps/sig-architecture/960-conformance-behaviors

1 file changed

+76
-88
lines changed

keps/sig-architecture/960-conformance-behaviors/README.md

Lines changed: 76 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@
3232
- [Role: SIG](#role-sig)
3333
- [Define expected behaviors for their area of responsibility](#define-expected-behaviors-for-their-area-of-responsibility)
3434
- [Solution Overview](#solution-overview)
35-
- [Representation of Behaviors](#representation-of-behaviors)
36-
- [Behavior and Test Generation Tooling](#behavior-and-test-generation-tooling)
35+
- [Representation of Behaviors (Phase 1)](#representation-of-behaviors-phase-1)
36+
- [Generating Lists of Behaviors (Phase 1)](#generating-lists-of-behaviors-phase-1)
37+
- [Coverage Tooling (Phase 2)](#coverage-tooling-phase-2)
38+
- [Developer and CI Support (Phase 2)](#developer-and-ci-support-phase-2)
39+
- [Generating Test Scaffolding (Phase 3)](#generating-test-scaffolding-phase-3)
3740
- [Handwritten Behaviour Scenarios](#handwritten-behaviour-scenarios)
38-
- [Coverage Tooling](#coverage-tooling)
3941
- [Risks and Mitigations](#risks-and-mitigations)
4042
- [Design Details](#design-details)
4143
- [Phase 1](#phase-1)
42-
- [Tying tests back to behaviors](#tying-tests-back-to-behaviors)
43-
- [kubetestgen](#kubetestgen)
4444
- [Phase 2](#phase-2)
45+
- [Phase 3](#phase-3)
4546
- [Graduation Criteria](#graduation-criteria)
4647
- [Future development](#future-development)
4748
- [Complex Storytelling combined with json/yaml](#complex-storytelling-combined-with-jsonyaml)
@@ -336,14 +337,22 @@ PR must touch file in conformance-specific directory
336337
owned by the SIG
337338

338339
### Solution Overview
339-
The proposed solution consists of four deliverables:
340-
* A machine readable format to define conforming behaviors.
341-
* Tooling to generate lists of behaviors from the API schemas.
340+
The proposed solution consists of these deliverables:
341+
* A machine readable format to define conforming behaviors. (Phase 1)
342+
* Tooling to generate lists of behaviors from the API schemas. (Phase 1)
342343
* Tooling to compare the implemented tests to the list of behaviors and
343-
calculate coverage.
344+
calculate coverage. (Phase 2)
345+
* Process documentation and supporting tooling to enable developers to move
346+
their features to GA and add conformance behaviors and tests with minimal
347+
review burden and entaglements. (Phase 2)
348+
* Migration of the existing tests to use behaviors, and to updates to the
349+
CNCF conformance program validation of tests to use the behaviors rather
350+
than simply the test results. (Phase 2)
344351
* Tooling to generate tests and test scaffolding to evaluate those behaviors.
352+
(Phase 3)
345353

346-
### Representation of Behaviors
354+
355+
#### Representation of Behaviors (Phase 1)
347356

348357
Behaviors will be captured in prose, which is in turn embedded in a YAML file
349358
along with meta-data about the behavior. More details on exactly what defines
@@ -375,7 +384,7 @@ Typical suites defined for any given feature will include:
375384
and other features.
376385

377386
Each suite may be stored in a separate file in a directory for the specific
378-
SIG. For example, a "sig-node" my have files such as:
387+
SIG. For example, a `sig-node` directory may have files such as:
379388
these files:
380389
* `api-generated.yaml` describing the set of behaviors auto-generated from the
381390
API specification.
@@ -399,12 +408,16 @@ test/conformance/behaviors
399408
The relationship between tests and behaviors is captured in the conformance test
400409
metadata, which contains a list of behavior IDs covered by the test.
401410

402-
The structure of the behavior YAML files is described by these Go types:
411+
The structure of the behavior YAML files is described by these Go types, which
412+
have been updated for Phase 2 to add the `Status` field. Use of this field is
413+
described later in this KEP. The actual implementation of these types can be
414+
found in
415+
[types.go](https://git.k8s.io/kubernetes/test/conformance/behaviors/types.go).
403416

404417
```go
405418
// Area defines a general grouping of behaviors
406419
type Area struct {
407-
// Area is the name of the area.
420+
// Area is the name of the area or SIG.
408421
Area string `json:"area,omitempty"`
409422

410423
// Suites is a list containing each suite of behaviors for this area.
@@ -415,9 +428,6 @@ type Suite struct {
415428
// Suite is the name of this suite.
416429
Suite string `json:"suite,omitempty"`
417430

418-
// Level is `Conformance` or `Validation`.
419-
Level string `json:"level,omitempty"`
420-
421431
// Description is a human-friendly description of this suite, possibly
422432
// for inclusion in the conformance reports.
423433
Description string `json:"description,omitempty"`
@@ -428,29 +438,30 @@ type Suite struct {
428438
}
429439

430440
type Behavior struct {
431-
// Id is a unique identifier for this behavior, and will be used to tie
441+
// ID is a unique identifier for this behavior, and will be used to tie
432442
// tests and their results back to this behavior. For example, a
433443
// behavior describing the defaulting of the PodSpec nodeSelector might
434444
// have an id like `pods/spec/nodeSelector/default`.
435-
Id string `json:"id,omitempty"`
445+
ID string `json:"id,omitempty"`
436446

437-
// ApiObject is the object whose behavior is being described. In
447+
// APIObject is the object whose behavior is being described. In
438448
// particular, in generated behaviors, this is the object to which
439-
// ApiField belongs. For example, `core.v1.PodSpec` or
449+
// APIField belongs. For example, `core.v1.PodSpec` or
440450
// `core.v1.EnvFromSource`.
441-
ApiObject string `json:"apiObject,omitempty"`
451+
APIObject string `json:"apiObject,omitempty"`
442452

443-
// ApiField is filled out for generated tests that are testing the
453+
// APIField is filled out for generated tests that are testing the
444454
// behavior associated with a particular field. For example, if
445-
// ApiObject is `core.v1.PodSpec`, this could be `nodeSelector`.
446-
ApiField string `json:"apiField,omitempty"`
455+
// APIObject is `core.v1.PodSpec`, this could be `nodeSelector`.
456+
APIField string `json:"apiField,omitempty"`
447457

448-
// ApiType is the data type of the field; for example, `string`.
449-
ApiType string `json:"apiType,omitempty"`
458+
// APIType is the data type of the field; for example, `string`.
459+
APIType string `json:"apiType,omitempty"`
450460

451-
// Generated is set to `true` if this entry was generated by tooling
452-
// rather than hand-written.
453-
Generated bool `json:"generated,omitempty"`
461+
// Status is used to create provisional behaviors prior to them becoming
462+
// part of the actual conformance criteria, as well as to deprecate
463+
// prior behaviors.
464+
Status string `json:"status,omitempty"`
454465

455466
// Description specifies the behavior. For those generated from fields,
456467
// this will identify if the behavior in question is for defaulting,
@@ -460,7 +471,33 @@ type Behavior struct {
460471
}
461472
```
462473

463-
### Behavior and Test Generation Tooling
474+
#### Generating Lists of Behaviors (Phase 1)
475+
476+
In Phase 1, a `kubetestgen` tool was created that can be used to generate
477+
candidate behaviors from the API spec, as described below. In Phase 2 this tool
478+
is combined into `kubeconform`, which will handle all of the conformance-related
479+
tooling for developers and CI.
480+
481+
#### Coverage Tooling (Phase 2)
482+
483+
In Phase 1, conformance test meta-data was updated to include a `Behaviors:`
484+
list, which can contain each of the behavior IDs for behaviors explicitly
485+
covered by that test. Implicit behaviors should not be included in the list.
486+
487+
In Phase 2, existing tests will be updated to properly set this field, and
488+
the `kubeconform` tool will be updated to calculate behavior coverage.
489+
490+
#### Developer and CI Support (Phase 2)
491+
492+
Phase 2 will define the process and tooling used by the developer to move a
493+
feature through to GA. This will include documenting the process and producing
494+
any supporting tooling as part of `kubeconform`, to be described in the Design
495+
Details below.
496+
497+
A CI job, and necessary supporting tooling, to verify coverage for features
498+
going to GA will also be implemented.
499+
500+
### Generating Test Scaffolding (Phase 3)
464501

465502
Some sets of behaviors may be tested in a similar, mechanical way. Basic CRUD
466503
operations, including updates to specific fields and constraints on immutable
@@ -529,18 +566,6 @@ define:
529566
With those two, the same creation and update scaffolding defined for individual
530567
field updates can be reused.
531568

532-
### Coverage Tooling
533-
534-
In order to tie behaviors back to the tests that are generated, including
535-
existing e2e tests that already cover behaviors, new tags with behavior IDs will
536-
be added to conformance tests. Using the existing conformance framework
537-
mechanism allows incremental adoption of this proposal. Thus, rather than a new
538-
conformance framework function, test authors will indicate the behaviors covered
539-
by their tests with a tag in the `framework.ConformanceIt` call.
540-
541-
This also enables a single test to validate multiple behaviors, although that
542-
should be discouraged.
543-
544569
### Risks and Mitigations
545570

546571
The behavior definitions may not be properly updated if a change is made to a
@@ -549,11 +574,16 @@ However, given that the behaviors defining conformance are generally stable,
549574
this is not a high risk.
550575

551576
## Design Details
577+
<<[UNRESOLVED]>>
578+
@johnbelamaric: note this section is still not updated for Phase 2
579+
<<[/UNRESOLVED]>>
552580

553581
Delivery of this KEP shall be done in the following phases:
554582

555583
### Phase 1
556584

585+
Phase 1 defined the basic behavior structure and enabled the generation of
586+
behaviors from API schemas.
557587
In Phase 1, we will:
558588
* Implement the behavior formats and types described above. This will include
559589
separate suites for tooling-generated behaviors and handcrafted behaviors.
@@ -565,52 +595,6 @@ In Phase 1, we will:
565595
tooling around generation of conformance reports will not be changed in this
566596
phase.
567597

568-
#### Tying tests back to behaviors
569-
The proposal above mentions `tests.yaml` but does not describe a format for that
570-
file. The current conformance frameworks requests that during promotion of the
571-
test to conformance, the developer adds metadata, including the release name,
572-
the test name, and description. Tests are identified in the
573-
[conformance.txt](https://github.com/kubernetes/kubernetes/blob/master/test/conformance/testdata/conformance.yaml)
574-
file by their Ginko description. Unfortunately, this does not produce unique
575-
test names, as it does not include all of the `Describe` calls from higher in
576-
the call tree (see this
577-
[slack discussion](https://kubernetes.slack.com/archives/C78F00H99/p1566324743171500)
578-
for more details).
579-
580-
As part of this KEP, tests being promoted to conformance must add a unique
581-
identifier, `TestId`, in their conformance metadata. This will be used, along with
582-
the behavior IDs, to map which tests validate which behaviors in the
583-
`tests.yaml` file. The Go structures for `tests.yaml` are shown below.
584-
585-
```go
586-
type BehaviorTestList struct {
587-
Tests []BehaviorTest `json:"tests,omitempty"`
588-
}
589-
590-
type BehaviorTest struct {
591-
BehaviorId string `json:"behaviorId,omitempty"`
592-
TestId string `json:"testId,omitempty"`
593-
594-
// Description is optional and is intended to make reviewing easier; the
595-
// expectation would be that tooling would copy the value here.
596-
Description string `json:"description,omitempty"`
597-
}
598-
```
599-
600-
#### kubetestgen
601-
602-
In this phase, the tool will only generate behavior lists in the format defined
603-
above. It will accept the following flags:
604-
* `-schema` - a URL or local file name pointing to the JSON OpenAPI schema
605-
* `-resource` - the specific OpenAPI definition for which to generate behaviors
606-
* `-area` - the name to use for the area
607-
* `-suite` - the name to use for the suite
608-
* `-behaviorsdir` - the path to the behaviors directory (default current
609-
directory)
610-
611-
The tool will read the schema, locate the specific definition, and generate the
612-
`{area}` directory and `{suite}.yaml` as described in the proposal above.
613-
614598
### Phase 2
615599

616600
In Phase 2, we will:
@@ -621,6 +605,8 @@ In Phase 2, we will:
621605
* Implement coverage metrics comparing behavior lists to the coverage captured
622606
by existing conformance tests.
623607

608+
### Phase 3
609+
624610
### Graduation Criteria
625611
As this is a tooling component and is not user facing, it does not follow the
626612
ordinary alpha/beta/GA process. In 1.17, the intent is to implement Phase 1,
@@ -848,6 +834,8 @@ It('test string')`
848834
directory structure for showing behavior/test separation
849835
- 2019-10-01: Added detailed design; marked implementable
850836
- 2020-03-26: Reformat for new KEP structure
837+
- 2020-04-17: Updated to add use cases, reflect what was implemented in Phase 1
838+
and add design details for Phase 2
851839

852840
## Drawbacks
853841

0 commit comments

Comments
 (0)