Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions scripts/ingest-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

# Only if it passes these checks, the tarball gets ingested to the base dir in the repository specified below.

CVMFS_ROOT=${CUSTOM_CVMFS_ROOT:-/cvmfs}

basedir=versions
decompress="gunzip -c"
cvmfs_server="cvmfs_server"
Expand Down Expand Up @@ -180,8 +182,14 @@ function update_lmod_caches() {
error "the script for updating the Lmod caches (${update_caches_script}) does not have execute permissions!"
fi
${cvmfs_server} transaction "${cvmfs_repo}"
${update_caches_script} /cvmfs/${cvmfs_repo}/${basedir}/${version}
${cvmfs_server} publish -m "update Lmod caches after ingesting ${tar_file_basename}" "${cvmfs_repo}"
${update_caches_script} "${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/${version}"
ec=$?
if [ $ec -eq 0 ]; then
${cvmfs_server} publish -m "update Lmod caches after ingesting ${tar_file_basename}" "${cvmfs_repo}"
else
${cvmfs_server} abort -f "${cvmfs_repo}"
error "Update of Lmod caches after ingesting ${tar_file_basename} for ${cvmfs_repo} failed!"
fi
}

function ingest_init_tarball() {
Expand All @@ -206,7 +214,7 @@ function ingest_compat_tarball() {
# Handle the ingestion of tarballs containing a compatibility layer
check_arch
check_os
compat_layer_path="/cvmfs/${cvmfs_repo}/${basedir}/${version}/compat/${os}/${arch}"
compat_layer_path="${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/${version}/compat/${os}/${arch}"
# Assume that we already had a compat layer in place if there is a startprefix script in the corresponding CVMFS directory
if [ -f "${compat_layer_path}/startprefix" ];
then
Expand All @@ -217,7 +225,7 @@ function ingest_compat_tarball() {
old_layer_suffixed_path="${compat_layer_path}-${new_suffix}"
echo_yellow "Moving the existing compat layer from ${compat_layer_path} to ${old_layer_suffixed_path}..."
mv ${compat_layer_path} ${old_layer_suffixed_path}
tar -C "/cvmfs/${cvmfs_repo}/${basedir}/" -xzf "${tar_file}"
tar -C "${CVMFS_ROOT}/${cvmfs_repo}/${basedir}/" -xzf "${tar_file}"
${cvmfs_server} publish -m "updated compat layer for ${version}, ${os}, ${arch}" "${cvmfs_repo}"
ec=$?
if [ $ec -eq 0 ]
Expand Down
34 changes: 31 additions & 3 deletions scripts/test-ingest-tarball.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash

INGEST_SCRIPT=$(dirname "$(realpath $0)")/ingest-tarball.sh
TEST_OUTPUT=/dev/null # change to /dev/stdout to print test outputs for debugging purposes

# Temporary base dir for the tests
tstdir=$(mktemp -d)

# let ingest-tarball.sh script not use /cvmfs, but a temporary directory we can create
export CUSTOM_CVMFS_ROOT=${tstdir}/cvmfs

INGEST_SCRIPT=$(dirname "$(realpath $0)")/ingest-tarball.sh
TEST_OUTPUT=${tstdir}/out.txt

# Statistics
num_tests=0
num_tests_failed=0
Expand Down Expand Up @@ -87,15 +90,30 @@ tarballs_fail=(
"$tstdir/eessi-2000.01-compat-123456.tar.gz 2000.01 compat"
)

# update_lmod_caches.sh script requires that directory exists,
# and that script to update Lmod cache is found in there
repo_version_root="${CUSTOM_CVMFS_ROOT}/my.repo.tld/versions/2000.01"
lmod_libexec_path="${repo_version_root}/compat/linux/$(uname -m)/usr/share/Lmod/libexec/"
mkdir -p "${lmod_libexec_path}"
lmod_update_script="${lmod_libexec_path}/update_lmod_system_cache_files"
touch "${lmod_update_script}"
chmod u+x "${lmod_update_script}"


# Run the tests that should succeed
for ((i = 0; i < ${#tarballs_success[@]}; i++)); do
t=$(create_tarball ${tarballs_success[$i]})
"${INGEST_SCRIPT}" "my.repo.tld" "$t" >& "${TEST_OUTPUT}"
if [ ! $? -eq 0 ]; then
echo ">> ${tarballs_success[$i]} test with existing repo FAILed!" >&2
echo ">> output:" >&2
cat "${TEST_OUTPUT}" >&2
echo >&2
num_tests_failed=$((num_tests_failed + 1))
else
num_tests_succeeded=$((num_tests_succeeded + 1))
fi
rm -f "${TEST_OUTPUT}"
num_tests=$((num_tests + 1))
done

Expand All @@ -104,10 +122,15 @@ for ((i = 0; i < ${#tarballs_fail[@]}; i++)); do
t=$(create_tarball ${tarballs_fail[$i]})
"${INGEST_SCRIPT}" "my.repo.tld" "$t" >& "${TEST_OUTPUT}"
if [ ! $? -eq 1 ]; then
echo ">> ${tarballs_fail[$i]} test passed, but should have failed!" >&2
echo ">> output:" >&2
cat "${TEST_OUTPUT}" >&2
echo >&2
num_tests_failed=$((num_tests_failed + 1))
else
num_tests_succeeded=$((num_tests_succeeded + 1))
fi
rm -f "${TEST_OUTPUT}"
num_tests=$((num_tests + 1))
done

Expand All @@ -116,10 +139,15 @@ for ((i = 0; i < ${#tarballs_success[@]}; i++)); do
t=$(create_tarball ${tarballs_success[$i]})
"${INGEST_SCRIPT}" "my.nonexistingrepo.tld" "$t" >& "${TEST_OUTPUT}"
if [ ! $? -eq 1 ]; then
echo ">> ${tarballs_success[$i]} test passed with non-existing repo, should have failed!" >&2
echo ">> output:" >&2
cat "${TEST_OUTPUT}" >&2
echo >&2
num_tests_failed=$((num_tests_failed + 1))
else
num_tests_succeeded=$((num_tests_succeeded + 1))
fi
rm -f "${TEST_OUTPUT}"
num_tests=$((num_tests + 1))
done

Expand Down
Loading