Skip to content

convert some jobs to Ginkgo --label-filter  #32911

Open
@carlory

Description

@carlory

Why we need this change:

  • Filtering tests via --label-filter is more readable and easier to review.

  • --label-filter can specify an allow-list of features supported by a job. When adding new tests which depend on a new feature, they don't accidentally run and fail in existing jobs, as they do now when the SKIP regexp doesn't get updated in lockstep.

  • As soon as all active jobs are converted and use the --label-filter=Feature: isEmpty expression or some variant of it, we can remove the requirement that a test which depends only on feature gates must have a [Feature:<xxx>] tag in addition to [FeatureGate:<xxx>] (this blocked PR makes such a change). WithFeatureGate automatically adds Alpha or Beta to the set of required features, so they still get skipped unless a job explicitly allows them.

    At that point we can run tests from different SIGs in the shared alpha/beta jobs (pull-kubernetes-kind-alpha-features, pull-kubernetes-kind-beta-features, pull-kubernetes-e2e-kind-alpha-beta-features, kind-master-alpha, kind-master-beta, kind-master-alpha-beta) without having to constantly update those jobs.

    Replacing [Feature:xxx] with [FeatureGates:xxx] is not part of this issue. Test owners need to do that once this issue is resolved to take advantage of the generic jobs.

Some background references:

Example PRs:

Examples:

e2e_node job:

- '--test_args=--timeout=1h --label-filter="Feature: containsAny DynamicResourceAllocation && Feature: isSubsetOf DynamicResourceAllocation && !Flaky"'

e2e jobs:

- name: LABEL_FILTER
value: "Feature: isEmpty"

- name: FEATURE_GATES
value: '{"AllBeta":true}'
- name: RUNTIME_CONFIG
value: '{"api/beta":"true", "api/ga":"true"}'
- name: LABEL_FILTER
value: "!Slow && !Disruptive && !Flaky && Feature: isSubsetOf Beta"

How to do it

  • Some tips for figuring out how to replace --focus/skip with --label-filter:

    • go test -v ./test/e2e -args -list-tests (same for e2e_node) shows all tests.
    • Note that not all tags in [] are also labels. Only those listed by go test -v ./test/e2e -args -list-labels are proper labels. If you find that you need to filter by something that isn't a label yet, then replace the inline text with WithLabel.
    • _output/bin/ginkgo --dry-run [--focus/skip/label-filter=...] ./test/e2e can be used to compare how many and, when adding -v, which tests would run. Note that statistics for actual runs may differ when tests ask to be skipped when invoked. (install ginkgo via make ginkgo)
  • If a job has a "canary" version, update that version first and try it out.

  • When converting some real jobs:

    • Create a separate tracking issue with a link to the jobs' testgrid entry.
    • Convert the job, linking to that issue with Related-to: ... (not Fixes: ...!).
    • Verify that the job still works as intended, then close the issue.
  • After converting a pre-submit job successfully, do the same for the corresponding periodic job.

  • Some best practices:

    • Replace focus/skip completely with a single label-filter.
    • If a job has a TODO(bentheelder): reduce the skip list further, check whether any of those skip entries really are still needed. Typically those are out-dated workarounds for know issues which got resolved already long ago. Skipping tests by name should not be needed anymore.
    • Include !Flaky even if you currently don't have flaky tests. Having it in the jobs is convenient when some tests turns out to be problematic and needs to be disable temporarily.
    • Exclude tests with special requirements with Feature: isEmpty.
    • Feature: containsAny <my feature> && Feature: isSubsetOf <my feature> runs tests with have the <my feature> label and no other unknown features. Use this in dedicated jobs for that feature. Note that e2e_node uses NodeFeature for the same purpose.
    • Ginkgo can run serial jobs together with parallel ones in a single invocation by running the serial jobs (and only those) sequentially, so it's not absolutely required to use !Serial when running ginkgo -p and there is no need for separate serial/parallel jobs.
    • Beware that serial tests can affect the overall runtime. It might be useful to skip with !Slow and !Serial in pre-submits and only run the skipped tests in periodic jobs.

What should be cleaned up or changed:

Metadata

Metadata

Assignees

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.sig/testingCategorizes an issue or PR as relevant to SIG Testing.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions