Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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.toolbox
Commits
7f4072b6
Commit
7f4072b6
authored
May 04, 2020
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
equeue: do not create lists for options expecting a single value
to simplify the code
parent
a57c27c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
slapos/equeue/__init__.py
slapos/equeue/__init__.py
+8
-8
slapos/test/test_equeue.py
slapos/test/test_equeue.py
+7
-7
No files found.
slapos/equeue/__init__.py
View file @
7f4072b6
...
...
@@ -93,10 +93,10 @@ class EqueueServer(socketserver.ThreadingUnixStreamServer):
RequestHandlerClass
=
None
,
*
args
,
**
kw
)
# Equeue Specific elements
self
.
setLogger
(
self
.
options
.
logfile
[
0
],
self
.
options
.
loglevel
[
0
]
)
self
.
setDB
(
self
.
options
.
database
[
0
]
)
self
.
setLogger
(
self
.
options
.
logfile
,
self
.
options
.
loglevel
)
self
.
setDB
(
self
.
options
.
database
)
if
getattr
(
self
.
options
,
'takeover_triggered_file_path'
,
None
):
self
.
takeover_triggered_file_path
=
self
.
options
.
takeover_triggered_file_path
[
0
]
self
.
takeover_triggered_file_path
=
self
.
options
.
takeover_triggered_file_path
# Lock to only have one command running at the time
self
.
thread_lock
=
threading
.
Lock
()
# Lockfile is used by other commands to know if an import is ongoing.
...
...
@@ -197,20 +197,20 @@ def remove_existing_file(path):
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"Run a single threaded execution queue."
)
parser
.
add_argument
(
'--database'
,
nargs
=
1
,
required
=
True
,
parser
.
add_argument
(
'--database'
,
required
=
True
,
help
=
"Path to the database where the last "
"calls are stored"
)
parser
.
add_argument
(
'--loglevel'
,
nargs
=
1
,
parser
.
add_argument
(
'--loglevel'
,
default
=
'INFO'
,
choices
=
logging_choices
,
required
=
False
)
parser
.
add_argument
(
'-l'
,
'--logfile'
,
nargs
=
1
,
required
=
True
,
parser
.
add_argument
(
'-l'
,
'--logfile'
,
required
=
True
,
help
=
"Path to the log file."
)
parser
.
add_argument
(
'-t'
,
'--timeout'
,
nargs
=
1
,
required
=
False
,
parser
.
add_argument
(
'-t'
,
'--timeout'
,
required
=
False
,
dest
=
'timeout'
,
type
=
int
,
default
=
3
)
parser
.
add_argument
(
'--lockfile'
,
help
=
"Path to the lock file created when a command is run"
)
parser
.
add_argument
(
'--takeover-triggered-file-path'
,
nargs
=
1
,
required
=
False
,
parser
.
add_argument
(
'--takeover-triggered-file-path'
,
required
=
False
,
help
=
"Path to the file created by takeover script to state that it has been triggered."
)
parser
.
add_argument
(
'socket'
,
help
=
"Path to the unix socket"
)
...
...
slapos/test/test_equeue.py
View file @
7f4072b6
...
...
@@ -10,10 +10,10 @@ from slapos.equeue import EqueueServer
class
Options
:
def
__init__
(
self
,
logfile
,
loglevel
,
database
,
takeover_triggered_file_path
,
lockfile
,
timeout
):
self
.
logfile
=
[
logfile
]
self
.
loglevel
=
[
loglevel
]
self
.
database
=
[
database
]
self
.
takeover_triggered_file_path
=
[
takeover_triggered_file_path
]
self
.
logfile
=
logfile
self
.
loglevel
=
loglevel
self
.
database
=
database
self
.
takeover_triggered_file_path
=
takeover_triggered_file_path
self
.
lockfile
=
lockfile
self
.
timeout
=
timeout
...
...
@@ -59,7 +59,7 @@ class TestEqueue(unittest.TestCase):
server_process
=
multiprocessing
.
Process
(
target
=
self
.
equeue_server
.
serve_forever
)
server_process
.
start
()
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
[
0
]
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
socket
))
# Prepare 2 requests, the first one including a delay.
...
...
@@ -95,7 +95,7 @@ class TestEqueue(unittest.TestCase):
server_process
=
multiprocessing
.
Process
(
target
=
self
.
equeue_server
.
serve_forever
)
server_process
.
start
()
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
[
0
]
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
socket
))
# Run 2 times the same command (bash), but with different
...
...
@@ -130,7 +130,7 @@ class TestEqueue(unittest.TestCase):
server_process
=
multiprocessing
.
Process
(
target
=
self
.
equeue_server
.
serve_forever
)
server_process
.
start
()
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
[
0
]
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
options
.
database
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
socket
))
# Create takeover file
...
...
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