Пример #1
0
// Runs root service
func Run(configFileName string) (chan common.ServiceMessage, string, error) {
	fullConfig, err := common.ReadConfig(configFileName)
	if err != nil {
		return nil, "", err
	}

	rootService := &Root{}
	rootServiceConfig := common.ServiceConfig{fullConfig.Services["root"].Common, make(map[string]interface{})}
	rootServiceConfig.ServiceSpecific[fullConfigKey] = fullConfig
	return common.InitializeService(rootService, rootServiceConfig)
}
Пример #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")

}
Пример #3
0
// Run configures and starts root service.
func Run(configFileName string) (*common.RestServiceInfo, error) {
	log.Printf("Entering root.Run()")
	fullConfig, err := common.ReadConfig(configFileName)
	if err != nil {
		return nil, err
	}

	rootService := &Root{}
	log.Printf("Initializing root config")
	rootServiceConfig := common.ServiceConfig{
		Common:          fullConfig.Services["root"].Common,
		ServiceSpecific: make(map[string]interface{}),
	}
	rootServiceConfig.ServiceSpecific[fullConfigKey] = fullConfig
	return common.InitializeService(rootService, rootServiceConfig, nil)
}
Пример #4
0
// Test the service list.
func TestServiceList(t *testing.T) {
	fmt.Println("Entering TestServiceList")
	dir, _ := os.Getwd()
	fmt.Println("In", dir)

	yamlFileName := "../common/testdata/romana.sample.yaml"
	common.MockPortsInConfig(yamlFileName)
	fmt.Println("Calling Run()")
	channel, addr, err := Run("/tmp/romana.yaml")
	if err != nil {
		fmt.Println(err.Error())
		t.FailNow()
	}

	fmt.Println("Waiting for message")
	msg := <-channel
	fmt.Println("Root service said:", msg)

	_, err = common.ReadConfig("/tmp/romana.yaml")
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	addr = fmt.Sprintf("http://%s", addr)
	client, err := common.NewRestClient(addr, common.DefaultRestTimeout)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	r := common.IndexResponse{}
	err = client.Get("", &r)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	fmt.Println("Received: ", r)
	svcName := r.ServiceName
	fmt.Println("Service name:", svcName)

	if svcName != "root" {
		t.Errorf("Expected serviceName to be root, got %s", svcName)
	}
}
Пример #5
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")
	}
}