Skip to content

test(vm): port VM placement scenarios to new framework#2268

Merged
danilrwx merged 12 commits into
mainfrom
fix/e2e/rewrite-legacy-affinity-test
Apr 24, 2026
Merged

test(vm): port VM placement scenarios to new framework#2268
danilrwx merged 12 commits into
mainfrom
fix/e2e/rewrite-legacy-affinity-test

Conversation

@danilrwx
Copy link
Copy Markdown
Contributor

@danilrwx danilrwx commented Apr 23, 2026

Description

Port the remaining VirtualMachineAffinityAndToleration legacy scenarios to the new e2e framework under test/e2e/vm.

The PR now covers all placement-related checks from the former legacy suite:

  • affinity / anti-affinity placement checks via status.nodeName
  • migration after affinity updates
  • spec.nodeSelector behavior
  • spec.affinity.nodeAffinity behavior

The new tests use the modern framework helpers and object builders, add cluster prerequisite checks for required node topology, and keep migration verification based on fresh MigrationState data and resulting status.nodeName.

The PR also includes a follow-up fix for the migrated placement scenarios: the selected target node is now preserved across By(...) steps, so the final assertions validate the actual migration destination instead of an empty outer-scope value.

The obsolete legacy file was removed after the remaining scenarios were ported.

Why do we need it, and what problem does it solve?

The old legacy affinity/toleration suite had already been partially migrated, but two placement scenarios still existed only in test/e2e/legacy/affinity_toleration.go.

Keeping the coverage split between legacy and the new framework made the suite harder to maintain and left outdated test infrastructure in place. This PR completes the migration, consolidates the scenarios in the new framework, and removes the leftover legacy implementation.

During validation, a scoping bug was also found in the new placement checks: targetNode was shadowed inside a step, which caused the outer variable to remain empty and made the final assertion fail despite successful migration. The fix makes the assertions stable and aligned with the actual migrated node.

What is the expected result?

  1. Run the e2e suite that includes test/e2e/vm/affinity_toleration.go.
  2. Verify that VM placement checks are performed through status.nodeName in the new framework.
  3. Verify that changing spec.nodeSelector to the current node does not trigger migration.
  4. Verify that changing spec.nodeSelector to another ready worker node triggers migration and updates status.nodeName.
  5. Verify that changing spec.affinity.nodeAffinity to the current node does not trigger migration.
  6. Verify that changing spec.affinity.nodeAffinity to another ready worker node triggers migration and updates status.nodeName.
  7. Verify that final assertions use the real target node selected during migration.
  8. Verify that the legacy test file is no longer needed.

Additionally, a compile-level validation was executed:

  • cd test/e2e && go test ./... -run '^$'

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: test
type: chore
summary: "Fix VM placement e2e coverage by migrating remaining legacy scenarios and preserving selected target nodes in final assertions."
impact_level: low

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx changed the title fix(e2e): rewrite legacy affinity test test(e2e): port VM placement scenarios to new framework Apr 23, 2026
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx marked this pull request as ready for review April 23, 2026 16:10
@danilrwx danilrwx requested a review from Isteb4k as a code owner April 23, 2026 16:10
@danilrwx danilrwx added this to the v1.9.0 milestone Apr 23, 2026
@danilrwx danilrwx changed the title test(e2e): port VM placement scenarios to new framework fix(vm): port VM placement scenarios to new framework Apr 23, 2026
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Comment thread test/e2e/vm/affinity_toleration.go Outdated
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx changed the title fix(vm): port VM placement scenarios to new framework test(vm): port VM placement scenarios to new framework Apr 24, 2026
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx force-pushed the fix/e2e/rewrite-legacy-affinity-test branch from 50cbdca to 525c788 Compare April 24, 2026 10:10
@danilrwx danilrwx requested a review from hardcoretime April 24, 2026 10:10
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx force-pushed the fix/e2e/rewrite-legacy-affinity-test branch from 21c2494 to 5ba5412 Compare April 24, 2026 13:20
@danilrwx danilrwx enabled auto-merge (squash) April 24, 2026 14:02
@danilrwx danilrwx merged commit 8c43a08 into main Apr 24, 2026
30 of 32 checks passed
@danilrwx danilrwx deleted the fix/e2e/rewrite-legacy-affinity-test branch April 24, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants