Scenarios
August 20, 2019 ยท View on GitHub
The scenario runner - perturb.sh
- Cloud provider - is hardcoded to work with digital ocean and hobbykube
- Node detection - Expects exactly 3 nodes - 1 master and 2 slaves
--auto-populateusesdoctland a regexp to find the droplets
Phases
handle_arguments- Argument parsing and vaildationrun_scenario- Setup the scenariorun_test_loop- Run Test loop
Scenario setup
Validation validate_instructions
Before doing anything perturb.sh checks that it can only find bash scripts with well-known names.
Scenario scripts are found by looking for files with a .sh extension under the $SCENARIO_DIR
worker-any.sh- runs on a randomly chosen slaveworker-1.sh- runs on slave 1worker-2.sh- runs on slave 2workers-every.sh- runs on slaves 1 & 2nodes-every.sh- runs on master and slaves 1 and 2master.sh- runs on mastertest.sh- Ignored for setup
Any other .sh scripts will cause an error
Configure Kubernetes run_kubectl_yaml
- Loop over subdirectories in
$SCENARIO_DIR. Subdirectories must be named after the command to be run bykubectl. This is currently always onlyapply - Concatenate all the
*.ya?mlfiles together into a string - Run the concatenated string through ssh/kubectl on the master
Run the validated shell scripts run_scenario
Runs each shell script on the appropriate host (see above)
Cleanup
Special scenarios
cleanupnoop
Scripts run always
no-cleanup.doIf this is presentscenario/cover-tracks.shwill not runreboot-all.doIf this is presentscenario/reboot.shwill run on all nodesreboot-workers.doIf this is presentscenario/reboot.shwill run on master nodereboot-master.doIf this is presentscenario/reboot.shwill run on worker nodes- temporary script to copy base64 encoded
$SCENARIO_DIR/flag.txtto/root/flag.txtif that file exists in$SCENARIO_DIR
Scripts only run for "normal scenarios
- temporary script to copy
$SCENARIO_DIR/challenge.txtto/opt/challenge.txt