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
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
4c9e270d
Commit
4c9e270d
authored
Apr 03, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test re6stnet: check more generated scripts
parent
bc357712
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
8 deletions
+46
-8
slapos/test/recipe/test_re6stnet.py
slapos/test/recipe/test_re6stnet.py
+46
-8
No files found.
slapos/test/recipe/test_re6stnet.py
View file @
4c9e270d
...
...
@@ -4,7 +4,7 @@ import shutil
import
sys
import
tempfile
import
unittest
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
NotFoundError
,
ConnectionError
from
slapos.recipe
import
re6stnet
...
...
@@ -21,7 +21,7 @@ class Re6stnetTest(unittest.TestCase):
with
open
(
config_file
,
'w'
)
as
f
:
f
.
write
(
'port 9201'
)
self
.
options
=
options
=
{
'openssl-bin'
:
'openssl'
,
'openssl-bin'
:
'
/usr/bin/
openssl'
,
'key-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.key'
),
'cert-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.crt'
),
'key-size'
:
'2048'
,
...
...
@@ -58,10 +58,12 @@ class Re6stnetTest(unittest.TestCase):
'executable'
:
sys
.
executable
,
},
'slap-connection'
:
{
'computer-id'
:
''
,
'partition-id'
:
''
,
'server-url'
:
''
,
'software-release-url'
:
''
,
'computer-id'
:
'comp-test'
,
'partition-id'
:
'slappart0'
,
'server-url'
:
'http://server.com'
,
'software-release-url'
:
'http://software.com'
,
'key-file'
:
'/path/to/key'
,
'cert-file'
:
'/path/to/cert'
}
}
...
...
@@ -69,6 +71,32 @@ class Re6stnetTest(unittest.TestCase):
return
re6stnet
.
Recipe
(
buildout
=
buildout
,
name
=
're6stnet'
,
options
=
options
)
def
checkWrapper
(
self
,
path
):
self
.
assertTrue
(
os
.
path
.
exists
(
path
))
content
=
""
token_file
=
os
.
path
.
join
(
self
.
options
[
'conf-dir'
],
'token.json'
)
with
open
(
path
,
'r'
)
as
f
:
content
=
f
.
read
()
self
.
assertIn
(
"'token_json': '%s'"
%
token_file
,
content
)
self
.
assertIn
(
"'partition_id': 'slappart0'"
,
content
)
self
.
assertIn
(
"'computer_id': 'comp-test'"
,
content
)
self
.
assertIn
(
"'key_file': '/path/to/key'"
,
content
)
self
.
assertIn
(
"'cert_file': '/path/to/cert'"
,
content
)
self
.
assertIn
(
"'server_url': 'http://server.com'"
,
content
)
self
.
assertIn
(
"'db': '%s'"
%
self
.
options
[
'db-path'
],
content
)
self
.
assertIn
(
"'token_base_path': '%s'"
%
self
.
token_dir
,
content
)
self
.
assertIn
(
"'registry_url': 'http://%s:%s/'"
%
(
self
.
options
[
'ipv4'
],
self
.
options
[
'port'
]),
content
)
def
checkRegistryWrapper
(
self
):
path
=
os
.
path
.
join
(
self
.
base_dir
,
'wrapper'
)
self
.
assertTrue
(
os
.
path
.
exists
(
path
))
content
=
""
config_file
=
os
.
path
.
join
(
self
.
base_dir
,
'config'
)
with
open
(
path
,
'r'
)
as
f
:
content
=
f
.
read
()
self
.
assertIn
(
"@%s"
%
config_file
,
content
)
def
test_generateCertificates
(
self
):
self
.
options
[
'ipv6-prefix'
]
=
'2001:db8:24::/48'
...
...
@@ -115,7 +143,7 @@ class Re6stnetTest(unittest.TestCase):
try
:
recipe
.
install
()
except
NotFoundError
:
except
(
NotFoundError
,
ConnectionError
)
:
# Recipe will raise not found error when trying to publish slave informations
pass
...
...
@@ -144,13 +172,18 @@ class Re6stnetTest(unittest.TestCase):
second_add
=
recipe
.
readFile
(
os
.
path
.
join
(
self
.
token_dir
,
'SOFTINST-58778.add'
))
self
.
assertEqual
(
token_dict
[
'SOFTINST-58778'
],
second_add
)
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'manager_wrapper'
))
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'drop_wrapper'
))
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'check_wrapper'
))
self
.
checkRegistryWrapper
()
# Remove one element
recipe
.
options
.
update
({
"slave-instance-list"
:
"""[{"slave_reference":"SOFTINST-58770"}]"""
})
try
:
recipe
.
install
()
except
NotFoundError
:
except
(
NotFoundError
,
ConnectionError
)
:
# Recipe will raise not found error when trying to publish slave informations
pass
token_dict
=
recipe
.
loadJsonFile
(
token_file
)
...
...
@@ -182,3 +215,8 @@ class Re6stnetTest(unittest.TestCase):
self
.
assertEqual
(
token_content
,
'{}'
)
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
options
[
'token-dir'
]),
[])
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'manager_wrapper'
))
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'drop_wrapper'
))
self
.
checkWrapper
(
os
.
path
.
join
(
self
.
base_dir
,
'check_wrapper'
))
self
.
checkRegistryWrapper
()
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