Skip to content
Open
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
13 changes: 0 additions & 13 deletions tests/coverage-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Removes objects from the bucket and indexd records, then runs monorepo tests (clean, normal, clone) twice.
set -euo pipefail


usage() {
cat <<-EOF
Usage: $0 [options]
Expand Down Expand Up @@ -40,7 +39,6 @@ EOF
exit 0
}


# Accept named parameters (flags override environment variables)
POD="${POD:-}"
POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-}"
Expand Down Expand Up @@ -70,7 +68,6 @@ while [ $# -gt 0 ]; do
esac
done


# echo commands as they are executed
if [ -z "${GIT_TRACE:-}" ]; then
echo "For more verbose git output, consider setting the following environment variables before re-running the script:" >&2
Expand All @@ -94,7 +91,6 @@ gofmt -s -w .
# build to ensure no compile errors
go build


# Derive PROJECT_ID from RESOURCE (e.g. /programs/<prog>/projects/<proj> -> <prog>-<proj>)
_resource_clean="${RESOURCE#/}" # drop leading slash if present
_resource_clean="${_resource_clean%/}" # drop trailing slash if present
Expand Down Expand Up @@ -147,18 +143,13 @@ if [ ! -d "$UTIL_DIR" ]; then
exit 1
fi

# before running tests, build the executables with coverage instrumentation


# build git-drs with coverage instrumentation
go build -cover -covermode=atomic -coverpkg=./... -o "${BUILD_DIR}/git-drs" .

export PATH="${BUILD_DIR}:${PATH}"

# get rid of old binary if exists
rm git-drs || true
#go build
# unit tests
which git-drs
rm -rf coverage/unit
mkdir -p coverage/unit
Expand Down Expand Up @@ -231,14 +222,10 @@ if ! $UTIL_DIR/list-indexd-sha256.sh "$POD" "$POSTGRES_PASSWORD" "$RESOURCE" | $
exit 1
fi


echo "coverage-test.sh: all steps completed successfully." >&2
go tool covdata textfmt -i="${INTEGRATION_COV_DIR}" -o "${INTEGRATION_PROFILE}"

echo "Integration coverage profile saved to ${INTEGRATION_PROFILE}"


echo "Combining coverage profiles..."
tests/scripts/coverage/combine-coverage.sh


20 changes: 20 additions & 0 deletions tests/scripts/coverage/run-e2e-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR=$(git rev-parse --show-toplevel)
COVERAGE_ROOT="${COVERAGE_ROOT:-${ROOT_DIR}/coverage}"
BUILD_DIR="${BUILD_DIR:-${ROOT_DIR}/build/coverage}"
export PATH="${BUILD_DIR}:${PATH}"

INTEGRATION_COV_DIR="${INTEGRATION_COV_DIR:-${COVERAGE_ROOT}/integration/raw}"
INTEGRATION_PROFILE="${INTEGRATION_PROFILE:-${COVERAGE_ROOT}/integration/coverage.out}"
export GOCOVERDIR="${INTEGRATION_COV_DIR}"

mkdir -p "${BUILD_DIR}" "${INTEGRATION_COV_DIR}" "$(dirname "${INTEGRATION_PROFILE}")"
go build "${GOFLAGS[@]}" -cover -covermode=atomic -coverpkg=./... -o "${BUILD_DIR}/git-drs" .


"${E2E_SCRIPT}"

go tool covdata textfmt -i="${INTEGRATION_COV_DIR}" -o "${INTEGRATION_PROFILE}"
echo "Integration coverage profile saved to ${INTEGRATION_PROFILE}"
69 changes: 69 additions & 0 deletions tests/scripts/e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e
set -x

# Set repo name and remote URL
REPO_NAME="git-drs-e2e-test"
GIT_USER="cbds"

# REMOTE_URL="https://source.ohsu.edu/$GIT_USER/$REPO_NAME"
REMOTE_URL="git@source.ohsu.edu:$GIT_USER/$REPO_NAME.git"

# Clean up if rerunning (don't fail if not removable)
rm -rf "$REPO_NAME" || true

# Create directory and initialize git
mkdir "$REPO_NAME"
cd "$REPO_NAME"

# Step 1: Initialize Repository
git init
git drs init
git drs remote add gen3 origin --cred ~/.gen3/credentials.json --project cbds-git_drs_test --bucket cbds

# set branch / add remote
git branch -M main
git remote add origin "$REMOTE_URL"

git lfs track "*.greeting"
git add .gitattributes

# Step 2: Create and Commit Initial Files
mkdir -p data/A data/B data/C

DATE="hello $(date)"
echo $DATE > data/A/simple.greeting
echo $DATE > data/B/simple.greeting
echo $DATE > data/C/simple.greeting

git add data/
git commit -m "Initial commit: Add .greeting files with 'hello'"

# Prompt user for remote if not set
git push --set-upstream origin main

# Step 3: Add single duplicate file (edge case)
cp data/A/simple.greeting data/A/duplicate.greeting
git add data/A/duplicate.greeting
git commit -m "Add duplicate .greeting file"
git push

# Step 4: Update and Commit File Changes
echo "A" >> data/A/simple.greeting
echo "B" >> data/B/simple.greeting
echo "C" >> data/C/simple.greeting

git add data/
git commit -m "Update .greeting files with folder-specific greetings"
git push

# Step 5: clone and pull
git clone "$REMOTE_URL"
cd "$REPO_NAME"
git drs init
git drs remote add gen3 origin --cred ~/.gen3/credentials.json --project cbds-git_drs_test --bucket cbds
git lfs pull

# Step 6: test data provenance
git checkout HEAD~1
git lfs pull
Loading