Skip to content

Commit

Permalink
Add RD_USE_SOCKET_VMNET option to BATS
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <[email protected]>
  • Loading branch information
jandubois committed Nov 1, 2023
1 parent ea2af44 commit 42d0673
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
15 changes: 15 additions & 0 deletions bats/tests/helpers/defaults.bash
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ if using_networking_tunnel && ! is_windows; then
fatal "RD_USE_NETWORKING_TUNNEL only works on Windows"
fi

########################################################################
: "${RD_USE_SOCKET_VMNET:=false}"

using_socket_vmnet() {
is_true "$RD_USE_SOCKET_VMNET"
}

if using_socket_vmnet && ! is_macos; then
fatal "RD_USE_SOCKET_VMNET only works on macOS"
fi

if using_socket_vmnet && sudo_needs_password; then
fatal "RD_USE_SOCKET_VMNET requires passwordless sudo"
fi

########################################################################
if ! is_unix && [ -n "${RD_MOUNT_TYPE:-}" ]; then
fatal "RD_MOUNT_TYPE only works on Linux and macOS"
Expand Down
1 change: 1 addition & 0 deletions bats/tests/helpers/info.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ show_info() { # @test
fi
printf "$format" "Using image allow list:" "$(bool using_image_allow_list)"
if is_macos; then
printf "$format" "Using socket_vmnet:" "$(bool using_socket_vmnet)"
printf "$format" "Using VZ emulation:" "$(bool using_vz_emulation)"
fi
if is_windows; then
Expand Down
6 changes: 6 additions & 0 deletions bats/tests/helpers/os.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ needs_port() {
fi
fi
}

sudo_needs_password() {
# Check if we can run /usr/bin/true (or /bin/true) without requiring a password
run sudo --non-interactive --reset-timestamp true
((status != 0))
}
8 changes: 7 additions & 1 deletion bats/tests/helpers/vm.bash
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ start_container_engine() {
--application.updater.enabled=false
--kubernetes.enabled=false
)
local admin_access=false

if [ -n "$RD_CONTAINER_ENGINE" ]; then
args+=(--container-engine.name="$RD_CONTAINER_ENGINE")
fi
if using_socket_vmnet; then
args+=(--experimental.virtual-machine.socket-vmnet)
admin_access=true
fi
if is_unix; then
args+=(
--application.admin-access=false
--application.admin-access="$admin_access"
--application.path-management-strategy rcfiles
--virtual-machine.memory-in-gb 6
--experimental.virtual-machine.mount.type="$RD_MOUNT_TYPE"
Expand Down

0 comments on commit 42d0673

Please sign in to comment.