Beispiel #1
0
    def test_process_updates_create_end(self):
        values = {
            'instance': INSTANCE_ID_1,
            'request_id': REQUEST_ID_1,
            'instance_type_id': '1',
        }
        InstanceUsage(**values).save()

        sent = '2012-12-21 12:34:50.123'
        when = utils.str_time_to_unix(sent)
        json = test_utils.make_create_end_json(sent)
        raw = create_raw(self.deployment, when,
                         views.INSTANCE_EVENT['create_end'], json=json)

        views._process_usage_for_updates(raw)

        usages = InstanceUsage.objects.all()
        self.assertEqual(len(usages), 1)
        usage = usages[0]
        self.assertEqual(usage.launched_at, when)
Beispiel #2
0
    def test_create_workflow_start_late(self):
        created_str = '2012-12-21 06:30:50.123'
        created = utils.str_time_to_unix(created_str)
        launched_str = '2012-12-21 06:34:50.123'
        launched = utils.str_time_to_unix(launched_str)
        create_start_json = test_utils.make_create_start_json()
        create_end_json = test_utils.make_create_end_json(launched_str)
        create_start_raw = create_raw(self.deployment, created,
                                      views.INSTANCE_EVENT['create_start'],
                                      json=create_start_json)
        create_end_raw = create_raw(self.deployment, launched,
                                    views.INSTANCE_EVENT['create_end'],
                                    json=create_end_json)

        views.aggregate_usage(create_end_raw)
        views.aggregate_usage(create_start_raw)

        usages = InstanceUsage.objects.all()
        self.assertEqual(len(usages), 1)
        usage = usages[0]
        self.assertOnUsage(usage, INSTANCE_ID_1, '1', launched, REQUEST_ID_1)
Beispiel #3
0
    def test_process_updates_create_end(self):
        values = {
            'instance': INSTANCE_ID_1,
            'request_id': REQUEST_ID_1,
            'instance_type_id': '1',
        }
        InstanceUsage(**values).save()

        sent = '2012-12-21 12:34:50.123'
        when = utils.str_time_to_unix(sent)
        json = test_utils.make_create_end_json(sent)
        raw = create_raw(self.deployment,
                         when,
                         views.INSTANCE_EVENT['create_end'],
                         json=json)

        views._process_usage_for_updates(raw)

        usages = InstanceUsage.objects.all()
        self.assertEqual(len(usages), 1)
        usage = usages[0]
        self.assertEqual(usage.launched_at, when)
Beispiel #4
0
    def test_create_workflow_start_late(self):
        created_str = '2012-12-21 06:30:50.123'
        created = utils.str_time_to_unix(created_str)
        launched_str = '2012-12-21 06:34:50.123'
        launched = utils.str_time_to_unix(launched_str)
        create_start_json = test_utils.make_create_start_json()
        create_end_json = test_utils.make_create_end_json(launched_str)
        create_start_raw = create_raw(self.deployment,
                                      created,
                                      views.INSTANCE_EVENT['create_start'],
                                      json=create_start_json)
        create_end_raw = create_raw(self.deployment,
                                    launched,
                                    views.INSTANCE_EVENT['create_end'],
                                    json=create_end_json)

        views.aggregate_usage(create_end_raw)
        views.aggregate_usage(create_start_raw)

        usages = InstanceUsage.objects.all()
        self.assertEqual(len(usages), 1)
        usage = usages[0]
        self.assertOnUsage(usage, INSTANCE_ID_1, '1', launched, REQUEST_ID_1)