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
Tatuya Kamada
slapos
Commits
9331117f
Commit
9331117f
authored
Nov 19, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cookbook: support python3 in erp5testnode recipe and add missing tests
parent
82a79c8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
2 deletions
+133
-2
slapos/recipe/erp5testnode/__init__.py
slapos/recipe/erp5testnode/__init__.py
+2
-2
slapos/test/recipe/test_erp5testnode.py
slapos/test/recipe/test_erp5testnode.py
+131
-0
No files found.
slapos/recipe/erp5testnode/__init__.py
View file @
9331117f
...
@@ -36,7 +36,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -36,7 +36,7 @@ class Recipe(GenericBaseRecipe):
self
.
path_list
=
[]
self
.
path_list
=
[]
options
=
self
.
options
.
copy
()
options
=
self
.
options
.
copy
()
del
options
[
'recipe'
]
del
options
[
'recipe'
]
CONFIG
=
{
k
.
replace
(
'-'
,
'_'
):
v
for
k
,
v
in
options
.
ite
rite
ms
()}
CONFIG
=
{
k
.
replace
(
'-'
,
'_'
):
v
for
k
,
v
in
options
.
items
()}
CONFIG
[
'PATH'
]
=
os
.
environ
[
'PATH'
]
CONFIG
[
'PATH'
]
=
os
.
environ
[
'PATH'
]
if
self
.
options
[
'instance-dict'
]:
if
self
.
options
[
'instance-dict'
]:
...
@@ -44,7 +44,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -44,7 +44,7 @@ class Recipe(GenericBaseRecipe):
config_instance_dict
.
add_section
(
'instance_dict'
)
config_instance_dict
.
add_section
(
'instance_dict'
)
instance_dict
=
json
.
loads
(
self
.
options
[
'instance-dict'
])
instance_dict
=
json
.
loads
(
self
.
options
[
'instance-dict'
])
for
k
,
v
in
instance_dict
.
ite
rite
ms
():
for
k
,
v
in
instance_dict
.
items
():
config_instance_dict
.
set
(
'instance_dict'
,
k
,
v
)
config_instance_dict
.
set
(
'instance_dict'
,
k
,
v
)
value
=
io
.
StringIO
()
value
=
io
.
StringIO
()
config_instance_dict
.
write
(
value
)
config_instance_dict
.
write
(
value
)
...
...
slapos/test/recipe/test_erp5testnode.py
0 → 100644
View file @
9331117f
import
functools
import
os
import
shutil
import
tempfile
import
unittest
from
six.moves
import
configparser
import
zc.buildout.testing
class
UserInfoTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmp_dir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
self
.
tmp_dir
)
self
.
get_temp_path
=
functools
.
partial
(
os
.
path
.
join
,
self
.
tmp_dir
)
self
.
buildout
=
buildout
=
zc
.
buildout
.
testing
.
Buildout
()
buildout
[
'slap-connection'
]
=
{
'computer-id'
:
'computer-id'
,
'server-url'
:
'https://slapos.example.com'
,
}
# dummy defaults
buildout
[
'erp5testnode'
]
=
{
'apache-binary'
:
'/bin/httpd'
,
'apache-htpasswd'
:
'/bin/htpasswd'
,
'apache-mime-file'
:
'/etc/mime.types'
,
'apache-modules-dir'
:
'/srv/modules'
,
'frontend-url'
:
'https://example.com/'
,
'git-binary'
:
'/bin/git'
,
'httpd-cert-file'
:
'etc/httpd-public.crt'
,
'httpd-key-file'
:
'etc/httpd-public.key'
,
'httpd-conf-file'
:
'etc/httpd.conf'
,
'httpd-ip'
:
'::1'
,
'httpd-lock-file'
:
'var/run/httpd.lock'
,
'httpd-log-directory'
:
'var/log'
,
'httpd-pid-file'
:
'var/run/httpd.pid'
,
'httpd-port'
:
'9080'
,
'httpd-software-access-port'
:
'9081'
,
'httpd-software-directory'
:
'srv/software'
,
'httpd-wrapper'
:
'bin/httpd'
,
'instance-dict'
:
''
,
'ipv4-address'
:
'127.0.0.1'
,
'ipv6-address'
:
'::1'
,
'keep-log-days'
:
'3'
,
'log-directory'
:
'var/log/testnode'
,
'log-file'
:
'var/log/erp5testnode.log'
,
'log-frontend-url'
:
'https://example.com'
,
'node-quantity'
:
'2'
,
'proxy-host'
:
'127.0.0.1'
,
'proxy-port'
:
'5000'
,
'recipe'
:
'slapos.cookbook:erp5testnode'
,
'run-directory'
:
'var/run/testnode'
,
'shared-part-list'
:
'srv/shared'
,
'slapos-binary'
:
'/bin/slapos'
,
'slapos-directory'
:
'srv/slapos'
,
'software-directory'
:
'srv/software'
,
'software-path-list'
:
'[""]'
,
'srv-directory'
:
'srv'
,
'test-node-title'
:
'TEST NODE TITLE'
,
'test-suite-directory'
:
'srv/test_suite'
,
'test-suite-master-url'
:
'https://testnode.example.com'
,
'testnode'
:
'/bin/testnode'
,
'working-directory'
:
'srv/testnode'
,
'wrapper'
:
'bin/erp5testnode-service'
,
'zip-binary'
:
'/bin/zip'
,
}
# values for test
buildout
[
'erp5testnode'
][
'configuration-file'
]
=
self
.
get_temp_path
(
'configuration-file'
)
buildout
[
'erp5testnode'
][
'wrapper'
]
=
self
.
get_temp_path
(
'wrapper'
)
buildout
[
'erp5testnode'
][
'httpd-conf-file'
]
=
self
.
get_temp_path
(
'httpd-conf-file'
)
buildout
[
'erp5testnode'
][
'httpd-wrapper'
]
=
self
.
get_temp_path
(
'httpd-wrapper'
)
buildout
[
'erp5testnode'
][
'log-directory'
]
=
self
.
get_temp_path
(
'log-directory'
)
os
.
mkdir
(
self
.
get_temp_path
(
'log-directory'
))
# software URLs are given as a json encoded string
buildout
[
'erp5testnode'
][
'software-path-list'
]
=
'["https://example.com/slapos/software.cfg", "https://example.com/slapos/another-software.cfg"]'
from
slapos.recipe
import
erp5testnode
self
.
recipe
=
erp5testnode
.
Recipe
(
buildout
,
'erp5testnode'
,
buildout
[
'erp5testnode'
],
)
def
test_installed_paths
(
self
):
self
.
assertEqual
(
sorted
(
self
.
recipe
.
install
()),
sorted
([
self
.
get_temp_path
(
'configuration-file'
),
self
.
get_temp_path
(
'wrapper'
),
self
.
get_temp_path
(
'httpd-conf-file'
),
self
.
get_temp_path
(
'httpd-wrapper'
),
]))
def
test_configuration_file
(
self
):
self
.
recipe
.
install
()
parser
=
configparser
.
ConfigParser
()
parser
.
read
(
self
.
get_temp_path
(
'configuration-file'
))
# this is generally a valid configparser file.
self
.
assertEqual
(
parser
.
get
(
'testnode'
,
'slapos_directory'
),
'srv/slapos'
)
# software URLs are specified comma separated (XXX not sure it was
# good idea, but it's like this)
self
.
assertEqual
(
parser
.
get
(
'software_list'
,
'path_list'
),
"https://example.com/slapos/software.cfg,https://example.com/slapos/another-software.cfg"
)
def
test_log_directory_apache
(
self
):
self
.
recipe
.
install
()
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
get_temp_path
(
'log-directory'
,
'index.html'
)))
# apache to expose log directory
with
open
(
self
.
get_temp_path
(
'httpd-conf-file'
))
as
f
:
self
.
assertIn
(
'DocumentRoot "{}"'
.
format
(
self
.
get_temp_path
(
'log-directory'
)),
f
.
read
())
# wrapper references the config file
with
open
(
self
.
get_temp_path
(
'httpd-wrapper'
))
as
f
:
self
.
assertIn
(
self
.
get_temp_path
(
'httpd-conf-file'
),
f
.
read
())
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