-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ba-st/tests_for_migration_failures
Tests for migration failures
- Loading branch information
Showing
6 changed files
with
307 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly ANSI_BOLD="\\033[1m" | ||
readonly ANSI_RED="\\033[31m" | ||
readonly ANSI_GREEN="\\033[32m" | ||
readonly ANSI_BLUE="\\033[34m" | ||
readonly ANSI_RESET="\\033[0m" | ||
|
||
function print_info() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
function print_success() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
function print_error() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2 | ||
else | ||
echo "$1" 1>&2 | ||
fi | ||
} | ||
|
||
function executeInDocker() { | ||
docker exec gs64-migration "$@" | ||
} | ||
|
||
function assertMigrationLogIncludes() { | ||
executeInDocker ./scripts/assertMigrationLogIncludesMessage.sh "$1" | ||
} | ||
|
||
function assertConsistencyLogIncludes() { | ||
executeInDocker ./scripts/assertConsistencyLogIncludesMessage.sh "$1" | ||
} | ||
|
||
set -e | ||
|
||
print_info "Starting stone" | ||
|
||
docker pull ghcr.io/ba-st/gs64-rowan:v3.7.0 | ||
|
||
docker run --rm --detach --name gs64-migration \ | ||
-e TZ="America/Argentina/Buenos_Aires" \ | ||
--cap-add=SYS_RESOURCE \ | ||
--volume="$PWD":/opt/gemstone/projects/GemStone-64-Migration-Tools:ro \ | ||
--volume="$PWD"/.docker/scripts:/opt/gemstone/scripts:ro \ | ||
ghcr.io/ba-st/gs64-rowan:v3.7.0 | ||
|
||
sleep 1 | ||
|
||
print_info "Loading Migration Tools" | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GemStone-64-Migration-Tools \ | ||
GemStone-64-Migration-Tools-Deployment | ||
|
||
print_info "Loading Migration Examples base version" | ||
|
||
executeInDocker git clone -b base \ | ||
https://github.com/ba-st/GS64-Migration-Examples.git \ | ||
/opt/gemstone/projects/GS64-Migration-Examples | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GS64-Migration-Examples \ | ||
GS64-Migration-Examples | ||
|
||
print_info "Configuring instance migrator" | ||
|
||
executeInDocker ./scripts/installInstanceMigrator.sh | ||
|
||
print_info "Loading Migration Examples failed_migration version" | ||
|
||
docker exec --workdir /opt/gemstone/projects/GS64-Migration-Examples \ | ||
gs64-migration \ | ||
git checkout failed_migration | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GS64-Migration-Examples \ | ||
GS64-Migration | ||
|
||
print_info "Checking migration result" | ||
|
||
executeInDocker ./scripts/checkMigrationFailed.sh | ||
assertMigrationLogIncludes "Migration finished with errors." | ||
assertMigrationLogIncludes "2 instances raised a MigrationError" | ||
assertMigrationLogIncludes "There are 1 classes with new versions, but no migration command applicable. Review your migration scripts." | ||
assertMigrationLogIncludes "ClassWithInstanceVariableToBeAdded" | ||
assertMigrationLogIncludes "There are 1 removed classes but having live instances in the repository." | ||
assertMigrationLogIncludes "ClassToBeRenamed" | ||
print_success " - Migration failed as expected [OK]" | ||
|
||
print_info "Running consistency checks" | ||
|
||
executeInDocker ./scripts/runFailingConsistencyChecks.sh | ||
assertConsistencyLogIncludes "1 classes have more than one version" | ||
assertConsistencyLogIncludes "ClassWithInstanceVariableToBeAdded" | ||
assertConsistencyLogIncludes "3 classes are unpublished" | ||
assertConsistencyLogIncludes "ClassWithInstanceVariableToBeAdded" | ||
assertConsistencyLogIncludes "ClassToBeRenamed" | ||
assertConsistencyLogIncludes "ClassToChangeSuperclassToStatefull" | ||
print_success " - Consistency checks failed as expected [OK]" | ||
|
||
print_info "Stopping stone" | ||
docker stop gs64-migration |
This file contains 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,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly ANSI_BOLD="\\033[1m" | ||
readonly ANSI_RED="\\033[31m" | ||
readonly ANSI_GREEN="\\033[32m" | ||
readonly ANSI_BLUE="\\033[34m" | ||
readonly ANSI_RESET="\\033[0m" | ||
|
||
function print_info() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
function print_success() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
function print_error() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2 | ||
else | ||
echo "$1" 1>&2 | ||
fi | ||
} | ||
|
||
function executeInDocker() { | ||
docker exec gs64-migration "$@" | ||
} | ||
|
||
function assertMigrationLogIncludes() { | ||
docker exec gs64-migration ./scripts/assertMigrationLogIncludesMessage.sh "$1" | ||
} | ||
|
||
set -e | ||
|
||
print_info "Starting stone" | ||
|
||
docker pull ghcr.io/ba-st/gs64-rowan:v3.7.0 | ||
|
||
docker run --rm --detach --name gs64-migration \ | ||
-e TZ="America/Argentina/Buenos_Aires" \ | ||
--cap-add=SYS_RESOURCE \ | ||
--volume="$PWD":/opt/gemstone/projects/GemStone-64-Migration-Tools:ro \ | ||
--volume="$PWD"/.docker/scripts:/opt/gemstone/scripts:ro \ | ||
ghcr.io/ba-st/gs64-rowan:v3.7.0 | ||
|
||
sleep 1 | ||
|
||
print_info "Loading Migration Tools" | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GemStone-64-Migration-Tools \ | ||
GemStone-64-Migration-Tools-Deployment | ||
|
||
print_info "Loading Migration Examples base version" | ||
|
||
executeInDocker git clone -b base \ | ||
https://github.com/ba-st/GS64-Migration-Examples.git \ | ||
/opt/gemstone/projects/GS64-Migration-Examples | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GS64-Migration-Examples \ | ||
GS64-Migration-Examples | ||
|
||
print_info "Configuring instance migration reporter" | ||
|
||
executeInDocker ./scripts/installInstanceMigrationReporter.sh | ||
|
||
print_info "Loading Migration Examples failed_migration version" | ||
|
||
docker exec --workdir /opt/gemstone/projects/GS64-Migration-Examples \ | ||
gs64-migration \ | ||
git checkout failed_migration | ||
|
||
executeInDocker ./load-rowan-project.sh \ | ||
GS64-Migration-Examples \ | ||
GS64-Migration-Examples | ||
|
||
print_info "Running Assertions" | ||
assertMigrationLogIncludes "2 classes have new versions" | ||
assertMigrationLogIncludes "ClassToChangeSuperclassToStatefull" | ||
assertMigrationLogIncludes "ClassWithInstanceVariableToBeAdded" | ||
print_success " - Number of classes with new versions [OK]" | ||
|
||
assertMigrationLogIncludes "2 classes were removed" | ||
assertMigrationLogIncludes "ClassToBeRenamed" | ||
assertMigrationLogIncludes "ClassToRemoveWithoutInstances" | ||
print_success " - Number of removed classes [OK]" | ||
|
||
print_info "Stopping stone" | ||
docker stop gs64-migration |
This file contains 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,24 @@ | ||
#!/usr/bin/env bash | ||
readonly ANSI_BOLD="\\033[1m" | ||
readonly ANSI_RED="\\033[31m" | ||
readonly ANSI_RESET="\\033[0m" | ||
|
||
function print_error() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2 | ||
else | ||
echo "$1" 1>&2 | ||
fi | ||
} | ||
|
||
message=$1 | ||
output=/opt/gemstone/logs/consistency-checks.log | ||
|
||
if [ "$(grep -c "$message" "$output")" -eq 0 ]; then | ||
print_error "Expected output: '$message' not found in the consistency checks log" | ||
print_error "Output contents:" | ||
cat "$output" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains 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,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly ANSI_BOLD="\\033[1m" | ||
readonly ANSI_RED="\\033[31m" | ||
readonly ANSI_GREEN="\\033[32m" | ||
readonly ANSI_BLUE="\\033[34m" | ||
readonly ANSI_RESET="\\033[0m" | ||
|
||
function print_error() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2 | ||
else | ||
echo "$1" 1>&2 | ||
fi | ||
} | ||
|
||
function print_success() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
function print_info() { | ||
if [ -t 1 ]; then | ||
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
if topaz -i -q <<EOF | ||
set gemstone gs64stone user SystemUser pass ${GS64_SYSTEM_USER_PASSWORD} | ||
iferror exit 1 | ||
login | ||
expectvalue false | ||
run | ||
Rowan platform instanceMigrator migrationWasSuccessful | ||
% | ||
logout | ||
exit 0 | ||
EOF | ||
then | ||
print_success "Migration failed as expected" | ||
print_info "Details of the process:\n" | ||
cat /opt/gemstone/logs/loading-rowan-projects.log | ||
exit 0 | ||
else | ||
print_error "##########################################" | ||
print_error " Migration succeded when expected to fail" | ||
print_error "##########################################" | ||
cat /opt/gemstone/logs/loading-rowan-projects.log | ||
exit 1 | ||
fi |
This file contains 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,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
topaz -i -q <<EOF > "${GEMSTONE_LOG_DIR}/consistency-checks.log" | ||
set gemstone gs64stone user SystemUser pass ${GS64_SYSTEM_USER_PASSWORD} | ||
iferror exit 1 | ||
login | ||
expectvalue false | ||
run | ||
Rowan platform instanceMigrator runConsistencyChecks | ||
% | ||
logout | ||
exit 0 | ||
EOF |
This file contains 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