Esempio n. 1
0
    def test_daemon_to_dict(self):

        daemon = Daemon(manager_ip='127.0.0.1', name='name', queue='queue')
        daemon_json = utils.internal.daemon_to_dict(daemon)
        self.assertEqual(daemon_json['manager_ip'], '127.0.0.1')
        self.assertEqual(daemon_json['name'], 'name')
        self.assertEqual(daemon_json['queue'], 'queue')
Esempio n. 2
0
 def setUpClass(cls):
     cls.daemon = Daemon(
         manager_ip='manager_ip',
         name='name',
         queue='queue',
         broker_user='******',
         broker_pass='******',
     )
Esempio n. 3
0
 def setUp(self):
     super(TestDaemonDefaults, self).setUp()
     self.daemon = Daemon(rest_host='127.0.0.1',
                          broker_ip='127.0.0.1',
                          queue='queue',
                          name='name',
                          broker_user='******',
                          broker_pass='******',
                          local_rest_cert_file=self._rest_cert_path)
Esempio n. 4
0
 def setUp(self):
     super(TestDaemonDefaults, self).setUp()
     self.daemon = Daemon(
         manager_ip='manager_ip',
         queue='queue',
         name='name',
         broker_user='******',
         broker_pass='******',
     )
Esempio n. 5
0
def test_daemon_to_dict(agent_ssl_cert):
    daemon = Daemon(rest_host=['127.0.0.1'],
                    name='name',
                    queue='queue',
                    broker_ip=['127.0.0.1'],
                    local_rest_cert_file=agent_ssl_cert.local_cert_path())
    daemon_json = utils.internal.daemon_to_dict(daemon)
    assert daemon_json['rest_host'] == ['127.0.0.1']
    assert daemon_json['broker_ip'] == ['127.0.0.1']
    assert daemon_json['name'] == 'name'
    assert daemon_json['queue'] == 'queue'
Esempio n. 6
0
 def test_daemon_to_dict(self):
     daemon = Daemon(rest_host='127.0.0.1',
                     name='name',
                     queue='queue',
                     broker_ip='127.0.0.1',
                     local_rest_cert_file=self._rest_cert_path)
     daemon_json = utils.internal.daemon_to_dict(daemon)
     self.assertEqual(daemon_json['rest_host'], '127.0.0.1')
     self.assertEqual(daemon_json['broker_ip'], '127.0.0.1')
     self.assertEqual(daemon_json['name'], 'name')
     self.assertEqual(daemon_json['queue'], 'queue')
Esempio n. 7
0
 def test_missing_rest_host(self):
     with self.assertRaisesRegex(
             exceptions.DaemonMissingMandatoryPropertyError,
             'rest_host is mandatory'):
         Daemon(name='name',
                queue='queue',
                host='queue',
                user='******',
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
Esempio n. 8
0
 def test_missing_rest_host(self):
     try:
         Daemon(name='name',
                queue='queue',
                host='queue',
                user='******',
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
         self.fail('Expected ValueError due to missing rest_host')
     except exceptions.DaemonMissingMandatoryPropertyError as e:
         self.assertTrue('rest_host is mandatory' in e.message)
Esempio n. 9
0
def get_daemon(ssl_cert, params=None):
    if not params:
        params = {
            'rest_host': '127.0.0.1',
            'broker_ip': '127.0.0.1',
        }
    params['queue'] = 'queue'
    params['name'] = 'queue'
    params['broker_user'] = '******'
    params['broker_pass'] = '******'
    params['local_rest_cert_file'] = ssl_cert.local_cert_path()
    return Daemon(**params)
Esempio n. 10
0
 def test_missing_manager_ip(self):
     try:
         Daemon(
             name='name',
             queue='queue',
             host='queue',
             user='******',
             broker_user='******',
             broker_pass='******',
         )
         self.fail('Expected ValueError due to missing manager_ip')
     except exceptions.DaemonMissingMandatoryPropertyError as e:
         self.assertTrue('manager_ip is mandatory' in e.message)
Esempio n. 11
0
 def test_bad_max_workers(self):
     with self.assertRaisesRegex(exceptions.DaemonPropertiesError,
                                 'max_workers is supposed to be a number'):
         Daemon(name='name',
                queue='queue',
                host='queue',
                rest_host='127.0.0.1',
                broker_ip='127.0.0.1',
                user='******',
                max_workers='bad',
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
Esempio n. 12
0
 def test_bad_max_workers(self):
     try:
         Daemon(name='name',
                queue='queue',
                host='queue',
                rest_host='127.0.0.1',
                broker_ip='127.0.0.1',
                user='******',
                max_workers='bad',
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
     except exceptions.DaemonPropertiesError as e:
         self.assertTrue(
             'max_workers is supposed to be a number' in e.message)
Esempio n. 13
0
 def test_bad_max_workers(self):
     try:
         Daemon(
             name='name',
             queue='queue',
             host='queue',
             manager_ip='manager_ip',
             user='******',
             max_workers='bad',
             broker_user='******',
             broker_pass='******',
         )
     except exceptions.DaemonPropertiesError as e:
         self.assertTrue(
             'max_workers is supposed to be a number' in e.message)
Esempio n. 14
0
 def test_min_workers_larger_than_max_workers(self):
     with self.assertRaisesRegex(
             exceptions.DaemonPropertiesError,
             'min_workers cannot be greater than max_workers'):
         Daemon(name='name',
                queue='queue',
                host='queue',
                rest_host='127.0.0.1',
                broker_ip='127.0.0.1',
                user='******',
                max_workers=4,
                min_workers=5,
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
Esempio n. 15
0
 def test_min_workers_larger_than_max_workers(self):
     try:
         Daemon(name='name',
                queue='queue',
                host='queue',
                rest_host='127.0.0.1',
                broker_ip='127.0.0.1',
                user='******',
                max_workers=4,
                min_workers=5,
                broker_user='******',
                broker_pass='******',
                local_rest_cert_file=self._rest_cert_path)
     except exceptions.DaemonPropertiesError as e:
         self.assertTrue(
             'min_workers cannot be greater than max_workers' in e.message)
Esempio n. 16
0
 def test_min_workers_larger_than_max_workers(self):
     try:
         Daemon(
             name='name',
             queue='queue',
             host='queue',
             manager_ip='manager_ip',
             user='******',
             max_workers=4,
             min_workers=5,
             broker_user='******',
             broker_pass='******',
         )
     except exceptions.DaemonPropertiesError as e:
         self.assertTrue(
             'min_workers cannot be greater than max_workers' in e.message)