def test_find_by_instance_id(self):
        """
        Test to retrieve a guest agents by it's id
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(
            instance_id=instance_id, guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)
예제 #2
0
    def test_find_by_instance_id(self):
        """
        Test to retrieve a guest agents by its id
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(instance_id=instance_id,
                                          guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)
예제 #3
0
    def test_update_heartbeat(self):
        """
        Test to show the upgrade scenario that will be used by conductor
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(instance_id=instance_id,
                                          guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)

        # update
        AgentHeartBeat().update(id=heartbeat_found.id,
                                instance_id=instance_id,
                                guest_agent_version="1.2.3")

        # retrieve the record
        updated_heartbeat = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(updated_heartbeat)
        self.assertEqual(heartbeat.id, updated_heartbeat.id)
        self.assertEqual(heartbeat.instance_id, updated_heartbeat.instance_id)
        self.assertEqual(heartbeat.guest_agent_version,
                         updated_heartbeat.guest_agent_version)

        self.assertEqual(heartbeat.updated_at, updated_heartbeat.updated_at)
    def test_update_heartbeat(self):
        """
        Test to show the upgrade scenario that will be used by conductor
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(
            instance_id=instance_id, guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)

        # update
        AgentHeartBeat().update(id=heartbeat_found.id,
                                instance_id=instance_id,
                                guest_agent_version="1.2.3")

        # retrieve the record
        updated_heartbeat = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(updated_heartbeat)
        self.assertEqual(heartbeat.id, updated_heartbeat.id)
        self.assertEqual(heartbeat.instance_id, updated_heartbeat.instance_id)
        self.assertEqual(heartbeat.guest_agent_version,
                         updated_heartbeat.guest_agent_version)

        self.assertEqual(heartbeat.updated_at, updated_heartbeat.updated_at)
예제 #5
0
    def test_find_by_instance_id_none(self):
        """
        Test to retrieve a guest agents when id is None
        """
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=None)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)
    def test_find_by_instance_id_none(self):
        """
        Test to retrieve a guest agents when id is None
        """
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=None)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)
예제 #7
0
    def test_find_by_instance_id_not_found(self, mock_logging):
        """
        Test to retrieve a guest agents when id is not found
        """
        instance_id = str(uuid.uuid4())
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=instance_id)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)
    def test_find_by_instance_id_not_found(self, mock_logging):
        """
        Test to retrieve a guest agents when id is not found
        """
        instance_id = str(uuid.uuid4())
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=instance_id)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)