Ejemplo n.º 1
0
func main() {
	var service keyvalue.Service
	if opts.Client {
		_, service = client.Init(args[0])
	} else {
		port, err := strconv.Atoi(args[0])
		if err == nil {
			_, service = server.Init(uint16(port))
		} else {
			split := strings.Split(args[0], ":")
			port, err := strconv.Atoi(split[len(split)-1])
			if err == nil {
				_, service = server.Init(uint16(port))
			} else {
				log.Fatalf("Could not parse port from '%s': %v", args[0], err)
			}
		}
	}

	defer service.Close()

	for oper := range operations {
		if oper.value == "" {
			result, value := service.Get(oper.key)
			log.Printf("Called Get(key=%s) Received(result=%d, value=%s)\n", oper.key, result, value)
		} else {
			result, old := service.Set(oper.key, oper.value)
			log.Printf("Called Set(key=%s, value=%s) Received(result=%d, value=%s)\n", oper.key, oper.value, result, old)
		}
	}
}
Ejemplo n.º 2
0
func TestClient(t *testing.T) {
	os.RemoveAll(server.LogDir)
	server.Init(12345)
	c := clientInit("localhost:12345")
	//c := clientInit("adelie-01:12345")
	sanityTest(c)
	correctnessTest(c)
	performanceTest(c, 100)
	performanceTest(c, 200)
	performanceTest(c, 500)
	performanceTest(c, 1000)
	performanceTest(c, 5000)
}