32
32
- [ Role: SIG] ( #role-sig )
33
33
- [ Define expected behaviors for their area of responsibility] ( #define-expected-behaviors-for-their-area-of-responsibility )
34
34
- [ 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 )
37
40
- [ Handwritten Behaviour Scenarios] ( #handwritten-behaviour-scenarios )
38
- - [ Coverage Tooling] ( #coverage-tooling )
39
41
- [ Risks and Mitigations] ( #risks-and-mitigations )
40
42
- [ Design Details] ( #design-details )
41
43
- [ Phase 1] ( #phase-1 )
42
- - [ Tying tests back to behaviors] ( #tying-tests-back-to-behaviors )
43
- - [ kubetestgen] ( #kubetestgen )
44
44
- [ Phase 2] ( #phase-2 )
45
+ - [ Phase 3] ( #phase-3 )
45
46
- [ Graduation Criteria] ( #graduation-criteria )
46
47
- [ Future development] ( #future-development )
47
48
- [ Complex Storytelling combined with json/yaml] ( #complex-storytelling-combined-with-jsonyaml )
@@ -336,14 +337,22 @@ PR must touch file in conformance-specific directory
336
337
owned by the SIG
337
338
338
339
### 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)
342
343
* 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)
344
351
* Tooling to generate tests and test scaffolding to evaluate those behaviors.
352
+ (Phase 3)
345
353
346
- ### Representation of Behaviors
354
+
355
+ #### Representation of Behaviors (Phase 1)
347
356
348
357
Behaviors will be captured in prose, which is in turn embedded in a YAML file
349
358
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:
375
384
and other features.
376
385
377
386
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:
379
388
these files:
380
389
* ` api-generated.yaml ` describing the set of behaviors auto-generated from the
381
390
API specification.
@@ -399,12 +408,16 @@ test/conformance/behaviors
399
408
The relationship between tests and behaviors is captured in the conformance test
400
409
metadata, which contains a list of behavior IDs covered by the test.
401
410
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 ) .
403
416
404
417
``` go
405
418
// Area defines a general grouping of behaviors
406
419
type Area struct {
407
- // Area is the name of the area.
420
+ // Area is the name of the area or SIG .
408
421
Area string ` json:"area,omitempty"`
409
422
410
423
// Suites is a list containing each suite of behaviors for this area.
@@ -415,9 +428,6 @@ type Suite struct {
415
428
// Suite is the name of this suite.
416
429
Suite string ` json:"suite,omitempty"`
417
430
418
- // Level is `Conformance` or `Validation`.
419
- Level string ` json:"level,omitempty"`
420
-
421
431
// Description is a human-friendly description of this suite, possibly
422
432
// for inclusion in the conformance reports.
423
433
Description string ` json:"description,omitempty"`
@@ -428,29 +438,30 @@ type Suite struct {
428
438
}
429
439
430
440
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
432
442
// tests and their results back to this behavior. For example, a
433
443
// behavior describing the defaulting of the PodSpec nodeSelector might
434
444
// have an id like `pods/spec/nodeSelector/default`.
435
- Id string ` json:"id,omitempty"`
445
+ ID string ` json:"id,omitempty"`
436
446
437
- // ApiObject is the object whose behavior is being described. In
447
+ // APIObject is the object whose behavior is being described. In
438
448
// 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
440
450
// `core.v1.EnvFromSource`.
441
- ApiObject string ` json:"apiObject,omitempty"`
451
+ APIObject string ` json:"apiObject,omitempty"`
442
452
443
- // ApiField is filled out for generated tests that are testing the
453
+ // APIField is filled out for generated tests that are testing the
444
454
// 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"`
447
457
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"`
450
460
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"`
454
465
455
466
// Description specifies the behavior. For those generated from fields,
456
467
// this will identify if the behavior in question is for defaulting,
@@ -460,7 +471,33 @@ type Behavior struct {
460
471
}
461
472
```
462
473
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)
464
501
465
502
Some sets of behaviors may be tested in a similar, mechanical way. Basic CRUD
466
503
operations, including updates to specific fields and constraints on immutable
@@ -529,18 +566,6 @@ define:
529
566
With those two, the same creation and update scaffolding defined for individual
530
567
field updates can be reused.
531
568
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
-
544
569
### Risks and Mitigations
545
570
546
571
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,
549
574
this is not a high risk.
550
575
551
576
## Design Details
577
+ <<[ UNRESOLVED] >>
578
+ @johnbelamaric : note this section is still not updated for Phase 2
579
+ <<[ /UNRESOLVED] >>
552
580
553
581
Delivery of this KEP shall be done in the following phases:
554
582
555
583
### Phase 1
556
584
585
+ Phase 1 defined the basic behavior structure and enabled the generation of
586
+ behaviors from API schemas.
557
587
In Phase 1, we will:
558
588
* Implement the behavior formats and types described above. This will include
559
589
separate suites for tooling-generated behaviors and handcrafted behaviors.
@@ -565,52 +595,6 @@ In Phase 1, we will:
565
595
tooling around generation of conformance reports will not be changed in this
566
596
phase.
567
597
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
-
614
598
### Phase 2
615
599
616
600
In Phase 2, we will:
@@ -621,6 +605,8 @@ In Phase 2, we will:
621
605
* Implement coverage metrics comparing behavior lists to the coverage captured
622
606
by existing conformance tests.
623
607
608
+ ### Phase 3
609
+
624
610
### Graduation Criteria
625
611
As this is a tooling component and is not user facing, it does not follow the
626
612
ordinary alpha/beta/GA process. In 1.17, the intent is to implement Phase 1,
@@ -848,6 +834,8 @@ It('test string')`
848
834
directory structure for showing behavior/test separation
849
835
- 2019-10-01: Added detailed design; marked implementable
850
836
- 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
851
839
852
840
## Drawbacks
853
841
0 commit comments