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") }
// Main entry point for the IPAM microservice func main() { createSchema := flag.Bool("createSchema", false, "Create schema") overwriteSchema := flag.Bool("overwriteSchema", false, "Overwrite schema") rootUrl := flag.String("rootUrl", "", "Root service URL") flag.Parse() if *createSchema || *overwriteSchema { err := ipam.CreateSchema(*rootUrl, *overwriteSchema) if err != nil { panic(err) } fmt.Println("Schema created.") return } channel, _, err := ipam.Run(*rootUrl) if err != nil { panic(err) } for { msg := <-channel fmt.Println(msg) } }