コード例 #1
0
ファイル: start_test.go プロジェクト: GABONIA/cli
func startAppWithInstancesAndErrors(displayApp ApplicationDisplayer, app models.Application, instances [][]models.AppInstanceFields, errorCodes []string, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, appRepo *testapi.FakeApplicationRepository, appInstancesRepo *testapi.FakeAppInstancesRepo) {
	configRepo := testconfig.NewRepositoryWithDefaults()
	appRepo = &testapi.FakeApplicationRepository{
		UpdateAppResult: app,
	}
	appRepo.ReadReturns.App = app
	appInstancesRepo = &testapi.FakeAppInstancesRepo{
		GetInstancesResponses:  instances,
		GetInstancesErrorCodes: errorCodes,
	}

	logRepo := &testapi.FakeLogsRepository{
		TailLogMessages: []*logmessage.LogMessage{
			testlogs.NewLogMessage("Log Line 1", app.Guid, LogMessageTypeStaging, time.Now()),
			testlogs.NewLogMessage("Log Line 2", app.Guid, LogMessageTypeStaging, time.Now()),
		},
	}

	args := []string{"my-app"}

	requirementsFactory.Application = app
	ui = callStart(args, configRepo, requirementsFactory, displayApp, appRepo, appInstancesRepo, logRepo)
	return
}
コード例 #2
0
ファイル: logs_test.go プロジェクト: vframbach/cli
	Context("when logged in", func() {
		var (
			app models.Application
		)

		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			requirementsFactory.TargetedSpaceSuccess = true

			app = models.Application{}
			app.Name = "my-app"
			app.Guid = "my-app-guid"

			currentTime := time.Now()
			recentLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", "1", logmessage.LogMessage_ERR, currentTime),
				testlogs.NewLogMessage("Log Line 2", app.Guid, "DEA", "1", logmessage.LogMessage_ERR, currentTime),
			}

			appLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", "1", logmessage.LogMessage_ERR, time.Now()),
			}

			requirementsFactory.Application = app
			logsRepo.RecentLogsForReturns(recentLogs, nil)
			logsRepo.TailLogsForStub = func(appGuid string, onConnect func(), onMessage func(*logmessage.LogMessage)) error {
				onConnect()
				for _, log := range appLogs {
					onMessage(log)
				}
				return nil
コード例 #3
0
ファイル: start_test.go プロジェクト: rbramwell/cli
				[]string{"timeout connecting to log server"},
			))
		})

		It("only displays staging logs when an app is starting", func() {
			requirementsFactory.Application = defaultAppForStart
			appRepo = &testApplication.FakeApplicationRepository{}
			appRepo.UpdateReturns(defaultAppForStart, nil)
			appRepo.ReadReturns(defaultAppForStart, nil)

			currentTime := time.Now()
			wrongSourceName := "DEA"
			correctSourceName := "STG"

			logMessages = []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", defaultAppForStart.Guid, wrongSourceName, "1", logmessage.LogMessage_OUT, currentTime),
				testlogs.NewLogMessage("Log Line 2", defaultAppForStart.Guid, correctSourceName, "1", logmessage.LogMessage_OUT, currentTime),
				testlogs.NewLogMessage("Log Line 3", defaultAppForStart.Guid, correctSourceName, "1", logmessage.LogMessage_OUT, currentTime),
				testlogs.NewLogMessage("Log Line 4", defaultAppForStart.Guid, wrongSourceName, "1", logmessage.LogMessage_OUT, currentTime),
			}

			callStart([]string{"my-app"})

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Log Line 2"},
				[]string{"Log Line 3"},
			))
			Expect(ui.Outputs).ToNot(ContainSubstrings(
				[]string{"Log Line 1"},
				[]string{"Log Line 4"},
			))
コード例 #4
0
ファイル: start_test.go プロジェクト: GABONIA/cli
			BeforeEach(func() {
				app = defaultAppForStart

				instances := [][]models.AppInstanceFields{[]models.AppInstanceFields{}}
				appRepo := &testapi.FakeApplicationRepository{
					UpdateAppResult: app,
				}
				appRepo.ReadReturns.App = app
				appInstancesRepo := &testapi.FakeAppInstancesRepo{
					GetInstancesResponses:  instances,
					GetInstancesErrorCodes: []string{"170001"},
				}

				logRepo := &testapi.FakeLogsRepository{
					TailLogMessages: []*logmessage.LogMessage{
						testlogs.NewLogMessage("Log Line 1", app.Guid, LogMessageTypeStaging, time.Now()),
						testlogs.NewLogMessage("Log Line 2", app.Guid, LogMessageTypeStaging, time.Now()),
					},
				}

				requirementsFactory.LoginSuccess = true
				requirementsFactory.Application = app
				config := testconfig.NewRepository()
				displayApp := &testcmd.FakeAppDisplayer{}

				cmd = NewStart(ui, config, displayApp, appRepo, appInstancesRepo, logRepo)
				cmd.StagingTimeout = 1
				cmd.PingerThrottle = 1
				cmd.StartupTimeout = 1
			})
