Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos
Commits
4c332c49
Commit
4c332c49
authored
Nov 10, 2022
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
theia: add peertube backup test
parent
a9479f62
Pipeline
#24671
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
0 deletions
+109
-0
software/theia/test/project_tests.py
software/theia/test/project_tests.py
+109
-0
No files found.
software/theia/test/project_tests.py
View file @
4c332c49
...
...
@@ -48,6 +48,9 @@ from test import SlapOSInstanceTestCase, theia_software_release_url
erp5_software_release_url
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'erp5'
,
'software.cfg'
))
peertube_software_release_url
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'peertube'
,
'software.cfg'
))
def
setUpModule
():
...
...
@@ -232,3 +235,109 @@ class TestTheiaResilienceERP5(ERP5Mixin, test_resiliency.TestTheiaResilience):
# Check that the mariadb catalog was properly restored
out
=
subprocess
.
check_output
((
mysql_bin
,
'erp5'
,
'-e'
,
query
),
universal_newlines
=
True
)
self
.
assertIn
(
self
.
_erp5_new_title
,
out
,
'Mariadb catalog is not properly restored'
)
class
TestTheiaResiliencePeertube
(
test_resiliency
.
TestTheiaResilience
):
test_instance_max_retries
=
12
backup_max_tries
=
480
backup_wait_interval
=
60
_test_software_url
=
peertube_software_release_url
def
test_twice
(
self
):
# do nothing
pass
def
_prepareExport
(
self
):
super
(
TestTheiaResiliencePeertube
,
self
).
_prepareExport
()
postgresql_partition
=
self
.
_getERP5PartitionPath
(
'export'
,
'postgresql'
)
postgresql_bin
=
os
.
path
.
join
(
mariadb_partition
,
'bin'
,
'psql'
)
postgres_bin
=
os
.
path
.
join
(
mariadb_partition
,
'bin'
,
'postgres'
)
# Change the email address of the user 'peertube'
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'UPDATE "user" SET "email"=
\
'
aaa
\
'
WHERE "username"=
\
'
root
\
'
'
),
universal_newlines
=
True
)
self
.
assertIn
(
"UPDATE"
,
output
)
# Checked the modification has been updated in the database
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'SELECT * FROM "user"'
),
universal_newlines
=
True
)
self
.
assertIn
(
"aaa"
,
output
)
# Change the email address of the user 'peertube'
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'UPDATE "user" SET "email"=
\
'
bbb
\
'
WHERE "username"=
\
'
root
\
'
'
),
universal_newlines
=
True
)
self
.
assertIn
(
"UPDATE"
,
output
)
# Checked the modification has been updated in the database
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'SELECT * FROM "user"'
),
universal_newlines
=
True
)
self
.
assertIn
(
"bbb"
,
output
)
# Do a fake periodically update???
# Compute backup date in the near future
# date = (datetime.now() + timedelta(days=1)).replace(second=0)
# Process twice to propagate parameter changes
# for _ in range(2):
# self.checkSlapos('node', 'instance')
# Do a fake periodically update???
# ---------------------------
# self.callSlapos('node', 'restart', 'all')
# Wait until after the programmed backup date, and a bit more
# t = (soon - datetime.now()).total_seconds()
# self.assertLess(0, t)
# time.sleep(t + 120)
# -------------------------------------
# Check that postgresql backup has started
# which contains this file: ./peertube_prod-dump.db
postgresql_backup
=
os
.
path
.
join
(
postgresql_partition
,
'var'
,
'www'
,
'peertube'
)
self
.
assertIn
(
'peertube_prod-dump.sql'
,
os
.
listdir
(
postgresql_backup
))
# Check the backup contains the changes
with
open
(
os
.
path
.
join
(
psql_backup
,
'peertube_prod-dump.sql'
))
as
f
:
msg
=
"Postgres backup peertube_prod-dump.sql is not up to date"
self
.
assertIn
(
"bbb"
,
f
.
read
(),
msg
)
def
_checkTakeover
(
self
):
super
(
TestTheiaResiliencePeertube
,
self
).
_checkTakeover
()
postgresql_partition
=
self
.
_getERP5PartitionPath
(
'export'
,
'postgresql'
)
postgresql_bin
=
os
.
path
.
join
(
mariadb_partition
,
'bin'
,
'psql'
)
postgres_bin
=
os
.
path
.
join
(
mariadb_partition
,
'bin'
,
'postgres'
)
# Check that the mariadb catalog is not yet restored
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'SELECT * FROM "user"'
),
universal_newlines
=
True
)
self
.
assertNotIn
(
"bbb"
,
output
)
# Stop all services
print
(
"Stop all services"
)
self
.
callSlapos
(
'node'
,
'stop'
,
'all'
)
# Manually restore postgresql from backup
postgresql_restore_script
=
os
.
path
.
join
(
mariadb_partition
,
'bin'
,
'restore-from-backup'
)
print
(
"Restore mariadb from backup"
)
subprocess
.
check_call
(
postgresql_restore_script
)
# Check that the test instance is properly redeployed after restoring postgresql
# This restarts the services and checks the promises of the test instance
# Process twice to propagate state change
for
_
in
range
(
2
):
self
.
_processEmbeddedInstance
(
self
.
test_instance_max_retries
)
# Check that the postgresql catalog was properly restored
output
=
subprocess
.
check_output
(
(
postgresql_bin
,
'-c'
,
'SELECT * FROM "user"'
),
universal_newlines
=
True
)
self
.
assertIn
(
"bbb"
,
output
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment