Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.core
Commits
e1e5d4bb
Commit
e1e5d4bb
authored
Dec 20, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: introduce a new software.slap_state column
parent
7467ef4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
slapos/proxy/schema.sql
slapos/proxy/schema.sql
+2
-1
slapos/tests/slapproxy/__init__.py
slapos/tests/slapproxy/__init__.py
+12
-12
No files found.
slapos/proxy/schema.sql
View file @
e1e5d4bb
--version:1
1
--version:1
2
CREATE
TABLE
IF
NOT
EXISTS
software
%
(
version
)
s
(
CREATE
TABLE
IF
NOT
EXISTS
software
%
(
version
)
s
(
url
VARCHAR
(
255
),
url
VARCHAR
(
255
),
computer_reference
VARCHAR
(
255
)
DEFAULT
'%(computer)s'
,
computer_reference
VARCHAR
(
255
)
DEFAULT
'%(computer)s'
,
requested_state
VARCHAR
(
255
)
DEFAULT
'available'
,
CONSTRAINT
uniq
PRIMARY
KEY
(
url
,
computer_reference
)
CONSTRAINT
uniq
PRIMARY
KEY
(
url
,
computer_reference
)
);
);
...
...
slapos/tests/slapproxy/__init__.py
View file @
e1e5d4bb
...
@@ -1262,25 +1262,25 @@ database_uri = %(tempdir)s/lib/external_proxy.db
...
@@ -1262,25 +1262,25 @@ database_uri = %(tempdir)s/lib/external_proxy.db
# XXX: when testing new schema version,
# XXX: when testing new schema version,
# rename to "TestMigrateVersion10ToLatest" and test accordingly.
# rename to "TestMigrateVersion10ToLatest" and test accordingly.
# Of course, also test version 1
1 to latest (should be 12
).
# Of course, also test version 1
2 to latest (should be 13
).
class
TestMigrateVersion10To1
1
(
TestInformation
,
TestRequest
,
TestSlaveRequest
,
TestMultiNodeSupport
):
class
TestMigrateVersion10To1
2
(
TestInformation
,
TestRequest
,
TestSlaveRequest
,
TestMultiNodeSupport
):
"""
"""
Test that old database version are automatically migrated without failure
Test that old database version are automatically migrated without failure
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestMigrateVersion10To1
1
,
self
).
setUp
()
super
(
TestMigrateVersion10To1
2
,
self
).
setUp
()
schema
=
bytes2str
(
pkg_resources
.
resource_string
(
schema
=
bytes2str
(
pkg_resources
.
resource_string
(
'slapos.tests.slapproxy'
,
'slapos.tests.slapproxy'
,
'database_dump_version_10.sql'
'database_dump_version_10.sql'
))
%
dict
(
version
=
'1
1
'
)
))
%
dict
(
version
=
'1
2
'
)
self
.
db
=
sqlite_connect
(
self
.
proxy_db
)
self
.
db
=
sqlite_connect
(
self
.
proxy_db
)
self
.
db
.
cursor
().
executescript
(
schema
)
self
.
db
.
cursor
().
executescript
(
schema
)
self
.
db
.
commit
()
self
.
db
.
commit
()
def
test_automatic_migration
(
self
):
def
test_automatic_migration
(
self
):
table_list
=
(
'software1
1'
,
'computer11'
,
'partition11'
,
'slave11'
,
'partition_network11
'
)
table_list
=
(
'software1
2'
,
'computer12'
,
'partition12'
,
'slave12'
,
'partition_network12
'
)
for
table
in
table_list
:
for
table
in
table_list
:
self
.
assertRaises
(
sqlite3
.
OperationalError
,
self
.
db
.
execute
,
"SELECT name FROM computer1
1
"
)
self
.
assertRaises
(
sqlite3
.
OperationalError
,
self
.
db
.
execute
,
"SELECT name FROM computer1
2
"
)
# Run a dummy request to cause migration
# Run a dummy request to cause migration
self
.
app
.
get
(
'/getComputerInformation?computer_id=computer'
)
self
.
app
.
get
(
'/getComputerInformation?computer_id=computer'
)
...
@@ -1291,31 +1291,31 @@ class TestMigrateVersion10To11(TestInformation, TestRequest, TestSlaveRequest, T
...
@@ -1291,31 +1291,31 @@ class TestMigrateVersion10To11(TestInformation, TestRequest, TestSlaveRequest, T
)
)
# Lower level tests
# Lower level tests
computer_list
=
self
.
db
.
execute
(
"SELECT * FROM computer1
1
"
).
fetchall
()
computer_list
=
self
.
db
.
execute
(
"SELECT * FROM computer1
2
"
).
fetchall
()
self
.
assertEqual
(
self
.
assertEqual
(
computer_list
,
computer_list
,
[(
u'computer'
,
u'127.0.0.1'
,
u'255.255.255.255'
)]
[(
u'computer'
,
u'127.0.0.1'
,
u'255.255.255.255'
)]
)
)
software_list
=
self
.
db
.
execute
(
"SELECT * FROM software1
1
"
).
fetchall
()
software_list
=
self
.
db
.
execute
(
"SELECT * FROM software1
2
"
).
fetchall
()
self
.
assertEqual
(
self
.
assertEqual
(
software_list
,
software_list
,
[(
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'computer'
)]
[(
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'computer'
,
u'available'
)]
)
)
partition_list
=
self
.
db
.
execute
(
"select * from partition1
1
"
).
fetchall
()
partition_list
=
self
.
db
.
execute
(
"select * from partition1
2
"
).
fetchall
()
self
.
assertEqual
(
self
.
assertEqual
(
partition_list
,
partition_list
,
[(
u'slappart0'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="json">{
\
n
"site-id": "erp5"
\
n
}
\
n
}</parameter>
\
n
</instance>
\
n
'
,
None
,
None
,
u'production'
,
u'slapos'
,
None
,
u'started'
),
(
u'slappart1'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">mysql://127.0.0.1:45678/erp5</parameter>
\
n
</instance>
\
n
'
,
None
,
u'mariadb'
,
u'MariaDB DataBase'
,
u'slappart0'
,
u'started'
),
(
u'slappart2'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="cloudooo-json"></parameter>
\
n
</instance>
\
n
'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">cloudooo://127.0.0.1:23000/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'cloudooo'
,
u'Cloudooo'
,
u'slappart0'
,
u'started'
),
(
u'slappart3'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">memcached://127.0.0.1:11000/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'memcached'
,
u'Memcached'
,
u'slappart0'
,
u'started'
),
(
u'slappart4'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">memcached://127.0.0.1:13301/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'kumofs'
,
u'KumoFS'
,
u'slappart0'
,
u'started'
),
(
u'slappart5'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="kumofs-url">memcached://127.0.0.1:13301/</parameter>
\
n
<parameter id="memcached-url">memcached://127.0.0.1:11000/</parameter>
\
n
<parameter id="cloudooo-url">cloudooo://127.0.0.1:23000/</parameter>
\
n
</instance>
\
n
'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">https://[fc00::1]:10001</parameter>
\
n
</instance>
\
n
'
,
None
,
u'tidstorage'
,
u'TidStorage'
,
u'slappart0'
,
u'started'
),
(
u'slappart6'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart7'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart8'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart9'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
)]
[(
u'slappart0'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="json">{
\
n
"site-id": "erp5"
\
n
}
\
n
}</parameter>
\
n
</instance>
\
n
'
,
None
,
None
,
u'production'
,
u'slapos'
,
None
,
u'started'
),
(
u'slappart1'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">mysql://127.0.0.1:45678/erp5</parameter>
\
n
</instance>
\
n
'
,
None
,
u'mariadb'
,
u'MariaDB DataBase'
,
u'slappart0'
,
u'started'
),
(
u'slappart2'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="cloudooo-json"></parameter>
\
n
</instance>
\
n
'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">cloudooo://127.0.0.1:23000/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'cloudooo'
,
u'Cloudooo'
,
u'slappart0'
,
u'started'
),
(
u'slappart3'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">memcached://127.0.0.1:11000/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'memcached'
,
u'Memcached'
,
u'slappart0'
,
u'started'
),
(
u'slappart4'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u"<?xml version='1.0' encoding='utf-8'?>
\
n
<instance/>
\
n
"
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">memcached://127.0.0.1:13301/</parameter>
\
n
</instance>
\
n
'
,
None
,
u'kumofs'
,
u'KumoFS'
,
u'slappart0'
,
u'started'
),
(
u'slappart5'
,
u'computer'
,
u'busy'
,
u'/srv/slapgrid//srv//runner/project//slapos/software.cfg'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="kumofs-url">memcached://127.0.0.1:13301/</parameter>
\
n
<parameter id="memcached-url">memcached://127.0.0.1:11000/</parameter>
\
n
<parameter id="cloudooo-url">cloudooo://127.0.0.1:23000/</parameter>
\
n
</instance>
\
n
'
,
u'<?xml version=
\
'
1.0
\
'
encoding=
\
'
utf-8
\
'
?>
\
n
<instance>
\
n
<parameter id="url">https://[fc00::1]:10001</parameter>
\
n
</instance>
\
n
'
,
None
,
u'tidstorage'
,
u'TidStorage'
,
u'slappart0'
,
u'started'
),
(
u'slappart6'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart7'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart8'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
),
(
u'slappart9'
,
u'computer'
,
u'free'
,
None
,
None
,
None
,
None
,
None
,
None
,
None
,
u'started'
)]
)
)
slave_list
=
self
.
db
.
execute
(
"select * from slave1
1
"
).
fetchall
()
slave_list
=
self
.
db
.
execute
(
"select * from slave1
2
"
).
fetchall
()
self
.
assertEqual
(
self
.
assertEqual
(
slave_list
,
slave_list
,
[]
[]
)
)
partition_network_list
=
self
.
db
.
execute
(
"select * from partition_network1
1
"
).
fetchall
()
partition_network_list
=
self
.
db
.
execute
(
"select * from partition_network1
2
"
).
fetchall
()
self
.
assertEqual
(
self
.
assertEqual
(
partition_network_list
,
partition_network_list
,
[(
u'slappart0'
,
u'computer'
,
u'slappart0'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart0'
,
u'computer'
,
u'slappart0'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart1'
,
u'computer'
,
u'slappart1'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart1'
,
u'computer'
,
u'slappart1'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart2'
,
u'computer'
,
u'slappart2'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart2'
,
u'computer'
,
u'slappart2'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart3'
,
u'computer'
,
u'slappart3'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart3'
,
u'computer'
,
u'slappart3'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart4'
,
u'computer'
,
u'slappart4'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart4'
,
u'computer'
,
u'slappart4'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart5'
,
u'computer'
,
u'slappart5'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart5'
,
u'computer'
,
u'slappart5'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart6'
,
u'computer'
,
u'slappart6'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart6'
,
u'computer'
,
u'slappart6'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart7'
,
u'computer'
,
u'slappart7'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart7'
,
u'computer'
,
u'slappart7'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart8'
,
u'computer'
,
u'slappart8'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart8'
,
u'computer'
,
u'slappart8'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart9'
,
u'computer'
,
u'slappart9'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart9'
,
u'computer'
,
u'slappart9'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
)]
[(
u'slappart0'
,
u'computer'
,
u'slappart0'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart0'
,
u'computer'
,
u'slappart0'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart1'
,
u'computer'
,
u'slappart1'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart1'
,
u'computer'
,
u'slappart1'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart2'
,
u'computer'
,
u'slappart2'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart2'
,
u'computer'
,
u'slappart2'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart3'
,
u'computer'
,
u'slappart3'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart3'
,
u'computer'
,
u'slappart3'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart4'
,
u'computer'
,
u'slappart4'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart4'
,
u'computer'
,
u'slappart4'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart5'
,
u'computer'
,
u'slappart5'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart5'
,
u'computer'
,
u'slappart5'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart6'
,
u'computer'
,
u'slappart6'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart6'
,
u'computer'
,
u'slappart6'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart7'
,
u'computer'
,
u'slappart7'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart7'
,
u'computer'
,
u'slappart7'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart8'
,
u'computer'
,
u'slappart8'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart8'
,
u'computer'
,
u'slappart8'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
),
(
u'slappart9'
,
u'computer'
,
u'slappart9'
,
u'127.0.0.1'
,
u'255.255.255.255'
),
(
u'slappart9'
,
u'computer'
,
u'slappart9'
,
u'fc00::1'
,
u'ffff:ffff:ffff::'
)]
...
...
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