Skip to content

Latest commit

 

History

History
94 lines (63 loc) · 4.75 KB

TAG_GUIDE.md

File metadata and controls

94 lines (63 loc) · 4.75 KB

Deprecation and New Feature Tag Guide

Deprecation Guide

New Feature Guide

Deprecation of a Feature for an Upcoming Release

we use //go:build tags in our test suites. The new branching strategy requires us to introduce a way to deprecate tests as well. We will be using go:build tags to deprecate tests. NOTE: All tests that are deprecated need the tag associated with the rancher version it is supported on to be included when running the test. Remember to do this step when running tests manually.

How To Deprecate

overall, the following steps should be followed:

  1. add go:build tags for each rancher version that is both:
  1. Deprecate the Tests
  2. Deprecate the Actions

for an example of how this was done, see the restrictedadmin rbac test cases and restrictedadmin rbac actions

Deprecating Tests

i.e. restricted admin has been enabled in rancher since at least 2.0.0, and the feature is being deprecated in 2.11.0 release.

At the time of deprecation, 2.10, 2.9, and 2.8 have limited support (as of 2/15/2025). Therefore any test(s) that use restricted admin should have && (2.8 || 2.9 || 2.10) go:build tags added.

All tests will fall into the following categories:

Deprecating an entire test file

simply add go:build tags to the existing ones at the top of each file.

Deprecating a subset of tests within a single test file
  1. create a new file
  2. move all deprecated tests to the new file
  3. rename the new file's suite, appropriate for the deprecated tests
  4. add go:build tags to the existing ones at the top of the new file

Deprecating Actions

  1. if the tests being deprecated are spread across multiple packages, the deprecated action(s) used by said tests should be moved to a new file in the same folder of actions, named appropriately, signifying they contain deprecated actions. All functions in the new file should have //Deprecated in their godoc comment(s)
  2. If the tests being deprecated are isolated to one package, the deprecated action(s) used by said tests should be moved to be a test helper within the deprecated test folder
Example action -> deprecated action
before deprecation:

actions/fleet/fleet.go

after deprecation:

actions/fleet/fleet.go -> contains non-deprecated functions actions/fleet/deprecatedfleet.go -> contains deprecated functions. In this new file, rename the package from fleet to deprecatedfleet

using the deprecated action

import the deprecatedfleet package into test files that will be deprecated.

Example action -> deprecate to test helper
before deprecation:

actions/fleet/fleet.go

after deprecation:
  • actions/fleet/fleet.go -> contains non-deprecated functions
  • validation/fleet/deprecated_fleet.go -> contains deprecated functions
    • these should now all be private functions, as they should not be imported outside of the test. Therefore, no importing necessary

Addition of a Feature for an Upcoming Release

we use //go:build tags in our test suites. The new branching strategy requires us to introduce a way to introduce features and tests around said feature. We will be using go:build tags to add feature tests.

How to Add Tests for a New Feature

Tags added to new features should not all versions of rancher that are in limited support and do not support the new feature. Follow these steps:

  1. add notted go:build tags for each rancher version that both:
  1. Add Tests for a New Feature

Adding Tests for a New Feature

i.e. clusterAgent and fleetAgent overrides were introduced in 2.7

At the time of introduction, 2.5 and 2.6 had limited support. Therefore any new test(s) for this feature should have && !(2.5 || 2.6) go:build tags added.

All tests for a new feature should have dedicated file(s) for each area they are being tested in. i.e. for clusterAgent and fleetAgent, there would be the following files added: validaiton/provisioning/k3s/agent_test.go validaiton/provisioning/rke2/agent_test.go validaiton/provisioning/rke1/agent_test.go validaiton/fleet/agent_test.go

all of which would have the not tags added.