Example #1
0
// Main entry point for the root microservice
func main() {
	configFileName := flag.String("c", "", "Configuration file")
	flag.Parse()
	channel, _, err := root.Run(*configFileName)
	if err != nil {
		panic(err)
	}
	for {
		msg := <-channel
		log.Println(msg)
	}
}
Example #2
0
func (s *MySuite) SetUpTest(c *check.C) {
	dir, _ := os.Getwd()
	c.Log("Entering setup in directory", dir)

	common.MockPortsInConfig("../common/testdata/romana.sample.yaml")
	s.configFile = "/tmp/romana.yaml"
	var err error
	s.config, err = common.ReadConfig(s.configFile)
	if err != nil {
		panic(err)
	}

	c.Log("Root configuration: ", s.config.Services["root"].Common.Api.GetHostPort())

	// Starting root service
	fmt.Println("STARTING ROOT SERVICE")
	channelRoot, addr, err := root.Run(s.configFile)
	if err != nil {
		c.Error(err)
	}
	s.rootUrl = "http://" + addr
	c.Log("Root URL:", s.rootUrl)

	msg := <-channelRoot
	c.Log("Root service said:", msg)
	c.Log("Waiting a bit...")
	time.Sleep(time.Second)
	c.Log("Creating topology schema with root URL", s.rootUrl)

	err = topology.CreateSchema(s.rootUrl, true)
	if err != nil {
		c.Fatal(err)
	}
	c.Log("OK")

	c.Log("Creating tenant schema")
	err = tenant.CreateSchema(s.rootUrl, true)
	if err != nil {
		c.Fatal(err)
	}
	c.Log("OK")

	c.Log("Creating IPAM schema")
	err = ipam.CreateSchema(s.rootUrl, true)
	if err != nil {
		c.Fatal(err)
	}
	c.Log("OK")

	myLog(c, "Done with setup")

}
Example #3
0
func (s *MySuite) SetUpTest(c *check.C) {

	myLog(c, "Entering SetUP, services started: ", s.servicesStarted)
	if !s.servicesStarted {
		dir, _ := os.Getwd()
		myLog(c, "Entering setup in directory", dir)
		var err error
		err = s.RomanaTestSuite.MockConfig(common.DefaultTestConfigFile)
		if err != nil {
			panic(err)
		}

		myLog(c, "Root configuration: ", s.RomanaTestSuite.Config.Services["root"].Common.Api.GetHostPort())
		root.Run(s.RomanaTestSuite.ConfigFile)

		// Starting root service
		myLog(c, "Starting root service...")
		svcInfo, err := root.Run(s.RomanaTestSuite.ConfigFile)
		if err != nil {
			c.Error(err)
		}
		s.rootURL = "http://" + svcInfo.Address
		myLog(c, "Root URL:", s.rootURL)

		msg := <-svcInfo.Channel
		myLog(c, "Root service said:", msg)

		myLog(c, "Creating topology schema")
		topoSvc := &TopologySvc{}
		err = common.SimpleOverwriteSchema(topoSvc, s.rootURL)
		myLog(c, "CreateSchema returned err: ", err, "which is of type", reflect.TypeOf(err), "let's compare it to", nil, ": err != nil: ", err != nil)
		if err != nil {
			c.Fatal(err)
		}
		s.servicesStarted = true
		myLog(c, "Done with setup")
	}
}
Example #4
0
func (s *MySuite) SetUpTest(c *check.C) {
	myLog(c, "Entering SetUP, services started: ", s.servicesStarted)
	if !s.servicesStarted {
		dir, _ := os.Getwd()
		myLog(c, "Entering setup in directory", dir)
		common.MockPortsInConfig("../common/testdata/romana.sample.yaml")
		s.configFile = "/tmp/romana.yaml"
		var err error
		s.config, err = common.ReadConfig(s.configFile)
		if err != nil {
			panic(err)
		}

		myLog(c, "Root configuration: ", s.config.Services["root"].Common.Api.GetHostPort())
		root.Run(s.configFile)

		// Starting root service
		myLog(c, "Starting root service...")
		channelRoot, addr, err := root.Run(s.configFile)
		if err != nil {
			c.Error(err)
		}
		s.rootUrl = "http://" + addr
		myLog(c, "Root URL:", s.rootUrl)

		msg := <-channelRoot
		myLog(c, "Root service said:", msg)

		myLog(c, "Creating topology schema")
		err = CreateSchema(s.rootUrl, true)
		myLog(c, "CreateSchema returned err: ", err, "which is of type", reflect.TypeOf(err), "let's compare it to", nil, ": err != nil: ", err != nil)
		if err != nil {
			c.Fatal(err)
		}
		s.servicesStarted = true
		myLog(c, "Done with setup")
	}
}
Example #5
0
File: main.go Project: romana/core
// Main entry point for the root microservice
func main() {
	cs := common.NewCliState()
	err := cs.Init()
	if err != nil {
		panic(err)
	}
	if *cs.ConfigFile == "" {
		fmt.Println("Must specify configFileName.")
		return
	}
	svcInfo, err := root.Run(*cs.ConfigFile)
	for {
		msg := <-svcInfo.Channel
		log.Println(msg)
	}
}