예제 #1
0
 def test_create(self):
     sot = host.Host(**HOST)
     self.assertEqual(HOST["id"], sot.id)
     self.assertEqual(HOST["uuid"], sot.uuid)
     self.assertEqual(HOST["segment_id"], sot.segment_id)
     self.assertEqual(HOST["created_at"], sot.created_at)
     self.assertEqual(HOST["updated_at"], sot.updated_at)
     self.assertEqual(HOST["name"], sot.name)
     self.assertEqual(HOST["type"], sot.type)
     self.assertEqual(HOST["control_attributes"], sot.control_attributes)
     self.assertEqual(HOST["on_maintenance"], sot.on_maintenance)
     self.assertEqual(HOST["reserved"], sot.reserved)
     self.assertEqual(HOST["failover_segment_id"], sot.failover_segment_id)
예제 #2
0
    def test_basic(self):
        sot = host.Host(HOST)
        self.assertEqual("host", sot.resource_key)
        self.assertEqual("hosts", sot.resources_key)
        self.assertEqual("/segments/%(segment_id)s/hosts", sot.base_path)
        self.assertTrue(sot.allow_list)
        self.assertTrue(sot.allow_fetch)
        self.assertTrue(sot.allow_create)
        self.assertTrue(sot.allow_commit)
        self.assertTrue(sot.allow_delete)

        self.assertDictEqual(
            {
                "failover_segment_id": "failover_segment_id",
                "limit": "limit",
                "marker": "marker",
                "on_maintenance": "on_maintenance",
                "reserved": "reserved",
                "sort_dir": "sort_dir",
                "sort_key": "sort_key",
                "type": "type"
            }, sot._query_mapping._mapping)
def data(TEST):

    TEST.masakari_segment = test_data_utils.TestDataContainer()

    segment1 = segment.Segment(
        uuid=uuidsentinel.segment1,
        name='test',
        recovery_method='auto',
        service_type='service',
        description='demo',
        is_enabled=True,
    )
    segment2 = segment.Segment(
        uuid=uuidsentinel.segment2,
        name='test2',
        recovery_method='auto',
        service_type='service',
        description='demo',
        is_enabled=False,
    )
    segment3 = segment.Segment(
        uuid=uuidsentinel.segment3,
        name='test3',
        recovery_method='auto',
        service_type='service',
        description='demo',
        is_enabled=True,
    )

    TEST.masakari_segment.add(segment1)
    TEST.masakari_segment.add(segment2)
    TEST.masakari_segment.add(segment3)

    TEST.masakari_host = test_data_utils.TestDataContainer()

    host1 = host.Host(uuid=uuidsentinel.host1,
                      name="test",
                      reserved='True',
                      type='service',
                      control_attributes='test',
                      failover_segment_id=uuidsentinel.segment1,
                      on_maintenance='False')

    TEST.masakari_host.add(host1)

    TEST.hypervisors = test_data_utils.TestDataContainer()

    hypervisor1 = Hypervisor(HypervisorManager, {
        'id': '1',
        'hypervisor_hostname': "test"
    })

    TEST.hypervisors.add(hypervisor1)

    TEST.masakari_notification = test_data_utils.TestDataContainer()
    notification1 = notification.Notification(
        notification_uuid=uuidsentinel.notification1,
        status='new',
        generated_time=(NOW - datetime.timedelta(seconds=2)),
        payload='test',
        type='type1',
        source_host_uuid=uuidsentinel.host1)
    notification2 = notification.Notification(
        notification_uuid=uuidsentinel.notification2,
        status='running',
        generated_time=(NOW - datetime.timedelta(seconds=3)),
        payload='test',
        type='type2',
        source_host_uuid=uuidsentinel.host2)
    notification3 = notification.Notification(
        notification_uuid=uuidsentinel.notification3,
        status='error',
        generated_time=(NOW - datetime.timedelta(seconds=4)),
        payload='test',
        type='type3',
        source_host_uuid=uuidsentinel.host3)
    TEST.masakari_notification.add(notification1)
    TEST.masakari_notification.add(notification2)
    TEST.masakari_notification.add(notification3)