-
Notifications
You must be signed in to change notification settings - Fork 12
Submission tests #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Submission tests #279
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9174fb6
test-sub.sh: a new testing script
theyoyojo 5b942d8
CI: enhance PINPing by running test-sub.sh
theyoyojo 76b69b2
test-sub-check.sh: add script to check results of test-sub.sh
theyoyojo 91ac6c8
treewide: s/DOCKER/PODMAN/g
theyoyojo 10eced6
test: consolidate repetitive setup in test-lib
theyoyojo 7cb495e
test: add more rubric tests cleanly by consolidating common testing code
theyoyojo 3643079
test: add test for whether only initial submission gets autozero
theyoyojo d08ad18
test: add test-sub4 to check peer review corner cases
theyoyojo 410599e
test-lib: use unpriveleged port
theyoyojo 8266b51
test-sub: correct bob version numbers
theyoyojo c06b7db
test: remove rubrics
theyoyojo d8279fc
test: remove rubric status checks
theyoyojo 5e09836
test: start.sh: simplify volume deletion
theyoyojo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| DOCKER_COMPOSE=${DOCKER_COMPOSE:-podman-compose} | ||
| PODMAN_COMPOSE=${PODMAN_COMPOSE:-podman-compose} | ||
|
|
||
| $DOCKER_COMPOSE exec git ./create-repo.sh "$@" | ||
| $PODMAN_COMPOSE exec git ./create-repo.sh "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| # This line: | ||
| # - aborts the script after any pipeline returns nonzero (e) | ||
| # - shows all commands as they are run (x) | ||
| # - sets any dereference of an unset variable to trigger an error (u) | ||
| # - causes the return value of a pipeline to be the nonzero return value | ||
| # of the furthest right failing command or zero if no command failed (o pipefail) | ||
| set -exuo pipefail | ||
|
|
||
| PODMAN=${PODMAN:-podman} | ||
| PODMAN_COMPOSE=${PODMAN_COMPOSE:-podman-compose} | ||
| SCRIPT_DIR=$(dirname "$(readlink -f "$0")") | ||
| WORKDIR=$(mktemp -d) | ||
|
|
||
| HOSTNAME_FROM_DOTENV="$(sh -c ' | ||
| set -o allexport | ||
| . ./.env | ||
| exec jq -r -n "env.SINGULARITY_HOSTNAME" | ||
| ')" | ||
|
|
||
| SINGULARITY_HOSTNAME=${SINGULARITY_HOSTNAME:-"${HOSTNAME_FROM_DOTENV}"} | ||
|
|
||
| setup_testdir() { | ||
| # Create test dir if it does not exist yet | ||
| mkdir -p test | ||
|
|
||
| # Reset the test directory | ||
| rm -f test/* | ||
|
|
||
| # put the cert in there | ||
| ${PODMAN} cp singularity_nginx_1:/etc/ssl/nginx/fullchain.pem test/ca_cert.pem | ||
| } | ||
|
|
||
| CURL_OPTS=( \ | ||
| --verbose \ | ||
| --cacert test/ca_cert.pem \ | ||
| --fail \ | ||
| --no-progress-meter \ | ||
| ) | ||
|
|
||
|
|
||
| get_git_port() { ${PODMAN} port singularity_git_1 | awk -F':' '{ print $2 }' ; } ; | ||
|
|
||
| # preconditions: | ||
| # - SCRIPT_DIR defined (singularity repo root) | ||
| # - WORKDIR defined (arbitrary) temp directory | ||
| setup_submissions_and_grading_repo() { | ||
| pushd "$SCRIPT_DIR" | ||
| # nuke grading repo inside container | ||
| # shellcheck disable=SC2016 | ||
| ${PODMAN_COMPOSE} exec git ash -c 'cd /var/lib/git/grading.git && for t in $(git tag); do git tag -d $t; done' | ||
| # crete and push fresh submissions repo | ||
| rm -rf repos/submissions | ||
| git/admin.sh submissions "course submissions repository" | ||
| pushd repos | ||
| git init --bare submissions | ||
| echo "course submissions repository" > submissions/description | ||
| # create a temporary workdir to push an initial commit to the submission repo | ||
| git init submissions_init | ||
| pushd submissions_init | ||
| echo "# submissions" > README.md | ||
| git add README.md | ||
| git status | ||
| git -c user.name=singularity -c user.email=singularity@singularity commit -sm 'init submissions repo' | ||
| git push ../submissions master | ||
| popd | ||
| rm -rf submissions_init | ||
| pushd submissions | ||
| git push --mirror http://localhost:"$(get_git_port)"/cgi-bin/git-receive-pack/submissions | ||
| popd | ||
| popd | ||
| popd | ||
|
|
||
| pushd "$WORKDIR" | ||
| mkdir certs | ||
| pushd certs | ||
| ${PODMAN} volume export singularity_ssl-certs > certs.tar | ||
| tar xf certs.tar | ||
| popd | ||
| git clone http://localhost:"$(get_git_port)"/submissions | ||
| popd | ||
| } | ||
|
|
||
| create_lighting_assignment() { | ||
| test -n "$1" | ||
| test -n "$2" | ||
| test -n "$3" | ||
| test -n "$4" | ||
|
|
||
| local asn="$1" | ||
| local i_s="$2" | ||
| local p_s="$3" | ||
| local f_s="$4" | ||
| set +u | ||
| local rub="$5" | ||
| set -u | ||
|
|
||
| RUBRIC= | ||
| if [ -n "$rub" ] | ||
| then | ||
| RUBRIC="-r $rub" | ||
| fi | ||
|
|
||
| pushd "$SCRIPT_DIR" | ||
| # create or recreate setup assignment | ||
| if denis/configure.sh dump | grep -q "^$asn:"; then | ||
| denis/configure.sh remove -a "$asn" | ||
| fi | ||
| denis/configure.sh create -a "$asn" -i "$(date -d "$i_s secs" +%s)" -p "$(date -d "$p_s secs" +%s)" -f "$(date -d "$f_s secs" +%s)" ${RUBRIC} | ||
| denis/configure.sh reload | ||
| popd | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after setup_submissions_and_grading_repo | ||
| setup_submissions_for() { | ||
| test -n "$1" | ||
| local user="$1" | ||
|
|
||
| pushd "$SCRIPT_DIR" | ||
| orbit/warpdrive.sh -u "$user" -p builder -n || orbit/warpdrive.sh -u "$user" -p builder -m | ||
| popd | ||
|
|
||
| pushd "$WORKDIR"/submissions | ||
| git config user.name "$user" | ||
| git config user.email "$user"@localhost.localdomain | ||
| git config sendemail.smtpUser "$user" | ||
| git config sendemail.smtpPass builder | ||
| git config sendemail.smtpserver localhost.localdomain | ||
| git config sendemail.smtpserverport 1465 | ||
theyoyojo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git config sendemail.smtpencryption ssl | ||
| popd | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - no non-tracked files in submissions repo | ||
| # - called after setup_submissions_for | ||
| enter_and_checkout() { | ||
| test -n "$1" | ||
| local branch="$1" | ||
|
|
||
| pushd "$WORKDIR"/submissions | ||
| git checkout --orphan "$1" | ||
| if [ -n "$(ls)" ] | ||
| then | ||
| git rm -rf ./* | ||
| fi | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to enter_and_checkout | ||
| exit_after_sending() { | ||
| test -n "$1" | ||
| local asn="$1" | ||
|
|
||
| git send-email \ | ||
| --confirm=never \ | ||
| --smtp-ssl-cert-path="$WORKDIR"/certs/fullchain.pem \ | ||
| --to "$asn"@localhost.localdomain \ | ||
| ./*.patch | ||
| rm ./*.patch | ||
| popd | ||
| sleep 1 | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to enter_and_checkout | ||
| write_commit_to() { | ||
| test -n "$1" && test -n "$2" | ||
| local content="$1" | ||
| local file="$2" | ||
| set +u # necessary since $3 is unbound in 2 arg case | ||
| local opt="$3" | ||
| set -x | ||
|
|
||
| mkdir -p $(dirname "$file") | ||
|
|
||
| if [ "$opt" == "append" ]; then | ||
| echo "$content" >> "$file" | ||
| else | ||
| echo "$content" > "$file" | ||
| fi | ||
|
|
||
| git add "$file" | ||
| git commit -sm "add $content to $file" | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to write_commit_to | ||
| fixup_cover() { | ||
| test -n "$1" | ||
| sed -i "s/\*\*\* SUBJECT HERE \*\*\*/$1/g" *0000-cover-letter.patch | ||
| sed -i "s/\*\*\* BLURB HERE \*\*\*/$1/g" *0000-cover-letter.patch | ||
| sed -i "\$a\\Signed-off-by: $(git config user.name) <$(git config user.email)>" *0000-cover-letter.patch | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| source test-lib | ||
|
|
||
| setup_testdir | ||
|
|
||
| # login as bob | ||
| curl --url "https://$SINGULARITY_HOSTNAME/login" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| "${CURL_OPTS[@]}" \ | ||
| -c test/cookies \ | ||
| --data "username=bob&password=builder" \ | ||
| | tee test/login_success \ | ||
| | grep "msg = bob authenticated by password" | ||
|
|
||
|
|
||
| # check for setup assignment and save dashboard | ||
| curl --url "https://$SINGULARITY_HOSTNAME/dashboard" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| -b test/cookies \ | ||
| "${CURL_OPTS[@]}" \ | ||
| | tee test/dashboard \ | ||
| | grep "setup" | ||
|
|
||
| grep "Total Score: 64.9" test/dashboard | ||
|
|
||
| grep "missing cover letter and first patch failed to apply!" test/dashboard | ||
|
|
||
| grep "bib Peer Review" test/dashboard | ||
|
|
||
| grep "bab Peer Review" test/dashboard | ||
|
|
||
| grep "patchset applies." test/dashboard | ||
|
|
||
| grep "Good effort but try harder next time." test/dashboard | ||
|
|
||
| # login as bab | ||
| curl --url "https://$SINGULARITY_HOSTNAME/login" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| "${CURL_OPTS[@]}" \ | ||
| -c test/cookies_bab \ | ||
| --data "username=bab&password=builder" \ | ||
| | tee test/login_success_bab \ | ||
| | grep "msg = bab authenticated by password" | ||
|
|
||
|
|
||
| # check for setup assignment and save dashboard | ||
| curl --url "https://$SINGULARITY_HOSTNAME/dashboard" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| -b test/cookies_bab \ | ||
| "${CURL_OPTS[@]}" \ | ||
| | tee test/dashboard_bab \ | ||
| | grep "setup" | ||
|
|
||
| grep "Total Score: 0.0" test/dashboard_bab | ||
|
|
||
| grep "bib Peer Review" test/dashboard_bab | ||
|
|
||
| grep "bob Peer Review" test/dashboard_bab | ||
|
|
||
| grep "patchset applies." test/dashboard_bab | ||
|
|
||
| grep "illegal patch 1: permission denied for path work!" test/dashboard_bab | ||
|
|
||
| grep 'Please review git' test/dashboard_bab | ||
|
|
||
| # login as bib | ||
| curl --url "https://$SINGULARITY_HOSTNAME/login" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| "${CURL_OPTS[@]}" \ | ||
| -c test/cookies_bib \ | ||
| --data "username=bib&password=builder" \ | ||
| | tee test/login_success_bib \ | ||
| | grep "msg = bib authenticated by password" | ||
|
|
||
|
|
||
| # check for setup assignment and save dashboard | ||
| curl --url "https://$SINGULARITY_HOSTNAME/dashboard" \ | ||
| --unix-socket ./socks/https.sock \ | ||
| -b test/cookies_bib \ | ||
| "${CURL_OPTS[@]}" \ | ||
| | tee test/dashboard_bib \ | ||
| | grep "setup" | ||
|
|
||
| grep "Total Score: 80.0" test/dashboard_bib | ||
|
|
||
| grep "bob Peer Review" test/dashboard_bib | ||
|
|
||
| grep "bab Peer Review" test/dashboard_bib | ||
|
|
||
| grep "patchset applies." test/dashboard_bib | ||
|
|
||
| grep 'Perfect. But no peer review!' test/dashboard_bib | ||
|
|
||
| echo "ALL SUBMISSION TESTS PASS" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.