示例#1
0
// runScenarioTest runs a test with the given number of orders
func runScenarioTest(assert *asserts.Asserts, param scenarioParam) {
	applog.Infof(param.String())
	monitoring.Reset()

	env, oas := setUpEnvironment(param)

	for on := 0; on < param.Orders; on++ {
		env.EmitSimple("shop", "order", generateOrder(on, param.Items))
	}

	oas.Wait(param.Orders)

	ol, sl := oas.Lengths()

	assert.Equal(ol, param.Orders, "All orders have been placed.")
	assert.Equal(sl, param.Orders, "All orders have been delivered.")
	assert.Equal(ol, sl, "The number of orders and shipments is equal.")

	time.Sleep(2 * time.Second)
	env.Shutdown()
	time.Sleep(2 * time.Second)

	monitoring.MeasuringPointsPrintAll()
	monitoring.StaySetVariablesPrintAll()
}
示例#2
0
// runScenarioTest runs a test with the given number of orders
func runScenarioTest(assert *asserts.Asserts, param scenarioParam) {
	applog.Infof(param.String())
	monitoring.Reset()

	// Prepare test.
	done := make(chan bool)
	provider := config.NewMapConfigurationProvider()
	config := config.New(provider)

	config.Set("backend", "single")

	assert.Nil(ebus.Init(config), "single node backend started")

	StartShopAgent()
	StartWarehouseAgent()
	StartManufacturerAgent()
	StartDeliveryAgent()
	StartWaitAgent(done)

	// Run orders.
	for on := 0; on < param.Orders; on++ {
		order := generateOrder(on)
		err := ebus.Emit(order, "OrderReceived")
		assert.Nil(err, "order emitted")
	}

	select {
	case <-done:
		applog.Infof("order processing done")
	case <-time.After(param.Timeout):
		assert.Fail("timeout during wait for processed orders")
	}

	// Finalize test.
	err := ebus.Stop()
	assert.Nil(err, "stopped the bus")
	time.Sleep(time.Second)
	monitoring.MeasuringPointsPrintAll()
}