1
# This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
3
# MAUS is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# MAUS is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with MAUS. If not, see <http://www.gnu.org/licenses/>.
17
Check that celery is alive on the test server. Note that this should not be run
18
as part of the regular test script - only should be run by online machine (and
19
online-capable machines)
23
import celery.task.control
27
class OnlineOkayTest(unittest.TestCase): # pylint: disable=R0904, C0301
29
Check that celery nodes are available and RabbitMQ is alive or fail
31
def test_celery_is_alive(self):
33
_test_online_okay: Check that celery can be accessed
35
Fail an assertion if celery.task.control.inspect() fails (RabbitMQ is
36
down) or no active nodes
39
active_nodes = celery.task.control.inspect().active()
40
except: #pylint: disable=W0702
41
self.assertTrue(False, "Failed to inspect celery workers")
42
self.assertNotEqual(active_nodes, None)
44
def test_mongodb_is_alive(self):
46
_test_online_okay: Check that mongodb can be accessed
48
Fail an assertion if mongodb can't be contacted on localhost
51
test_connx = pymongo.Connection("localhost", 27017)
52
except pymongo.errors.AutoReconnect: # pylint: disable=W0702
53
self.assertTrue(False, "MongoDB server is not accessible")
54
test_connx.disconnect()
56
if __name__ == "__main__":