Files
krkn/CI
augmentcode[bot]andlnx01 03416ddbb6 test: migrate node_scenarios to tests_v2 pytest framework (#1400)
* test: add node_scenarios pytest migration under tests_v2

Migrate the node chaos coverage from the legacy CI/tests/test_node.sh into the v2 pytest framework at CI/tests_v2/scenarios/node_scenarios/.

- test_node_scenarios.py (TestNodeScenarios extends BaseScenarioTest): reboot and stop/start happy paths, node_name vs label_selector targeting, node recovery with finalizer, a control-plane safety guard, and negative cases (invalid selector, invalid node, missing actions, unsupported cloud type, unknown action).

- scenario_base.yaml: single node_scenarios entry (cloud_type docker, worker-only) patched per test.

- Register the node_scenarios marker in pytest.ini and document the scenario in CI/tests_v2/README.md.

Part of #1398. The coupled legacy move + workflow edit is left for a maintainer (the bot lacks GitHub App workflows permission); see PR description.

* test: address node_scenarios review feedback

- Reboot happy path now runs with kube_check: True so Krkn waits for the
  node to go Unknown then Ready, eliminating the race where wait_node_ready
  could pass against a stale Ready=True before the disruption propagated.
- Finalizer ensure_node_container_running now polls for Ready (bounded) when
  given k8s_core and logs non-zero 'start' exits, matching the docstring
  contract so a rerun never picks up an unrecovered node.
- Clarify the parallelism note: first/last worker separation only applies on
  multi-worker clusters (CI's 2-worker kind-config.yml); single-worker dev
  clusters share the node and rely on test ordering.

* fix: make node happy-path tests resilient to KinD multi-CP API LB

The reboot/stop_start happy paths failed in the Tests v2 job with
"Response ended prematurely": with kube_check enabled, Krkn's docker node
plugin polls the kube API (wait_for_unknown_status/wait_for_ready_status)
for ~40-50s after the disruption, and krkn-lib does not retry a transient
connection drop from the multi-control-plane KinD haproxy API load balancer.
The docker action itself succeeded in <0.5s.

Run both happy paths with kube_check: False so Krkn performs the action and
exits cleanly, and prove real disruption deterministically via the node
container's State.StartedAt advancing (runtime-level evidence, independent of
node-status timing). Recovery is still verified with the resilient test-side
wait_node_ready poll. README updated to match.

* refactor: move reusable node/container test helpers to lib/utils

Per review feedback, relocate the generic node-level helpers out of the
node_scenarios test module into the shared CI/tests_v2/lib/utils.py so future
node/container tests can reuse them: wait_node_ready, container_runtime,
container_started_at, assert_container_cycled, ensure_node_container_running,
and assert_kraken_marker. The test module now imports them; behavior is
unchanged and all 8 tests still collect.

* docs: fix duplicated word in tests_v2 README scenario list

* test: skip redundant container start in node finalizer to avoid noisy warnings

* test: honor KIND_EXPERIMENTAL_PROVIDER when selecting container runtime

* docs: align node finalizer wording with start-if-stopped behavior

* docs: align node test module docstring with start-if-stopped finalizer

* test: sort schedulable worker nodes for deterministic targeting

* test: assert combined node_stop_start_scenario marker in stop/start happy path

---------

Co-authored-by: augmentcode[bot] <185243770+augmentcode[bot]@users.noreply.github.com>
2026-06-15 14:51:15 +05:30
..
2025-12-15 11:46:48 -05:00

CI Tests

First steps

Edit functional_tests with tests you want to run

How to run

./CI/run.sh

This will run kraken using python, make sure python3 is set up and configured properly with all requirements

Adding a test case

  1. Add in simple scenario yaml file to execute under ../CI/scenarios/

  2. Copy test_application_outages.sh for example on how to get started

  3. Lines to change for bash script

    a. 11: Set scenario type to be your new scenario name

    b. 12: Add pointer to scenario file for the test

    c. 13: If a post action file is needed; add in pointer

    d. 14: Set filled in config yaml file name specific to your scenario

    e. 15: Make sure name of config in line 14 matches what you pass on this line

  4. Add test name to functional_tests file

    a. This will be the name of the file without ".sh"

  5. If any changes to the main config (other than the scenario list), please be sure to add them into the common_config