Skip to content

Commit

Permalink
Merge pull request #156 from rhatdan/cleanup
Browse files Browse the repository at this point in the history
Remove unused functions from tests
  • Loading branch information
ericcurtin authored Sep 18, 2024
2 parents 26fbeb2 + d6e2b47 commit 255588f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 80 deletions.
3 changes: 0 additions & 3 deletions test/system/000-TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ function teardown() {

# FIXME: very basic one-pass example
@test "ramalama FOO - description of test" {
# FIXME: please try to remove this line; that is, try to write tests
# that will pass as both root and rootless.

# FIXME: template for run commands. Always use 'run_ramalama'!
# FIXME: The '?' means 'ignore exit status'; use a number if you
# FIXME: expect a precise nonzero code, or omit for 0 (usual case).
Expand Down
15 changes: 0 additions & 15 deletions test/system/015-help.bats
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ function check_help() {
# This should be disallowed with a clear message.
if expr "$full_help" : ".*-l, --latest" >/dev/null; then
local nope="exec list port ps top" # these can't be tested
if is_rootless; then
nope="$nope mount restore" # these don't work rootless
fi
if ! grep -wq "$cmd" <<<$nope; then
run_ramalama 2 "$@" $cmd -l nonexistent-container
is "$output" "Error: .*--latest and \(containers\|pods\|arguments\) cannot be used together" \
Expand All @@ -83,18 +80,6 @@ function check_help() {

# If usage has required arguments, try running without them.
if expr "$usage" : '[A-Z]' >/dev/null; then
# Exceptions: these commands don't work rootless
if is_rootless; then
# "pause is not supported for rootless containers"
if [[ "$cmd" = "pause" ]] || [[ "$cmd" = "unpause" ]]; then
continue
fi
# "network rm" too
if [ "$@" = "network" -a "$cmd" = "rm" ]; then
continue
fi
fi

# The </dev/null protects us from 'ramalama login' which will
# try to read username/password from stdin.
dprint "$command_string (without required args)"
Expand Down
63 changes: 1 addition & 62 deletions test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ function _prefetch() {
function skopeo() {
local xdg=${XDG_RUNTIME_DIR}
if [ -z "$xdg" ]; then
if is_rootless; then
xdg=/run/user/$(id -u)
fi
xdg=/run/user/$(id -u)
fi
XDG_RUNTIME_DIR=${xdg} command skopeo "$@"
}
Expand Down Expand Up @@ -558,18 +556,10 @@ function wait_for_file_content() {
# BEGIN miscellaneous tools

# Shortcuts for common needs:
function is_rootless() {
[ "$(id -u)" -ne 0 ]
}

function is_aarch64() {
[ "$(uname -m)" == "aarch64" ]
}

function selinux_enabled() {
/usr/sbin/selinuxenabled 2> /dev/null
}

# Returns the OCI runtime *basename* (typically llama.cpp or vllm). Much as we'd
# love to cache this result, we probably shouldn't.
function ramalama_runtime() {
Expand Down Expand Up @@ -605,57 +595,6 @@ function ramalama_isolation_opts() {
done
}

# rhbz#1895105: rootless journald is unavailable except to users in
# certain magic groups; which our testuser account does not belong to
# (intentional: that is the RHEL default, so that's the setup we test).
function journald_unavailable() {
if ! is_rootless; then
# root must always have access to journal
return 1
fi

run journalctl -n 1
if [[ $status -eq 0 ]]; then
return 1
fi

if [[ $output =~ permission ]]; then
return 0
fi

# This should never happen; if it does, it's likely that a subsequent
# test will fail. This output may help track that down.
echo "WEIRD: 'journalctl -n 1' failed with a non-permission error:"
echo "$output"
return 1
}

# Wait for the pod (1st arg) to transition into the state (2nd arg)
function _ensure_pod_state() {
for i in {0..5}; do
run_ramalama pod inspect $1 --format "{{.State}}"
if [[ $output == "$2" ]]; then
return
fi
sleep 0.5
done

die "Timed out waiting for pod $1 to enter state $2"
}

# Wait for the container's (1st arg) running state (2nd arg)
function _ensure_container_running() {
for i in {0..20}; do
run_ramalama container inspect $1 --format "{{.State.Running}}"
if [[ $output == "$2" ]]; then
return
fi
sleep 0.5
done

die "Timed out waiting for container $1 to enter state running=$2"
}

#########
# die # Abort with helpful message
#########
Expand Down

0 comments on commit 255588f

Please sign in to comment.