Пример #1
0
func main() {
	// init server
	err := server.Init("registry")
	if err != nil {
		server.Log.Fatal(err)
		return
	}

	err = mysql.MigrateDatabase(*confDBHost, *confDBPort, *confDBName, *confDBUser, *confDBPass)
	if err != nil {
		server.Log.Fatal(err)
		return
	}

	// register a rpc service
	r, err := NewRegistry()
	if err != nil {
		server.Log.Fatal(err)
		return
	}
	err = server.RegisterRPCHandler(r)
	if err != nil {
		server.Log.Errorf("Register RPC service Error: %s", err)
		return
	}

	// start to run
	err = server.Run()
	if err != nil {
		server.Log.Fatal(err)
	}
}
Пример #2
0
func TestVendor(t *testing.T) {
	mysql.MigrateDatabase(defaultDBHost, defaultDBPort, defaultDBName, defaultDBUser, "")

	*confAESKey = "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"

	r, err := NewRegistry()
	if err != nil {
		t.Fatal(err)
	}

	testVendor(t, r)
}
Пример #3
0
func TestRegistry(t *testing.T) {
	err := mysql.MigrateDatabase(defaultDBHost, defaultDBPort, defaultDBName, defaultDBUser, "")
	if err != nil {
		t.Fatal(err)
	}

	*confAESKey = "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"

	*confDBPass = ""
	r, err := NewRegistry()
	if err != nil {
		t.Fatal(err)
	}

	testVendor(t, r)
	testProduct(t, r)
	testDevice(t, r)
}