Exemplo n.º 1
0
func (f *FakeCell) SpinUp(serviceClient bbs.ServiceClient) {
	//make a test-friendly AuctionRepDelegate using the auction package's SimulationRepDelegate
	f.SimulationRep = simulationrep.New(f.stack, "Z0", rep.Resources{
		DiskMB:     100,
		MemoryMB:   100,
		Containers: 100,
	})

	//spin up an http auction server
	logger := lager.NewLogger(f.cellID)
	logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))

	fakeLRPStopper := new(fake_lrp_stopper.FakeLRPStopper)
	fakeExecutorClient := new(executorfakes.FakeClient)
	fakeEvacuatable := new(fake_evacuation_context.FakeEvacuatable)

	handlers := rephandlers.New(f.SimulationRep, fakeLRPStopper, fakeExecutorClient, fakeEvacuatable, logger)
	router, err := rata.NewRouter(rep.Routes, handlers)
	Expect(err).NotTo(HaveOccurred())
	f.server = httptest.NewServer(router)

	presence := models.NewCellPresence(
		f.cellID,
		f.server.URL,
		"az1",
		models.NewCellCapacity(512, 1024, 124),
		[]string{},
		[]string{})

	f.heartbeater = ifrit.Invoke(serviceClient.NewCellPresenceRunner(logger, &presence, time.Second))
}
func buildInProcessReps() map[string]rep.SimClient {
	cells := map[string]rep.SimClient{}

	for i := 0; i < numCells; i++ {
		cells[cellGuid(i)] = simulationrep.New(linuxStack, zone(i), repResources)
	}

	return cells
}
Exemplo n.º 3
0
func main() {
	cf_lager.AddFlags(flag.CommandLine)
	flag.Parse()

	if *repGuid == "" {
		panic("need rep-guid")
	}

	if *httpAddr == "" {
		panic("need http addr")
	}

	simulationRep := simulationrep.New(*stack, *zone, rep.Resources{
		MemoryMB:   int32(*memoryMB),
		DiskMB:     int32(*diskMB),
		Containers: *containers,
	})

	logger, _ := cf_lager.New("repnode-http")

	fakeLRPStopper := new(fake_lrp_stopper.FakeLRPStopper)
	fakeExecutorClient := new(executorfakes.FakeClient)
	fakeEvacuatable := new(fake_evacuation_context.FakeEvacuatable)

	handlers := rephandlers.New(simulationRep, fakeLRPStopper, fakeExecutorClient, fakeEvacuatable, logger.Session(*repGuid))
	router, err := rata.NewRouter(rep.Routes, handlers)
	if err != nil {
		log.Fatalln("failed to make router:", err)
	}
	httpServer := http_server.New(*httpAddr, router)

	monitor := ifrit.Invoke(sigmon.New(httpServer))
	fmt.Println("rep node listening")
	err = <-monitor.Wait()
	if err != nil {
		println("EXITED WITH ERROR: ", err.Error())
	}
}