Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
Odevzdávací Systém MO
Commits
6070aaba
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
6070aaba
authored
Sep 6, 2022
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Testy: Zakládání testovacího prostředí
parent
058dc2dd
Branches
Branches containing commit
No related tags found
1 merge request
!121
Testovací prostředí
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/test-init
+153
-21
153 additions, 21 deletions
bin/test-init
with
153 additions
and
21 deletions
bin/test-init
+
153
−
21
View file @
6070aaba
#!/bin/bash
set
-e
if
[
$#
!=
1
]
;
then
echo
>
&2
"Použití:
$0
<jméno-db>"
if
[
$#
!=
2
-o
"
$1
"
=
"--help"
]
;
then
cat
<<
AMEN
Použití:
$0
<jméno-databáze> <datový-adresář>
POZOR: Databáze i datový adresář jsou kompletně přepsané!!!
Obojí musí odpovídat nastavení v mo.config.
AMEN
exit
1
fi
DB
=
$1
DB
=
"
$1
"
DATA
=
"
$2
"
T_GREEN
=
"
$(
tput setaf 2
)
"
T_NORMAL
=
"
$(
tput sgr0
)
"
PATH
=
"./bin:
$PATH
"
progress
()
{
echo
"
${
T_GREEN
}
>>>
$1
${
T_NORMAL
}
"
}
run
()
{
echo
"+
$@
"
"
$@
"
}
init_data
()
{
progress
"Inicializuji databázi"
psql
"
$DB
"
<db/drop-all.sql
psql
"
$DB
"
<db/db.ddl
progress
"Inicializuji datový adresář"
rm
-rf
"
$DATA
"
run init-data-dir
"
$DATA
"
progress
"Zakládám regiony"
run init-regions
progress
"Zakládám školy"
run init-schools
progress
"Zkracuji školy"
run shorten-schools
}
init_codes
()
{
progress
"Přiděluji školám kódy"
run test-school-code
--red-izo
600039811
--code
zs-sutka
# ZŠ Na Šutce, P8
run test-school-code
--red-izo
691008736
--code
zs-brno
# Scio ZŠ Brno
run test-school-code
--red-izo
600005933
--code
gulz
# G U Libeň. zámku, P8
run test-school-code
--red-izo
600013481
--code
gkj
# G tř. Kpt. Jaroše, Brno
}
init_users
()
{
progress
"Zakládám uživatele"
run create-user admin@test Hlavní Administrátor
--admin
--passwd
brum
run create-user cg@test Celostátní Garant
--org
--passwd
brum
run add-role
--email
cg@test
--role
garant
--cat
A
run add-role
--email
cg@test
--role
garant
--cat
Z
run create-user kg@test Krajský Garant
--org
--passwd
brum
run add-role
--email
kg@test
--role
garant_kraj
--cat
A
--place
A
run create-user og@test Okresní Garant
--org
--passwd
brum
run add-role
--email
og@test
--role
garant_okres
--cat
Z
--place
P8
run create-user sg-sutka@test Garant
'ZŠ Šutka'
--org
--passwd
brum
run add-role
--email
sg-sutka@test
--role
garant_skola
--place
zs-sutka
run create-user sg-brno@test Garant
'ZŠ Brno'
--org
--passwd
brum
run add-role
--email
sg-brno@test
--role
garant_skola
--place
zs-brno
run create-user sg-gulz@test Garant
'G Libeň'
--org
--passwd
brum
run add-role
--email
sg-gulz@test
--role
garant_skola
--place
gulz
run create-user sg-gkj@test Garant
'G Jaroše'
--org
--passwd
brum
run add-role
--email
sg-gkj@test
--role
garant_skola
--place
gkj
run create-user ko@test Krajský Opravovatel
--org
--passwd
brum
run add-role
--email
ko@test
--role
opravovatel
--place
A
run create-user so@test Školní Opravovatel
--org
--passwd
brum
run add-role
--email
so@test
--role
opravovatel
--cat
Z
--place
zs-sutka
run create-user sd@test Školní Dozor
--org
--passwd
brum
run add-role
--email
sd@test
--role
dozor
--cat
Z
--place
zs-sutka
run create-user u1@test První Účastník
--passwd
brum
run create-user u2@test Druhý Účastník
--passwd
brum
run create-user u3@test Třetí Účastník
--passwd
brum
run create-user u4@test Čtvrtý Účastník
--passwd
brum
run create-user u5@test Pátý Účastník
--passwd
brum
}
init_contests
()
{
progress
"Zakládám soutěže"
run init-year 42
# init-year zakládá krajská a vyšší kola, zde doplňujeme nižší
run create-contests 42-A-1
--region
gulz
run create-contests 42-A-1
--region
gkj
run create-contests 42-A-2
--region
gulz
run create-contests 42-A-2
--region
gkj
run create-contests 42-Z7-1
--region
zs-sutka
run create-contests 42-Z7-1
--region
zs-brno
run create-contests 42-Z7-2
--region
P8
}
init_contestants
()
{
progress
"Přihlašuji soutěžící"
run register-year
--email
u1@test
--year
42
--school
gulz
--grade
3/4
--birth-year
=
2002
run register-contest
--email
u1@test
--round
42-A-1
--region
gulz
run register-contest
--email
u1@test
--round
42-A-2
--region
gulz
run register-contest
--email
u1@test
--round
42-A-3
--region
A
run register-contest
--email
u1@test
--round
42-A-4a
--region
CZ
psql
$DB
<db/drop-all.sql
psql
$DB
<db/db.ddl
run register-year
--email
u2@test
--year
42
--school
gkj
--grade
4/4
--birth-year
=
2001
run register-contest
--email
u2@test
--round
42-A-1
--region
gkj
run register-contest
--email
u2@test
--round
42-A-2
--region
gkj
# V krajském kole soutěží v jiném kraji, než kam patří
run register-contest
--email
u2@test
--round
42-A-3
--region
B
--site
A
run register-contest
--email
u2@test
--round
42-A-4a
--region
CZ
bin/init-regions
bin/init-schools
bin/shorten-schools
run register-year
--email
u3@test
--year
42
--school
zs-sutka
--grade
7
--birth-year
=
2010
run register-contest
--email
u3@test
--round
42-Z7-1
--region
zs-sutka
# V okresním kole soutěží na své škole
run register-contest
--email
u3@test
--round
42-Z7-2
--region
P8
--site
zs-sutka
bin/create-user mj@ucw.cz Martin Mareš
--admin
--passwd
brum
run register-year
--email
u4@test
--year
42
--school
zs-sutka
--grade
7
--birth-year
=
2011
run register-contest
--email
u4@test
--round
42-Z7-1
--region
zs-sutka
run register-contest
--email
u4@test
--round
42-Z7-2
--region
P8
bin/create-user medved@ucw.cz Baltasis Lokys
--org
--passwd
brum
bin/add-role
--email
medved@ucw.cz
--role
garant
--cat
P
bin/add-role
--email
medved@ucw.cz
--role
garant_kraj
--cat
A
--place
S
# Na zs-brno registrujeme jen do prvního kola, ať se dá testovat zakládání
# soutěží a postupy.
run register-year
--email
u5@test
--year
42
--school
zs-brno
--grade
7
--birth-year
=
2011
run register-contest
--email
u5@test
--round
42-Z7-1
--region
zs-brno
}
bin/create-round
-y
70
-c
P
-s
1
-n
'Školní kolo'
-l
1
bin/create-round
-y
70
-c
P
-s
2
-n
'Krajské kolo'
-l
1
bin/create-round
-y
70
-c
P
-s
3
-n
'Ústřední kolo'
-l
0
init_states
()
{
progress
"Generuji PDF zadání"
echo
'# Zadání úlohy'
>
"
$DATA
/tmp/zadani.md"
pandoc
"
$DATA
/tmp/zadani.md"
-o
"
$DATA
/tmp/zadani.pdf"
bin/create-round
-y
70
-c
A
-s
1
-n
'Školní kolo (domácí)'
-l
1
bin/create-round
-y
70
-c
A
-s
2
-n
'Školní kolo (klauzurní)'
-l
1
bin/create-round
-y
70
-c
A
-s
3
-n
'Krajské kolo'
-l
1
bin/create-round
-y
70
-c
A
-s
4
-n
'Ústřední kolo'
-l
0
progress
"Nastavuji stav soutěží"
run test-state preparing
--statement
"
$DATA
/tmp/zadani.pdf"
}
bin/create-contests 70-P-2
bin/create-contests 70-A-3
init_data
init_codes
init_users
init_contests
init_contestants
init_states
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment