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
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
Dmitry Blinov
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
...
@@ -4,7 +4,7 @@ import shutil
import
sys
import
sys
import
tempfile
import
tempfile
import
unittest
import
unittest
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
NotFoundError
,
ConnectionError
from
slapos.recipe
import
re6stnet
from
slapos.recipe
import
re6stnet
...
@@ -21,7 +21,7 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -21,7 +21,7 @@ class Re6stnetTest(unittest.TestCase):
with
open
(
config_file
,
'w'
)
as
f
:
with
open
(
config_file
,
'w'
)
as
f
:
f
.
write
(
'port 9201'
)
f
.
write
(
'port 9201'
)
self
.
options
=
options
=
{
self
.
options
=
options
=
{
'openssl-bin'
:
'openssl'
,
'openssl-bin'
:
'
/usr/bin/
openssl'
,
'key-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.key'
),
'key-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.key'
),
'cert-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.crt'
),
'cert-file'
:
os
.
path
.
join
(
self
.
ssl_dir
,
'cert.crt'
),
'key-size'
:
'2048'
,
'key-size'
:
'2048'
,
...
@@ -58,10 +58,12 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -58,10 +58,12 @@ class Re6stnetTest(unittest.TestCase):
'executable'
:
sys
.
executable
,
'executable'
:
sys
.
executable
,
},
},
'slap-connection'
:
{
'slap-connection'
:
{
'computer-id'
:
''
,
'computer-id'
:
'comp-test'
,
'partition-id'
:
''
,
'partition-id'
:
'slappart0'
,
'server-url'
:
''
,
'server-url'
:
'http://server.com'
,
'software-release-url'
:
''
,
'software-release-url'
:
'http://software.com'
,
'key-file'
:
'/path/to/key'
,
'cert-file'
:
'/path/to/cert'
}
}
}
}
...
@@ -69,6 +71,32 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -69,6 +71,32 @@ class Re6stnetTest(unittest.TestCase):
return
re6stnet
.
Recipe
(
buildout
=
buildout
,
name
=
're6stnet'
,
options
=
options
)
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
):
def
test_generateCertificates
(
self
):
self
.
options
[
'ipv6-prefix'
]
=
'2001:db8:24::/48'
self
.
options
[
'ipv6-prefix'
]
=
'2001:db8:24::/48'
...
@@ -115,7 +143,7 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -115,7 +143,7 @@ class Re6stnetTest(unittest.TestCase):
try
:
try
:
recipe
.
install
()
recipe
.
install
()
except
NotFoundError
:
except
(
NotFoundError
,
ConnectionError
)
:
# Recipe will raise not found error when trying to publish slave informations
# Recipe will raise not found error when trying to publish slave informations
pass
pass
...
@@ -144,13 +172,18 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -144,13 +172,18 @@ class Re6stnetTest(unittest.TestCase):
second_add
=
recipe
.
readFile
(
os
.
path
.
join
(
self
.
token_dir
,
'SOFTINST-58778.add'
))
second_add
=
recipe
.
readFile
(
os
.
path
.
join
(
self
.
token_dir
,
'SOFTINST-58778.add'
))
self
.
assertEqual
(
token_dict
[
'SOFTINST-58778'
],
second_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
# Remove one element
recipe
.
options
.
update
({
recipe
.
options
.
update
({
"slave-instance-list"
:
"""[{"slave_reference":"SOFTINST-58770"}]"""
"slave-instance-list"
:
"""[{"slave_reference":"SOFTINST-58770"}]"""
})
})
try
:
try
:
recipe
.
install
()
recipe
.
install
()
except
NotFoundError
:
except
(
NotFoundError
,
ConnectionError
)
:
# Recipe will raise not found error when trying to publish slave informations
# Recipe will raise not found error when trying to publish slave informations
pass
pass
token_dict
=
recipe
.
loadJsonFile
(
token_file
)
token_dict
=
recipe
.
loadJsonFile
(
token_file
)
...
@@ -182,3 +215,8 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -182,3 +215,8 @@ class Re6stnetTest(unittest.TestCase):
self
.
assertEqual
(
token_content
,
'{}'
)
self
.
assertEqual
(
token_content
,
'{}'
)
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
options
[
'token-dir'
]),
[])
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