コード例 #5
0
ファイル: logs_test.go プロジェクト: yingkitw/cli
	Context("when logged in", func() {
		var (
			app models.Application
		)

		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			requirementsFactory.TargetedSpaceSuccess = true

			app = models.Application{}
			app.Name = "my-app"
			app.GUID = "my-app-guid"

			currentTime := time.Now()
			recentLogs := []logs.Loggable{
				testlogs.NewLogMessage("Log Line 1", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, currentTime),
				testlogs.NewLogMessage("Log Line 2", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, currentTime),
			}

			appLogs := []logs.Loggable{
				testlogs.NewLogMessage("Log Line 1", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, time.Now()),
			}

			requirementsFactory.Application = app
			logsRepo.RecentLogsForReturns(recentLogs, nil)
			logsRepo.TailLogsForStub = func(appGUID string, onConnect func(), logChan chan<- logs.Loggable, errChan chan<- error) {
				onConnect()
				go func() {
					for _, log := range appLogs {
						logChan <- log
					}
コード例 #6
0
ファイル: logs_test.go プロジェクト: raghulsid/cli
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			requirementsFactory.TargetedSpaceSuccess = true

			app = models.Application{}
			app.Name = "my-app"
			app.Guid = "my-app-guid"

			currentTime := time.Now()
			recentLogs := []*events.LogMessage{
				testlogs.NewNoaaLogMessage("Log Line 1", app.Guid, "DEA", currentTime),
				testlogs.NewNoaaLogMessage("Log Line 2", app.Guid, "DEA", currentTime),
			}

			appLogs := []*events.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", time.Now()),
			}

			requirementsFactory.Application = app
			noaaRepo.RecentLogsForReturns(recentLogs, nil)

			noaaRepo.TailNoaaLogsForStub = func(appGuid string, onConnect func(), onMessage func(*events.LogMessage)) error {
				onConnect()
				for _, log := range appLogs {
					onMessage(log)
				}
				return nil
			}
		})

		It("shows the recent logs when the --recent flag is provided", func() {
コード例 #7
0
ファイル: start_test.go プロジェクト: palakmathur/cli
				UpdateAppResult: defaultAppForStart,
			}
			appRepo.ReadReturns.App = defaultAppForStart

			appInstancesRepo := &testapi.FakeAppInstancesRepo{
				GetInstancesResponses:  defaultInstanceReponses,
				GetInstancesErrorCodes: defaultInstanceErrorCodes,
			}

			currentTime := time.Now()
			wrongSourceName := "DEA"
			correctSourceName := "STG"

			logRepo := &testapi.FakeLogsRepository{
				TailLogMessages: []*logmessage.LogMessage{
					testlogs.NewLogMessage("Log Line 1", defaultAppForStart.Guid, wrongSourceName, currentTime),
					testlogs.NewLogMessage("Log Line 2", defaultAppForStart.Guid, correctSourceName, currentTime),
					testlogs.NewLogMessage("Log Line 3", defaultAppForStart.Guid, correctSourceName, currentTime),
					testlogs.NewLogMessage("Log Line 4", defaultAppForStart.Guid, wrongSourceName, currentTime),
				},
			}

			ui := callStart([]string{"my-app"}, testconfig.NewRepository(), requirementsFactory, displayApp, appRepo, appInstancesRepo, logRepo)

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Log Line 2"},
				[]string{"Log Line 3"},
			))
			Expect(ui.Outputs).ToNot(ContainSubstrings(
				[]string{"Log Line 1"},
				[]string{"Log Line 4"},
コード例 #8
0
ファイル: logs_test.go プロジェクト: Kunsarka/cli
	Context("when logged in", func() {
		var (
			app models.Application
		)

		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true

			app = models.Application{}
			app.Name = "my-app"
			app.Guid = "my-app-guid"

			currentTime := time.Now()
			recentLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", currentTime),
				testlogs.NewLogMessage("Log Line 2", app.Guid, "DEA", currentTime),
			}

			appLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", time.Now()),
			}

			requirementsFactory.Application = app
			logsRepo.RecentLogs = recentLogs
			logsRepo.TailLogMessages = appLogs
		})

		It("shows the recent logs when the --recent flag is provided", func() {
			runCommand("--recent", "my-app")
コード例 #9
0
	"github.com/cloudfoundry/loggregatorlib/logmessage"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("loggregatorMessage", func() {
	Describe("ToLog", func() {
		var date time.Time

		BeforeEach(func() {
			date = time.Date(2014, 4, 4, 11, 39, 20, 5, time.UTC)
		})

		Context("when the message comes", func() {
			It("include the instance index", func() {
				msg := testlogs.NewLogMessage("Hello World!", "", "DEA", "4", logmessage.LogMessage_OUT, date)
				Expect(terminal.Decolorize(msg.ToLog(time.UTC))).To(Equal("2014-04-04T11:39:20.00+0000 [DEA/4]      OUT Hello World!"))
			})

			It("doesn't include the instance index if sourceID is empty", func() {
				msg := testlogs.NewLogMessage("Hello World!", "", "DEA", "", logmessage.LogMessage_OUT, date)
				Expect(terminal.Decolorize(msg.ToLog(time.UTC))).To(Equal("2014-04-04T11:39:20.00+0000 [DEA]        OUT Hello World!"))
			})
		})

		Context("when the message was written to stderr", func() {
			It("shows the log type as 'ERR'", func() {
				msg := testlogs.NewLogMessage("Hello World!", "", "DEA", "4", logmessage.LogMessage_ERR, date)
				Expect(terminal.Decolorize(msg.ToLog(time.UTC))).To(Equal("2014-04-04T11:39:20.00+0000 [DEA/4]      ERR Hello World!"))
			})
		})