mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 19:50:30 +00:00
Adding unit test for ephemeral feature flag
This was something that was missing in #707. Adding a new test to make sure the ephemeral feature flag from upstream is set up correctly by the script.
This commit is contained in:
committed by
Yusuke Kuoka
parent
b679a54196
commit
bf35c51440
81
test/entrypoint/should_switch_to_ephemeral_upstream_feature/test.sh
Executable file
81
test/entrypoint/should_switch_to_ephemeral_upstream_feature/test.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
# UNITTEST: should work as non ephemeral
|
||||
# Will simulate a scenario where ephemeral=false. expects:
|
||||
# - the configuration step to be run exactly once
|
||||
# - the entrypoint script to exit with no error
|
||||
# - the runsvc.sh script to run without the --once flag
|
||||
|
||||
source ../logging.sh
|
||||
|
||||
entrypoint_log() {
|
||||
while read I; do
|
||||
printf "\tentrypoint.sh: $I\n"
|
||||
done
|
||||
}
|
||||
|
||||
log "Setting up the test"
|
||||
export UNITTEST=true
|
||||
export RUNNER_HOME=localhome
|
||||
export RUNNER_NAME="example_runner_name"
|
||||
export RUNNER_REPO="myorg/myrepo"
|
||||
export RUNNER_TOKEN="xxxxxxxxxxxxx"
|
||||
export RUNNER_EPHEMERAL=true
|
||||
export RUNNER_FEATURE_FLAG_EPHEMERAL=true
|
||||
|
||||
mkdir -p ${RUNNER_HOME}/bin
|
||||
# add up the config.sh and runsvc.sh
|
||||
ln -s ../config.sh ${RUNNER_HOME}/config.sh
|
||||
ln -s ../../runsvc.sh ${RUNNER_HOME}/bin/runsvc.sh
|
||||
|
||||
cleanup() {
|
||||
rm -rf ${RUNNER_HOME}
|
||||
unset UNITTEST
|
||||
unset RUNNERHOME
|
||||
unset RUNNER_NAME
|
||||
unset RUNNER_REPO
|
||||
unset RUNNER_TOKEN
|
||||
unset RUNNER_EPHEMERAL
|
||||
unset RUNNER_FEATURE_FLAG_EPHEMERAL
|
||||
}
|
||||
|
||||
trap cleanup SIGINT SIGTERM SIGQUIT EXIT
|
||||
|
||||
log "Running the entrypoint"
|
||||
log ""
|
||||
|
||||
../../../runner/entrypoint.sh 2> >(entrypoint_log)
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
error "==========================================="
|
||||
error "Entrypoint script did not exit successfully"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Testing if we went through the configuration step only once"
|
||||
count=`cat ${RUNNER_HOME}/counter || echo "not_found"`
|
||||
if [ ${count} != "1" ]; then
|
||||
error "==============================================="
|
||||
error "The configuration step was not run exactly once"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Testing if the configuration included the --ephemeral flag"
|
||||
if ! grep -q -- '--ephemeral' ${RUNNER_HOME}/runner_config; then
|
||||
error "==============================================="
|
||||
error "The configuration did not include the --ephemeral flag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success "The configuration ran ${count} time(s)"
|
||||
|
||||
log "Testing if runsvc ran"
|
||||
if [ ! -f "${RUNNER_HOME}/runsvc_ran" ]; then
|
||||
error "=============================="
|
||||
error "The runner service has not run"
|
||||
exit 1
|
||||
fi
|
||||
success "The service ran"
|
||||
success ""
|
||||
success "==========================="
|
||||
success "Test completed successfully"
|
||||
Reference in New Issue
Block a user