Exemplo n.º 1
0
    def test_host_dict_using_updated_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        now = datetime.datetime.now()
        updated_at = now - datetime.timedelta(seconds=10)
        compute_service = {'updated_at': updated_at}
        volume_service = {'updated_at': updated_at}

        expected_host_dict = {'hostname': 'server',
                              'instance_count': 2,
                              'volume_count': 3,
                              'compute': 'up',
                              'volume': 'up'}

        self.assertEqual(expected_host_dict,
                         admin.host_dict('server', compute_service, instances,
                                         volume_service, volumes, now))
Exemplo n.º 2
0
    def test_host_dict_service_down_using_created_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        # service_down_time is 60 by defualt so we set to 70 to simulate
        # services been down
        now = datetime.datetime.now()
        created_at = now - datetime.timedelta(seconds=70)
        compute_service = {'created_at': created_at, 'updated_at': None}
        volume_service = {'created_at': created_at, 'updated_at': None}

        expected_host_dict = {'hostname': 'server',
                              'instance_count': 2,
                              'volume_count': 3,
                              'compute': 'down',
                              'volume': 'down'}

        self.assertEqual(expected_host_dict,
                         admin.host_dict('server', compute_service, instances,
                                         volume_service, volumes, now))
Exemplo n.º 3
0
    def test_host_dict_using_updated_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        now = datetime.datetime.now()
        updated_at = now - datetime.timedelta(seconds=10)
        compute_service = {"updated_at": updated_at}
        volume_service = {"updated_at": updated_at}

        expected_host_dict = {
            "hostname": "server",
            "instance_count": 2,
            "volume_count": 3,
            "compute": "up",
            "volume": "up",
        }

        self.assertEqual(
            expected_host_dict, admin.host_dict("server", compute_service, instances, volume_service, volumes, now)
        )
Exemplo n.º 4
0
    def test_host_dict_using_updated_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        now = datetime.datetime.now()
        updated_at = now - datetime.timedelta(seconds=10)
        compute_service = {'updated_at': updated_at}
        volume_service = {'updated_at': updated_at}

        expected_host_dict = {
            'hostname': 'server',
            'instance_count': 2,
            'volume_count': 3,
            'compute': 'up',
            'volume': 'up'
        }

        self.assertEqual(
            expected_host_dict,
            admin.host_dict('server', compute_service, instances,
                            volume_service, volumes, now))
Exemplo n.º 5
0
    def test_host_dict_service_down_using_created_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        # service_down_time is 60 by defualt so we set to 70 to simulate
        # services been down
        now = datetime.datetime.now()
        created_at = now - datetime.timedelta(seconds=70)
        compute_service = {"created_at": created_at, "updated_at": None}
        volume_service = {"created_at": created_at, "updated_at": None}

        expected_host_dict = {
            "hostname": "server",
            "instance_count": 2,
            "volume_count": 3,
            "compute": "down",
            "volume": "down",
        }

        self.assertEqual(
            expected_host_dict, admin.host_dict("server", compute_service, instances, volume_service, volumes, now)
        )
Exemplo n.º 6
0
    def test_host_dict_service_down_using_created_at(self):
        # instances and volumes only used for count
        instances = range(2)
        volumes = range(3)

        # service_down_time is 60 by defualt so we set to 70 to simulate
        # services been down
        now = datetime.datetime.now()
        created_at = now - datetime.timedelta(seconds=70)
        compute_service = {'created_at': created_at, 'updated_at': None}
        volume_service = {'created_at': created_at, 'updated_at': None}

        expected_host_dict = {
            'hostname': 'server',
            'instance_count': 2,
            'volume_count': 3,
            'compute': 'down',
            'volume': 'down'
        }

        self.assertEqual(
            expected_host_dict,
            admin.host_dict('server', compute_service, instances,
                            volume_service, volumes, now))