Example #1
0
func main() {
	flag.Parse()
	if *help {
		flag.Usage()
		os.Exit(0)
	}
	c, err := agent.SetupConfig(*config, *props)
	if err != nil {
		log.Fatal(err)
	}
	if err := agent.Run(c, *restore); err != nil {
		log.Fatal(err)
	}
}
	tConfig.Apps["master"] = common.App{
		ID:   c.MasterApp.AppID,
		Key:  c.MasterApp.AppKey,
		Site: c.MasterApp.Site,
	}
	tConfig.GatewayAddress = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.LocalServer.Addr.Port,
	}
	tConfig.MqttBroker = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.Mqtt.LocalBroker.Port,
	}

	go agent.Run(c, false)
	// wait for gateway-agent to start
	time.Sleep(1 * time.Second)
})

var _ = AfterSuite(func() {
	agent.Stop()
})

func TestIntegration(t *testing.T) {
	if testing.Short() {
		t.Skip("skipped by -test.short option")
	}
	if err := util.ConfigWrite("gw-config.yml", "gw-config.yml.tmpl", "MASTER_APP"); err != nil {
		t.Fatal(err)
	}
	// run on different port
	tConfig.Apps["master"] = common.App{
		ID:   c.MasterApp.AppID,
		Key:  c.MasterApp.AppKey,
		Site: c.MasterApp.Site,
	}
	tConfig.GatewayAddress = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.LocalServer.Addr.Port,
	}
	tConfig.MqttBroker = common.GatewayAddress{
		Host: "127.0.0.1",
		Port: c.Mqtt.LocalBroker.Port,
	}

	go agent.Run(c, true)
	// wait for gateway-agent to start
	time.Sleep(1 * time.Second)

})

var _ = AfterSuite(func() {
	agent.Stop()
})

func TestRestore(t *testing.T) {
	if testing.Short() {
		t.Skip("skipped by -test.short option")
	}
	if err := util.ConfigWrite("gw-config.yml", "gw-config.yml.tmpl", "MASTER_APP_R"); err != nil {
		t.Fatal(err)