def test_failure(self): """Fail to generate a broker service management object. Assert that :class:`pulp_smash.exceptions.NoKnownBrokerError` is raised if the function cannot find a broker. """ with mock.patch.object(cli, 'Client') as client: client.return_value.run.return_value.returncode = 1 with self.assertRaises(exceptions.NoKnownBrokerError): utils.get_broker(mock.Mock())
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() self.broker = utils.get_broker(self.cfg) self.services = tuple(( cli.Service(self.cfg, service) for service in PULP_SERVICES ))
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() if check_issue_2277(self.cfg): self.skipTest('https://pulp.plan.io/issues/2277') self.broker = utils.get_broker(self.cfg) self.services = tuple( (cli.Service(self.cfg, service) for service in PULP_SERVICES))
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() if selectors.bug_is_untestable(2277, self.cfg.version): self.skipTest('https://pulp.plan.io/issues/2277') self.broker = utils.get_broker(self.cfg) self.services = tuple(( cli.Service(self.cfg, service) for service in PULP_SERVICES ))
def test_all(self): """Test whether ``httpd`` dispatches a task while the broker is down. This test targets the following issues: * `Pulp Smash #650 <https://github.com/PulpQE/pulp-smash/issues/650>`_ * `Pulp #2770 <https://pulp.plan.io/issues/2770>`_ This test does the following: 1. Create a repository. 2. Stop the AMQP broker. (Also, schedule it to be re-started later!) 3. Sync the repository, ignore any errors that are returned when doing so, and assert that no tasks are left in the ``waiting`` state. """ cfg = config.get_config() if selectors.bug_is_untestable(2770, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2770') # Create a repository. client = api.Client(cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_UNSIGNED_FEED_URL repo = client.post(REPOSITORY_PATH, body) self.addCleanup(client.delete, repo['_href']) # Stop the AMQP broker. broker = [utils.get_broker(cfg)] svc_mgr = cli.GlobalServiceManager(cfg) svc_mgr.stop(broker) self.addCleanup(svc_mgr.start, broker) # Sync the repo, and assert no tasks are left in the waiting state. try: utils.sync_repo(cfg, repo) except HTTPError: pass tasks = client.post( urljoin(TASKS_PATH, 'search/'), { 'criteria': { 'fields': [ 'finish_time', 'start_time', 'state', 'tags', 'task_id', ], 'filters': { 'state': { '$in': ['waiting'] } }, } }) self.assertEqual(len(tasks), 0, tasks)
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() if check_issue_2277(self.cfg): self.skipTest('https://pulp.plan.io/issues/2277') if check_issue_2387(self.cfg): self.skipTest('https://pulp.plan.io/issues/2387') self.broker = utils.get_broker(self.cfg) self.services = tuple(( cli.Service(self.cfg, service) for service in PULP_SERVICES ))
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() if check_issue_3104(self.cfg): self.skipTest('https://pulp.plan.io/issues/3104') if check_issue_2277(self.cfg): self.skipTest('https://pulp.plan.io/issues/2277') if check_issue_2387(self.cfg): self.skipTest('https://pulp.plan.io/issues/2387') self.broker = (utils.get_broker(self.cfg), ) self.svc_mgr = cli.GlobalServiceManager(self.cfg)
def test_success(self): """Successfully generate a broker service management object. Assert that: * ``get_broker(…)`` returns a string. * The ``server_config`` argument is passed to the service object. * The "qpidd" broker is the preferred broker. """ with mock.patch.object(cli, 'Client') as client: client.return_value.run.return_value.returncode = 0 broker = utils.get_broker(server_config=mock.Mock()) self.assertEqual(broker, 'qpidd')
def test_success(self): """Successfully generate a broker service management object. Assert that: * ``get_broker(…)`` returns ``Service(…)``. * The ``server_config`` argument is passed to the service object. * The "qpidd" broker is the preferred broker. """ server_config = mock.Mock() with mock.patch.object(cli, 'Client') as client: client.return_value.run.return_value.returncode = 0 with mock.patch.object(cli, 'Service') as service: broker = utils.get_broker(server_config) self.assertEqual(service.return_value, broker) self.assertEqual(service.call_args[0], (server_config, 'qpidd'))
def setUp(self): """Provide a server config and Pulp services to stop and start.""" self.cfg = config.get_config() self.broker = utils.get_broker(self.cfg) self.services = tuple( (cli.Service(self.cfg, service) for service in PULP_SERVICES))