Ejemplo n.º 1
0
var _ = Describe("App Events Repo", func() {
	It("TestListOldV2EventsWhenNewV2ApiNotFound", func() {
		deps := setupEventTest([]testnet.TestRequest{
			newV2NotFoundRequest,
			firstPageOldV2EventsRequest,
			secondPageOldV2EventsRequest,
		})
		defer teardownEventTest(deps)

		repo := NewCloudControllerAppEventsRepository(deps.config, deps.gateway)

		expectedEvents := []models.EventFields{
			models.EventFields{
				Name:        "app crashed",
				Description: "instance: 1, reason: app instance exited, exit_status: 1",
				Timestamp:   testtime.MustParse(APP_EVENT_TIMESTAMP_FORMAT, "2013-10-07T16:51:07+00:00"),
			},
			models.EventFields{
				Name:        "app crashed",
				Description: "instance: 2, reason: app instance was stopped, exit_status: 2",
				Timestamp:   testtime.MustParse(APP_EVENT_TIMESTAMP_FORMAT, "2013-10-07T17:51:07+00:00"),
			},
		}

		list := []models.EventFields{}
		apiErr := repo.ListEvents("my-app-guid", func(event models.EventFields) bool {
			list = append(list, event)
			return true
		})

		Expect(apiErr).NotTo(HaveOccurred())
Ejemplo n.º 2
0
				"metadata": {
				  "instance": "50dd66d3f8874b35988d23a25d19bfa0",
				  "index": 3,
				  "exit_status": -1,
				  "exit_description": "unknown",
				  "reason": "CRASHED"
				}
			  }
			}`), &resource)

			Expect(err).NotTo(HaveOccurred())

			eventFields := resource.ToFields()
			Expect(eventFields.Guid).To(Equal("event-1-guid"))
			Expect(eventFields.Name).To(Equal("app.crash"))
			Expect(eventFields.Timestamp).To(Equal(testtime.MustParse(eventTimestampFormat, "2013-10-07T16:51:07+00:00")))
			Expect(eventFields.Description).To(Equal(`index: 3, reason: CRASHED, exit_description: unknown, exit_status: -1`))
		})

		It("unmarshals app update events", func() {
			err := json.Unmarshal([]byte(`
			{
			  "metadata": {
				"guid": "event-1-guid"
			  },
			  "entity": {
				"type": "audit.app.update",
				"timestamp": "2014-01-21T00:20:11+00:00",
				"metadata": {
				  "request": {
				  	"state": "STOPPED",
Ejemplo n.º 3
0
		server, handler = testnet.NewServer(requests)
		config.SetApiEndpoint(server.URL)
	}

	Describe("list recent events", func() {
		It("returns the most recent events", func() {
			setupTestServer(eventsRequest)

			list, err := repo.RecentEvents("my-app-guid", 2)
			Expect(err).ToNot(HaveOccurred())

			Expect(list).To(Equal([]models.EventFields{
				models.EventFields{
					Guid:        "event-1-guid",
					Name:        "audit.app.update",
					Timestamp:   testtime.MustParse(eventTimestampFormat, "2014-01-21T00:20:11+00:00"),
					Description: "instances: 1, memory: 256, command: PRIVATE DATA HIDDEN, environment_json: PRIVATE DATA HIDDEN",
					ActorName:   "*****@*****.**",
				},
				models.EventFields{
					Guid:        "event-2-guid",
					Name:        "audit.app.update",
					Timestamp:   testtime.MustParse(eventTimestampFormat, "2014-01-21T00:20:11+00:00"),
					Description: "instances: 1, memory: 256, command: PRIVATE DATA HIDDEN, environment_json: PRIVATE DATA HIDDEN",
					ActorName:   "*****@*****.**",
				},
			}))
		})
	})
})
Ejemplo n.º 4
0
		})

		It("fails with usage when no arguments are given", func() {
			runCommand()
			Expect(ui.FailedWithUsage).To(BeTrue())
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})

	})

	Describe("displaying a summary of an app", func() {
		BeforeEach(func() {
			app := makeAppWithRoute("my-app")
			appInstance := models.AppInstanceFields{
				State:     models.InstanceRunning,
				Since:     testtime.MustParse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2012"),
				CpuUsage:  1.0,
				DiskQuota: 1 * formatters.GIGABYTE,
				DiskUsage: 32 * formatters.MEGABYTE,
				MemQuota:  64 * formatters.MEGABYTE,
				MemUsage:  13 * formatters.BYTE,
			}

			appInstance2 := models.AppInstanceFields{
				State: models.InstanceDown,
				Since: testtime.MustParse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Apr 1 15:04:05 -0700 MST 2012"),
			}

			instances := []models.AppInstanceFields{appInstance, appInstance2}

			appSummaryRepo.GetSummarySummary = app