コード例 #1
0
    def test_save_should_persist_generic_rawdata_to_database(self):
        body = {
            "event_type": "image.upload",
            '_context_request_id': REQUEST_ID_1,
            '_context_project_id': TENANT_ID_1,
            "timestamp": TIMESTAMP_1,
            "publisher_id":
            "glance-api01-r2961.global.preprod-ord.ohthree.com",
            "message_id": MESSAGE_ID_1,
            "payload": {
                'instance_id': INSTANCE_ID_1,
                "status": "saving",
                "container_format": "ovf",
                "tenant": "5877054"
            }
        }
        deployment = "1"
        routing_key = "generic_monitor.info"
        json_body = json.dumps([routing_key, body])
        raw = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(db, 'create_generic_rawdata')
        db.create_generic_rawdata(
            deployment="1",
            tenant=TENANT_ID_1,
            json=json_body,
            routing_key=routing_key,
            when=utils.str_time_to_unix(TIMESTAMP_1),
            publisher="glance-api01-r2961.global.preprod-ord.ohthree.com",
            event="image.upload",
            service="glance-api01-r2961",
            host="global.preprod-ord.ohthree.com",
            instance=INSTANCE_ID_1,
            request_id=REQUEST_ID_1,
            message_id=MESSAGE_ID_1).AndReturn(raw)

        self.mox.ReplayAll()

        notification = Notification(body, deployment, routing_key, json_body)
        self.assertEquals(notification.save(), raw)
        self.mox.VerifyAll()
コード例 #2
0
ファイル: notification.py プロジェクト: DragonDM/stacktach
 def save(self):
     return db.create_generic_rawdata(deployment=self.deployment,
                                      routing_key=self.routing_key,
                                      tenant=self.tenant,
                                      json=self.json,
                                      when=self.when,
                                      publisher=self.publisher,
                                      event=self.event,
                                      service=self.service,
                                      host=self.host,
                                      instance=self.instance,
                                      request_id=self.request_id,
                                      message_id=self.message_id)
コード例 #3
0
    def test_save_should_persist_generic_rawdata_to_database(self):
        body = {
            "event_type": "image.upload",
            '_context_request_id': REQUEST_ID_1,
            '_context_project_id': TENANT_ID_1,
            "timestamp": TIMESTAMP_1,
            "publisher_id": "glance-api01-r2961.global.preprod-ord.ohthree.com",
            "message_id": MESSAGE_ID_1,
            "payload": {
                'instance_id': INSTANCE_ID_1,
                "status": "saving",
                "container_format": "ovf",
                "tenant": "5877054"
            }
        }
        deployment = "1"
        routing_key = "generic_monitor.info"
        json = '{["routing_key", {%s}]}' % body
        raw = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(db, 'create_generic_rawdata')
        db.create_generic_rawdata(
            deployment="1",
            tenant=TENANT_ID_1,
            json=json,
            routing_key=routing_key,
            when=utils.str_time_to_unix(TIMESTAMP_1),
            publisher="glance-api01-r2961.global.preprod-ord.ohthree.com",
            event="image.upload",
            service="glance-api01-r2961",
            host="global.preprod-ord.ohthree.com",
            instance=INSTANCE_ID_1,
            request_id=REQUEST_ID_1,
            message_id=MESSAGE_ID_1).AndReturn(raw)

        self.mox.ReplayAll()

        notification = Notification(body, deployment, routing_key, json)
        self.assertEquals(notification.save(), raw)
        self.mox.VerifyAll()
コード例 #4
0
ファイル: notification.py プロジェクト: ravikamachi/stacktach
 def save(self):
     return db.create_generic_rawdata(deployment=self.deployment,
                                      routing_key=self.routing_key,
                                      tenant=self.tenant,
                                      json=self.json,
                                      when=self.when,
                                      publisher=self.publisher,
                                      event=self.event,
                                      service=self.service,
                                      host=self.host,
                                      instance=self.instance,
                                      request_id=self.request_id,
                                      message_id=self.message_id)