Beispiel #1
0
func New(
	cellID string,
	bbs bbs.Client,
	executorClient executor.Client,
	evacuationReporter evacuation_context.EvacuationReporter,
	evacuationTTLInSeconds uint64,
) Generator {
	containerDelegate := internal.NewContainerDelegate(executorClient)
	lrpProcessor := internal.NewLRPProcessor(bbs, containerDelegate, cellID, evacuationReporter, evacuationTTLInSeconds)
	taskProcessor := internal.NewTaskProcessor(bbs, containerDelegate, cellID)

	return &generator{
		cellID:            cellID,
		bbs:               bbs,
		executorClient:    executorClient,
		lrpProcessor:      lrpProcessor,
		taskProcessor:     taskProcessor,
		containerDelegate: containerDelegate,
	}
}
	const expectedCellID = "cell-id"

	var (
		processor          internal.LRPProcessor
		logger             *lagertest.TestLogger
		bbsClient          *fake_bbs.FakeClient
		containerDelegate  *fake_internal.FakeContainerDelegate
		evacuationReporter *fake_evacuation_context.FakeEvacuationReporter
	)

	BeforeEach(func() {
		bbsClient = new(fake_bbs.FakeClient)
		containerDelegate = new(fake_internal.FakeContainerDelegate)
		evacuationReporter = &fake_evacuation_context.FakeEvacuationReporter{}
		evacuationReporter.EvacuatingReturns(false)
		processor = internal.NewLRPProcessor(bbsClient, containerDelegate, expectedCellID, evacuationReporter, 124)
		logger = lagertest.NewTestLogger("test")
	})

	Describe("Process", func() {
		const sessionPrefix = "test.ordinary-lrp-processor."

		var (
			desiredLRP          *models.DesiredLRP
			expectedLrpKey      models.ActualLRPKey
			expectedInstanceKey models.ActualLRPInstanceKey
			expectedNetInfo     models.ActualLRPNetInfo
			expectedSessionName string
		)

		BeforeEach(func() {
			instanceGuid string

			lrpKey         models.ActualLRPKey
			lrpInstanceKey models.ActualLRPInstanceKey
		)

		BeforeEach(func() {
			logger = lagertest.NewTestLogger("test")

			fakeBBS = new(fake_bbs.FakeClient)

			fakeContainerDelegate = &fake_internal.FakeContainerDelegate{}
			fakeEvacuationReporter = &fake_evacuation_context.FakeEvacuationReporter{}
			fakeEvacuationReporter.EvacuatingReturns(true)

			lrpProcessor = internal.NewLRPProcessor(fakeBBS, fakeContainerDelegate, localCellID, fakeEvacuationReporter, evacuationTTL)

			processGuid = "process-guid"
			desiredLRP = models.DesiredLRP{
				Domain:      "domain",
				ProcessGuid: processGuid,
				Instances:   1,
				RootFs:      "some-rootfs",
				Action: models.WrapAction(&models.RunAction{
					Path: "/bin/true",
				}),
			}

			instanceGuid = "instance-guid"
			index = 0