Merge pull request #1099 from canonical/wsl_oobe_shutdown_testing
WSL OOBE: shutdown/reboot tests
This commit is contained in:
commit
ff953cb341
|
@ -25,4 +25,4 @@ wslconfadvanced:
|
||||||
motd_wslnewsenabled: false
|
motd_wslnewsenabled: false
|
||||||
automount_enabled: false
|
automount_enabled: false
|
||||||
automount_mountfstab: false
|
automount_mountfstab: false
|
||||||
shutdown: 'reboot'
|
shutdown: 'poweroff'
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: 1
|
||||||
|
early-commands:
|
||||||
|
- echo a
|
||||||
|
- ["sleep", "1"]
|
||||||
|
- echo a
|
||||||
|
locale: en_US
|
||||||
|
identity:
|
||||||
|
realname: Ubuntu
|
||||||
|
username: ubuntu
|
||||||
|
# ubuntu
|
||||||
|
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
|
||||||
|
wslconfbase:
|
||||||
|
automount_root: '/custom_mnt_path'
|
||||||
|
automount_options: 'metadata'
|
||||||
|
network_generatehosts: false
|
||||||
|
network_generateresolvconf: false
|
|
@ -29,7 +29,23 @@ validate () {
|
||||||
elif [ "${mode}" = "system_setup" ]; then
|
elif [ "${mode}" = "system_setup" ]; then
|
||||||
setup_mode="$2"
|
setup_mode="$2"
|
||||||
echo "system setup validation for $setup_mode"
|
echo "system setup validation for $setup_mode"
|
||||||
|
[ -d ".subiquity/run/subiquity/" ] || (echo "run/subiquity/ dir not created for status"; exit 1)
|
||||||
|
[ -e ".subiquity/run/subiquity/launcher-status" ] || (echo "run/subiquity/launcher-status not created"; exit 1)
|
||||||
|
expected_status="reboot"
|
||||||
|
if [ "${setup_mode}" = "autoinstall-full" ]; then
|
||||||
|
expected_status="shutdown"
|
||||||
|
elif [ "${setup_mode}" = "autoinstall-no-shutdown" ]; then
|
||||||
|
expected_status="complete"
|
||||||
|
fi
|
||||||
|
result_status="$(cat .subiquity/run/subiquity/launcher-status)"
|
||||||
|
if [ "${result_status}" != "${expected_status}" ]; then
|
||||||
|
echo "incorrect run/subiquity/launcher-status: expect ${expected_status}, got ${result_status}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
[ -d ".subiquity/etc/" ] || (echo "etc/ dir not created for config"; exit 1)
|
[ -d ".subiquity/etc/" ] || (echo "etc/ dir not created for config"; exit 1)
|
||||||
|
if [ "${setup_mode}" = "autoinstall-no-shutdown" ]; then
|
||||||
|
setup_mode="autoinstall"
|
||||||
|
fi
|
||||||
[ -d "system_setup/tests/golden/${setup_mode}" ] || (echo "tests/golden not found in system_setup"; exit 1)
|
[ -d "system_setup/tests/golden/${setup_mode}" ] || (echo "tests/golden not found in system_setup"; exit 1)
|
||||||
for file in system_setup/tests/golden/${setup_mode}/*.conf; do
|
for file in system_setup/tests/golden/${setup_mode}/*.conf; do
|
||||||
filename=$(basename ${file})
|
filename=$(basename ${file})
|
||||||
|
@ -121,13 +137,11 @@ grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades:
|
||||||
|
|
||||||
# The OOBE doesn't exist in WSL < 20.04
|
# The OOBE doesn't exist in WSL < 20.04
|
||||||
if [ "${RELEASE%.*}" -ge 20 ]; then
|
if [ "${RELEASE%.*}" -ge 20 ]; then
|
||||||
clean
|
for mode in "" "-full" "-no-shutdown"; do
|
||||||
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup.yaml --dry-run"
|
clean
|
||||||
validate "system_setup" "autoinstall"
|
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup${mode}.yaml --dry-run"
|
||||||
|
validate "system_setup" "autoinstall${mode}"
|
||||||
clean
|
done
|
||||||
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m system_setup.cmd.tui --autoinstall examples/autoinstall-system-setup-full.yaml --dry-run"
|
|
||||||
validate "system_setup" "autoinstall-full"
|
|
||||||
|
|
||||||
python3 -m system_setup.cmd.schema > "$testschema"
|
python3 -m system_setup.cmd.schema > "$testschema"
|
||||||
scripts/schema-cmp.py "autoinstall-system-setup-schema.json" "$testschema" --ignore-tz
|
scripts/schema-cmp.py "autoinstall-system-setup-schema.json" "$testschema" --ignore-tz
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import enum
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -23,6 +24,10 @@ from subiquity.server.controllers import ShutdownController
|
||||||
log = logging.getLogger("system_setup.server.controllers.restart")
|
log = logging.getLogger("system_setup.server.controllers.restart")
|
||||||
|
|
||||||
|
|
||||||
|
class WSLShutdownMode(enum.Enum):
|
||||||
|
COMPLETE = -1
|
||||||
|
|
||||||
|
|
||||||
class SetupShutdownController(ShutdownController):
|
class SetupShutdownController(ShutdownController):
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
|
@ -31,6 +36,7 @@ class SetupShutdownController(ShutdownController):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
self.root_dir = app.base_model.root
|
self.root_dir = app.base_model.root
|
||||||
self.app.controllers.Install = self.app.controllers.Configure
|
self.app.controllers.Install = self.app.controllers.Configure
|
||||||
|
self.mode = WSLShutdownMode.COMPLETE # allow the complete mode
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.app.aio_loop.create_task(self._wait_install())
|
self.app.aio_loop.create_task(self._wait_install())
|
||||||
|
|
Loading…
Reference in New Issue