Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to specify number of workers in
verdi daemon start
Now you can start more than just one worker when starting the daemon.
- Loading branch information
Showing
4 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
"""Tests for `verdi daemon`.""" | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
|
||
from click.testing import CliRunner | ||
|
||
from aiida.backends.testbase import AiidaTestCase | ||
from aiida.cmdline.commands import cmd_daemon | ||
from aiida.engine.daemon.client import DaemonClient | ||
from aiida.manage.configuration import get_config | ||
|
||
|
||
class TestVerdiDaemon(AiidaTestCase): | ||
"""Tests for `verdi daemon` commands.""" | ||
|
||
def setUp(self): | ||
super(TestVerdiDaemon, self).setUp() | ||
self.daemon_client = DaemonClient(get_config().current_profile) | ||
self.cli_runner = CliRunner() | ||
|
||
def test_daemon_start(self): | ||
"""Test `verdi daemon start`.""" | ||
try: | ||
result = self.cli_runner.invoke(cmd_daemon.start, []) | ||
self.assertClickResultNoException(result) | ||
|
||
daemon_response = self.daemon_client.get_daemon_info() | ||
worker_response = self.daemon_client.get_worker_info() | ||
|
||
self.assertIn('status', daemon_response, daemon_response) | ||
self.assertEqual(daemon_response['status'], 'ok', daemon_response) | ||
|
||
self.assertIn('info', worker_response, worker_response) | ||
self.assertEqual(len(worker_response['info']), 1, worker_response) | ||
finally: | ||
self.daemon_client.stop_daemon(wait=True) | ||
|
||
def test_daemon_start_number(self): | ||
"""Test `verdi daemon start` with a specific number of workers.""" | ||
try: | ||
number = 4 | ||
result = self.cli_runner.invoke(cmd_daemon.start, [str(number)]) | ||
self.assertClickResultNoException(result) | ||
|
||
daemon_response = self.daemon_client.get_daemon_info() | ||
worker_response = self.daemon_client.get_worker_info() | ||
|
||
self.assertIn('status', daemon_response, daemon_response) | ||
self.assertEqual(daemon_response['status'], 'ok', daemon_response) | ||
|
||
self.assertIn('info', worker_response, worker_response) | ||
self.assertEqual(len(worker_response['info']), number, worker_response) | ||
finally: | ||
self.daemon_client.stop_daemon(wait=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters