Skip to content

Commit eba50df

Browse files
authored
Improve tests: check that stack startup creates ES indices (#462)
* Improve tests: check that stack startup creates ES indices * Refactor test script, add test for Translation presence
1 parent 53f5af5 commit eba50df

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/tests.sh

+18-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ print_heading() {
1515
echo ">"
1616
}
1717

18+
# Run commands in the zammad-railsserver container in a way that also allows the rails stack to start.
19+
railsserver_run_command() {
20+
docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver "$@"
21+
}
22+
1823
print_heading "wait for zammad to be ready…"
1924
docker compose wait zammad-init
2025
docker compose exec zammad-nginx bash -c "curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:8080 | grep 'Zammad'"
@@ -28,24 +33,32 @@ then
2833
print_heading "Zammad is available via external port :)"
2934
fi
3035

36+
print_heading "Check if elasticsearch index is present…"
37+
railsserver_run_command rails r "SearchIndexBackend.index_exists?('Ticket') || exit(1)"
38+
print_heading "Elasticsearch index is present :)"
39+
40+
print_heading "Check that translations are present…"
41+
railsserver_run_command rails r "Translation.any? || exit(1)"
42+
print_heading "Translations are present :)"
43+
3144
print_heading "Execute autowizard…"
32-
docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rake zammad:setup:auto_wizard
45+
railsserver_run_command bundle exec rake zammad:setup:auto_wizard
3346
print_heading "Autowizard executed successfully :)"
3447

3548
print_heading "Check DB for AutoWizard user"
36-
docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "p User.find_by(email: '[email protected]')" | grep '[email protected]'
49+
railsserver_run_command bundle exec rails r "p User.find_by(email: '[email protected]')" | grep '[email protected]'
3750
print_heading "Check DB for AutoWizard user successful :)"
3851

3952
print_heading "Fill DB with some random data"
40-
docker compose exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver bundle exec rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)"
53+
railsserver_run_command bundle exec rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)"
4154
print_heading "DB fill successful :)"
4255

4356
print_heading "Check if the Zammad user can write to FS storage"
44-
docker compose exec zammad-railsserver touch storage/test.txt
57+
railsserver_run_command touch storage/test.txt
4558
print_heading "Storage write successful :)"
4659

4760
print_heading "Check if the Zammad user can write /tmp"
48-
docker compose exec zammad-railsserver touch tmp/test.txt
61+
railsserver_run_command touch tmp/test.txt
4962
print_heading "Tmp write successful :)"
5063

5164
print_heading "Check if zammad-backup created an application backup"

0 commit comments

Comments
 (0)