mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
test(gui-client): multi-process smoke test for GUI + IPC service (#5672)
```[tasklist] ### Tasks - [x] Check the GUI saves its settings file - [x] Check the IPC service writes the device ID to disk - [x] Check the GUI writes a log file (skipped - we already check if the exported zip has any files in it) - [x] Run the crash file through `minidump-stackwalk` - [x] Reach feature parity with the original smoke tests - [x] Ready for review - [x] Finish #5452 - [ ] Start on #5453 ```
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Put `set -euox` in the top-level scripts directly. If it's only sourced,
|
||||
# and the source path is wrong, it will not throw an error and it'll be hard
|
||||
# to debug.
|
||||
# <https://github.com/firezone/firezone/actions/runs/9602401296/job/26483176628#step:11:12>
|
||||
set -euox pipefail
|
||||
|
||||
BUNDLE_ID="dev.firezone.client"
|
||||
FZ_GROUP="firezone-client"
|
||||
|
||||
LOGS_PATH="$HOME/.cache/$BUNDLE_ID/data/logs"
|
||||
|
||||
DUMP_PATH="$LOGS_PATH/last_crash.dmp"
|
||||
IPC_LOGS_PATH="/var/log/$BUNDLE_ID"
|
||||
RAN_BEFORE_PATH="$HOME/.local/share/$BUNDLE_ID/data/ran_before.txt"
|
||||
SETTINGS_PATH="$HOME/.config/$BUNDLE_ID/config/advanced_settings.json"
|
||||
SYMS_PATH="../target/debug/firezone-gui-client.syms"
|
||||
|
||||
PACKAGE=firezone-gui-client
|
||||
export RUST_LOG=firezone_gui_client=debug,warn
|
||||
export WEBKIT_DISABLE_COMPOSITING_MODE=1
|
||||
|
||||
# The dwp doesn't actually do anything if the exe already has all the debug info
|
||||
# Getting this to coordinate between Linux and Windows is tricky
|
||||
dump_syms ../target/debug/firezone-gui-client --output "$SYMS_PATH"
|
||||
ls -lash ../target/debug
|
||||
|
||||
sudo groupadd --force "$FZ_GROUP"
|
||||
sudo adduser "$USER" "$FZ_GROUP"
|
||||
|
||||
# Make the IPC log dir so that the zip export doesn't bail out
|
||||
sudo mkdir -p "$IPC_LOGS_PATH"
|
||||
|
||||
function run_fz_gui() {
|
||||
pwd
|
||||
# Does what it says
|
||||
sudo --preserve-env \
|
||||
su --login "$USER" --command \
|
||||
"xvfb-run --auto-servernum $PWD/../target/debug/$PACKAGE $*"
|
||||
}
|
||||
|
||||
function smoke_test() {
|
||||
# Make sure the files we want to check don't exist on the system yet
|
||||
stat "$LOGS_PATH" && exit 1
|
||||
stat "$SETTINGS_PATH" && exit 1
|
||||
# TODO: The device ID will be written by the tunnel, not the GUI, so we can't check that.
|
||||
# stat "$DEVICE_ID_PATH" && exit 1
|
||||
stat "$RAN_BEFORE_PATH" && exit 1
|
||||
|
||||
# Run the smoke test normally
|
||||
if ! run_fz_gui --no-deep-links smoke-test
|
||||
then
|
||||
minidump-stackwalk --symbols-path "$SYMS_PATH" "$DUMP_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Note the device ID
|
||||
# DEVICE_ID_1=$(cat "$DEVICE_ID_PATH")
|
||||
|
||||
# Make sure the files were written in the right paths
|
||||
# TODO: Inject some bogus sign-in sequence to test the actor_name file
|
||||
# https://stackoverflow.com/questions/41321092
|
||||
# TODO: Smoke test the IPC service
|
||||
# bash -c "stat \"${LOGS_PATH}/\"connlib*log"
|
||||
stat "$SETTINGS_PATH"
|
||||
# stat "$DEVICE_ID_PATH"
|
||||
# `ran_before` is now only written after a successful sign-in
|
||||
stat "$RAN_BEFORE_PATH" && exit 1
|
||||
|
||||
# Run the test again and make sure the device ID is not changed
|
||||
run_fz_gui --no-deep-links smoke-test
|
||||
# DEVICE_ID_2=$(cat "$DEVICE_ID_PATH")
|
||||
|
||||
#if [ "$DEVICE_ID_1" != "$DEVICE_ID_2" ]
|
||||
#then
|
||||
# echo "The device ID should not change if the file is intact between runs"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
# Clean up the files but not the folders
|
||||
rm -rf "$LOGS_PATH"
|
||||
rm "$SETTINGS_PATH"
|
||||
# rm "$DEVICE_ID_PATH"
|
||||
rm -f "$RAN_BEFORE_PATH"
|
||||
}
|
||||
|
||||
function crash_test() {
|
||||
# Delete the crash file if present
|
||||
rm -f "$DUMP_PATH"
|
||||
|
||||
# Fail if it returns success, this is supposed to crash
|
||||
run_fz_gui --crash --no-deep-links && exit 1
|
||||
|
||||
# Fail if the crash file wasn't written
|
||||
stat "$DUMP_PATH"
|
||||
}
|
||||
|
||||
function get_stacktrace() {
|
||||
minidump-stackwalk --symbols-path "$SYMS_PATH" "$DUMP_PATH"
|
||||
}
|
||||
|
||||
# Run the tests twice to make sure it's okay for the directories to stay intact
|
||||
smoke_test
|
||||
smoke_test
|
||||
crash_test
|
||||
crash_test
|
||||
get_stacktrace
|
||||
|
||||
# Clean up
|
||||
rm "$DUMP_PATH"
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Usage: This is made for CI, so it will change system-wide files without asking.
|
||||
# Read it before running on a dev system.
|
||||
# This script must run from an elevated shell so that Firezone won't try to elevate.
|
||||
|
||||
set -euox pipefail
|
||||
|
||||
# This prevents a `shellcheck` lint warning about using an unset CamelCase var
|
||||
if [[ -z "$ProgramData" ]]; then
|
||||
echo "The env var \$ProgramData should be set to \`C:\ProgramData\` or similar"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUNDLE_ID="dev.firezone.client"
|
||||
DUMP_PATH="$LOCALAPPDATA/$BUNDLE_ID/data/logs/last_crash.dmp"
|
||||
IPC_LOGS_PATH="$ProgramData/$BUNDLE_ID/data/logs"
|
||||
PACKAGE=firezone-gui-client
|
||||
|
||||
# Make the IPC log dir so that the zip export doesn't bail out
|
||||
mkdir -p "$IPC_LOGS_PATH"
|
||||
|
||||
function smoke_test() {
|
||||
# This array used to have more items
|
||||
# TODO: Smoke-test the IPC service
|
||||
files=(
|
||||
"$LOCALAPPDATA/$BUNDLE_ID/config/advanced_settings.json"
|
||||
)
|
||||
|
||||
# Make sure the files we want to check don't exist on the system yet
|
||||
# I'm leaning on ChatGPT and `shellcheck` for the syntax here.
|
||||
# Maybe this is about ready to be translated into Python or Rust.
|
||||
for file in "${files[@]}"
|
||||
do
|
||||
stat "$file" && exit 1
|
||||
done
|
||||
|
||||
# Run the smoke test normally
|
||||
$PWD/../target/debug/$PACKAGE smoke-test
|
||||
|
||||
# Make sure the files were written in the right paths
|
||||
for file in "${files[@]}"
|
||||
do
|
||||
stat "$file"
|
||||
done
|
||||
|
||||
# Clean up so the test can be cycled
|
||||
for file in "${files[@]}"
|
||||
do
|
||||
rm "$file"
|
||||
done
|
||||
}
|
||||
|
||||
function crash_test() {
|
||||
# Delete the crash file if present
|
||||
rm -f "$DUMP_PATH"
|
||||
|
||||
# Fail if it returns success, this is supposed to crash
|
||||
$PWD/../target/debug/$PACKAGE --crash && exit 1
|
||||
|
||||
# Fail if the crash file wasn't written
|
||||
stat "$DUMP_PATH"
|
||||
}
|
||||
|
||||
function get_stacktrace() {
|
||||
# Per `crash_handling.rs`
|
||||
SYMS_PATH="../target/debug/firezone-gui-client.syms"
|
||||
dump_syms ../target/debug/firezone_gui_client.pdb ../target/debug/firezone-gui-client.exe --output "$SYMS_PATH"
|
||||
ls -lash ../target/debug
|
||||
minidump-stackwalk --symbols-path "$SYMS_PATH" "$DUMP_PATH"
|
||||
}
|
||||
|
||||
smoke_test
|
||||
smoke_test
|
||||
crash_test
|
||||
get_stacktrace
|
||||
|
||||
# Clean up
|
||||
rm "$DUMP_PATH"
|
||||
Reference in New Issue
Block a user