Пример #1
0
// ------------------------------------------
//
//
// End 2 End test of the MTAContainer with Failure strategy
// and RoundRobinSchedule.
//
//
func TestEnd2End(t *testing.T) {

	//	mg := mailgunprovider.New(utilities.GetLogger("MG"),mailgunprovider.BitLabConfig("09fe27"),NewMockFailureStrategy());
	//	az := amazonsesprovider.New(utilities.GetLogger("MG"),amazonsesprovider.BitLabConfig("09fe27"),NewMockFailureStrategy());
	//  sg := sendgridprovider.New(utilities.GetLogger("MG"),sendgridprovider.BitLabConfig("09fe27"),NewMockFailureStrategy());
	var provider = loopbackprovider.New(utilities.GetLogger("loop1"), mtacontainer.NewThressHoldFailureStrategy(12))

	scheduler := mtacontainer.NewRoundRobinScheduler([]mtacontainer.MTAProvider{provider})

	container := mtacontainer.New(scheduler)

	mail1 := FreshTestMail(provider, "*****@*****.**")
	mail2 := FreshTestMail(provider, "*****@*****.**")
	mail3 := FreshTestMail(provider, "*****@*****.**")

	container.GetOutgoing() <- mail1
	container.GetOutgoing() <- mail2
	container.GetOutgoing() <- mail3

	go func() {
		<-container.GetIncoming()
	}()

	i := 0
	for {
		select {
		case e := <-container.GetEvent():
			log.Println("Reading event from container: " + e.GetError().Error())
			if i == 2 {
				return
			}
			i = i + 1
		}
	}
}
Пример #2
0
func GetProductionMTAContainer() (mtacontainer.MTAContainer, mtacontainer.Scheduler) {
	var passphrase = GetPassphraseFromArgOrTerminal()
	var mailGunConfig = mailgunprovider.BitLabConfig(passphrase)
	var amazonConfig = amazonsesprovider.BitLabConfig(passphrase)
	var sendgridConfig = sendgridprovider.BitLabConfig(passphrase)
	providers := make([]mtacontainer.MTAProvider, 3)
	providers[0] = mailgunprovider.New(utilities.GetLogger("MailGun"), mailGunConfig, mtacontainer.NewThressHoldFailureStrategy(ERROR_THRESHOLD))
	providers[1] = amazonsesprovider.New(utilities.GetLogger("amazonSES"), amazonConfig, mtacontainer.NewThressHoldFailureStrategy(ERROR_THRESHOLD))
	providers[2] = sendgridprovider.New(utilities.GetLogger("SendGrid"), sendgridConfig, mtacontainer.NewThressHoldFailureStrategy(ERROR_THRESHOLD))
	var scheduler mtacontainer.Scheduler = mtacontainer.NewRoundRobinScheduler(providers)
	return mtacontainer.New(scheduler), scheduler
}
func TestLoopBack(t *testing.T) {

	loop1 := loopbackprovider.New(utilities.GetLogger("loop1"), mtacontainer.NewThressHoldFailureStrategy(1))

	mail := test.FreshTestMail(loop1, "test")

	c := make(chan int)

	go func() {
		for {
			select {
			case <-loop1.GetEvent():
			case <-c:
			}
		}
	}()

	loop1.GetOutgoing() <- mail

	<-loop1.GetIncoming()
}
Пример #4
0
func GetLoopBackContainer() (mtacontainer.MTAContainer, mtacontainer.Scheduler) {
	var provider = loopbackprovider.New(utilities.GetLogger("LoopBack"), mtacontainer.NewThressHoldFailureStrategy(ERROR_THRESHOLD))
	var scheduler = mtacontainer.NewRoundRobinScheduler([]mtacontainer.MTAProvider{provider})
	return mtacontainer.New(scheduler), scheduler
}