示例#1
0
    def test_periodic_patch_audit_in_sync(self, mock_context,
                                          mock_keystone_client,
                                          mock_patching_client, mock_db_api,
                                          mock_sysinv_client):
        mock_context.get_admin_context.return_value = self.ctxt
        mock_sm = mock.Mock()
        am = patch_audit_manager.PatchAuditManager(subcloud_manager=mock_sm)

        mock_patching_client.side_effect = FakePatchingClientInSync
        mock_sysinv_client.side_effect = FakeSysinvClientOneLoad
        fake_subcloud1 = Subcloud(1,
                                  'subcloud1',
                                  is_managed=True,
                                  is_online=True)
        fake_subcloud2 = Subcloud(2,
                                  'subcloud2',
                                  is_managed=True,
                                  is_online=True)
        mock_db_api.subcloud_get_all.return_value = [
            fake_subcloud1, fake_subcloud2
        ]

        am._periodic_patch_audit_loop()
        expected_calls = [
            mock.call(mock.ANY,
                      subcloud_name='subcloud1',
                      endpoint_type=dcorch_consts.ENDPOINT_TYPE_PATCHING,
                      sync_status=consts.SYNC_STATUS_IN_SYNC),
            mock.call(mock.ANY,
                      subcloud_name='subcloud2',
                      endpoint_type=dcorch_consts.ENDPOINT_TYPE_PATCHING,
                      sync_status=consts.SYNC_STATUS_IN_SYNC),
        ]
        mock_sm.update_subcloud_endpoint_status.assert_has_calls(
            expected_calls)
示例#2
0
    def test_init(self, mock_context, mock_keystone_client,
                  mock_patching_client):
        mock_context.get_admin_context.return_value = self.ctxt

        sm = subcloud_manager.SubcloudManager()
        am = patch_audit_manager.PatchAuditManager(subcloud_manager=sm)
        self.assertIsNotNone(am)
        self.assertEqual('patch_audit_manager', am.service_name)
        self.assertEqual('localhost', am.host)
        self.assertEqual(self.ctxt, am.context)
示例#3
0
    def test_periodic_patch_audit_ignore_unmanaged_or_offline(
            self, mock_context,
            mock_keystone_client,
            mock_patching_client,
            mock_db_api):
        mock_context.get_admin_context.return_value = self.ctxt
        mock_sm = mock.Mock()
        am = patch_audit_manager.PatchAuditManager(
            subcloud_manager=mock_sm)

        mock_patching_client.side_effect = FakePatchingClientOutOfSync
        fake_subcloud1 = Subcloud(1, 'subcloud1',
                                  is_managed=False, is_online=True)
        fake_subcloud2 = Subcloud(2, 'subcloud2',
                                  is_managed=True, is_online=False)
        mock_db_api.subcloud_get_all.return_value = [fake_subcloud1,
                                                     fake_subcloud2]

        am._periodic_patch_audit_loop()
        mock_sm.update_subcloud_endpoint_status.assert_not_called()