Exemplo n.º 1
0
// Generate and send a random GetValuesSingle request.
func (l *Load) sendMulti(client *gen.HFileServiceClient, diff *gen.HFileServiceClient) {
	numKeys := int(math.Abs(rand.ExpFloat64()*10) + 1)
	keys := l.randomKeys(numKeys)
	r := &gen.SingleHFileKeyRequest{HfileName: &l.collection, SortedKeys: keys}

	before := time.Now()
	resp, err := client.GetValuesMulti(r)
	if err != nil {
		log.Println("[GetValuesMulti] Error fetching value:", err, util.PrettyKeys(keys))
	}
	report.TimeSince(l.rtt+".overall", before)
	report.TimeSince(l.rtt+".getValuesMulti", before)

	if diff != nil {
		beforeDiff := time.Now()
		diffResp, diffErr := diff.GetValuesMulti(r)
		if diffErr != nil {
			log.Println("[GetValuesMulti] Error fetching diff value:", diffErr, util.PrettyKeys(keys))
		}
		report.TimeSince(l.diffRtt+".overall", beforeDiff)
		report.TimeSince(l.diffRtt+".getValuesMulti", beforeDiff)

		if err == nil && diffErr == nil && !reflect.DeepEqual(resp, diffResp) {
			report.Inc("diffs")
			report.Inc("diffs.getValuesMulti")
			log.Printf("[DIFF-getValuesMulti] req: %v\n \torig: %v\n\n\tdiff: %v\n", r, resp, diffResp)
		}
	}
}
Exemplo n.º 2
0
// Generate and send a random GetValuesSingle request.
func (l *Load) sendGetIterator(client *gen.HFileServiceClient, diff *gen.HFileServiceClient) {

	includeValues := true
	k := l.randomKey()
	lim := int32(10)
	r := &gen.IteratorRequest{HfileName: &l.collection, IncludeValues: &includeValues, LastKey: k, ResponseLimit: &lim}

	before := time.Now()
	resp, err := client.GetIterator(r)
	if err != nil {
		log.Println("[GetIterator] Error fetching value:", err, k)
	}
	report.TimeSince(l.rtt+".overall", before)
	report.TimeSince(l.rtt+".GetIterator", before)

	if diff != nil {
		beforeDiff := time.Now()
		diffResp, diffErr := diff.GetIterator(r)
		if diffErr != nil {
			log.Println("[GetIterator] Error fetching diff value:", diffErr, k)
		}
		report.TimeSince(l.diffRtt+".overall", beforeDiff)
		report.TimeSince(l.diffRtt+".GetIterator", beforeDiff)

		if err == nil && diffErr == nil && !reflect.DeepEqual(resp, diffResp) {
			report.Inc("diffs")
			report.Inc("diffs.GetIterator")
			log.Printf("[DIFF-GetIterator] req: %v\n", r)
			log.Printf("[DIFF-GetIterator] orig (skip %d): %v\n", resp.GetSkipKeys(), resp)
			log.Printf("[DIFF-GetIterator] diff (skip %d): %v\n", diffResp.GetSkipKeys(), diffResp)
		}
	}
}
Exemplo n.º 3
0
// Generate and send a random GetValuesSingle request.
func (l *Load) sendPrefixes(client *gen.HFileServiceClient, diff *gen.HFileServiceClient) {
	numKeys := int(math.Abs(rand.ExpFloat64()*10) + 1)
	fullKeys := l.randomKeys(numKeys)
	prefixes := make([][]byte, len(fullKeys))

	for i, v := range fullKeys {
		prefixes[i] = v[:len(v)-2]
	}
	sort.Sort(util.Keys(prefixes))
	r := &gen.PrefixRequest{HfileName: &l.collection, SortedKeys: prefixes}

	before := time.Now()
	resp, err := client.GetValuesForPrefixes(r)
	if err != nil {
		log.Println("[GetValuesForPrefixes] Error fetching value:", err, util.PrettyKeys(prefixes))
	}
	report.TimeSince(l.rtt+".overall", before)
	report.TimeSince(l.rtt+".GetValuesForPrefixes", before)

	if diff != nil {
		beforeDiff := time.Now()
		diffResp, diffErr := diff.GetValuesForPrefixes(r)
		if diffErr != nil {
			log.Println("[GetValuesForPrefixes] Error fetching diff value:", diffErr, util.PrettyKeys(prefixes))
		}
		report.TimeSince(l.diffRtt+".overall", beforeDiff)
		report.TimeSince(l.diffRtt+".GetValuesForPrefixes", beforeDiff)

		if err == nil && diffErr == nil && !reflect.DeepEqual(resp, diffResp) {
			report.Inc("diffs")
			report.Inc("diffs.GetValuesForPrefixes")
			log.Printf("[DIFF-GetValuesForPrefixes] req: %v\n \torig: %v\n\n\tdiff: %v\n", r, resp, diffResp)
		}
	}
}
Exemplo n.º 4
0
func dummyWorker(t hasFatal, client *gen.HFileServiceClient, work chan *gen.SingleHFileKeyRequest, done *sync.WaitGroup) {
	defer done.Done()
	// warmup
	if _, err := client.GetValuesSingle(GetRandomTestReqs("compressed", 1, 5, 50000)[0]); err != nil {
		return
	}

	for {
		if req, ok := <-work; !ok {
			return
		} else if res, err := client.GetValuesSingle(req); err != nil {
			t.Fatal("error: ", err)
		} else {
			CheckReqAndRes(t, req, res)
		}
	}
}
Exemplo n.º 5
0
// Generate and send a random GetValuesSingle request.
func (l *Load) sendMulti(client *gen.HFileServiceClient, diff *gen.HFileServiceClient) {
	var wg sync.WaitGroup

	keys := l.randomKeys()
	r := &gen.SingleHFileKeyRequest{HfileName: &l.collection, SortedKeys: keys}

	var diffResp *gen.MultiHFileKeyResponse
	var diffErr error
	if diff != nil {
		wg.Add(1)
		go func() {
			defer wg.Done()
			beforeDiff := time.Now()
			diffResp, diffErr = diff.GetValuesMulti(r)
			if diffErr != nil {
				log.Println("[GetValuesMulti] Error fetching diff value:", renderErr(diffErr), util.PrettyKeys(keys))
			}
			report.TimeSince(l.diffRtt+".overall", beforeDiff)
			report.TimeSince(l.diffRtt+".getValuesMulti", beforeDiff)
		}()
	}

	before := time.Now()
	resp, err := client.GetValuesMulti(r)
	if err != nil {
		log.Println("[GetValuesMulti] Error fetching value:", renderErr(err), util.PrettyKeys(keys))
	}
	report.TimeSince(l.rtt+".overall", before)
	report.TimeSince(l.rtt+".getValuesMulti", before)

	if diff != nil {
		wg.Wait()
		if err == nil && diffErr == nil && !reflect.DeepEqual(resp, diffResp) {
			report.Inc("diffs")
			report.Inc("diffs.getValuesMulti")
			log.Printf("[DIFF-getValuesMulti] req: %v\n \torig: %v\n\n\tdiff: %v\n", r, resp, diffResp)
		}
	}
}
Exemplo n.º 6
0
// Generate and send a random GetValuesSingle request.
func (l *Load) sendPrefixes(client *gen.HFileServiceClient, diff *gen.HFileServiceClient) {
	var wg sync.WaitGroup

	fullKeys := l.randomKeys()
	prefixes := make([][]byte, len(fullKeys))

	for i, v := range fullKeys {
		prefixes[i] = v[:len(v)/2]
	}
	sort.Sort(util.Keys(prefixes))
	limit := int32(10) // request a max of 10 k/v pairs
	r := &gen.PrefixRequest{HfileName: &l.collection, SortedKeys: prefixes, ValueLimit: &limit}

	var diffResp *gen.PrefixResponse
	var diffErr error
	if diff != nil {
		wg.Add(1)
		go func() {
			defer wg.Done()
			beforeDiff := time.Now()
			diffResp, diffErr = diff.GetValuesForPrefixes(r)
			if diffErr != nil {
				log.Println("[GetValuesForPrefixes] Error fetching diff value:", renderErr(diffErr), util.PrettyKeys(prefixes))
			}
			report.TimeSince(l.diffRtt+".overall", beforeDiff)
			report.TimeSince(l.diffRtt+".getValuesForPrefixes", beforeDiff)
		}()
	}

	before := time.Now()
	resp, err := client.GetValuesForPrefixes(r)
	if err != nil {
		log.Println("[GetValuesForPrefixes] Error fetching value:", renderErr(err), util.PrettyKeys(prefixes))
	}
	report.TimeSince(l.rtt+".overall", before)
	report.TimeSince(l.rtt+".getValuesForPrefixes", before)

	if diff != nil {
		wg.Wait()

		if err == nil && diffErr == nil && !reflect.DeepEqual(resp, diffResp) {
			report.Inc("diffs")
			report.Inc("diffs.getValuesForPrefixes")
			if resp != nil && diffResp != nil {
				log.Printf("[DIFF-GetValuesForPrefixes] req: %v\n", r)

				log.Printf("[DIFF-GetValuesForPrefixes] orig len: %d\n", len(resp.GetValues()))
				log.Printf("[DIFF-GetValuesForPrefixes] diff len: %d\n", len(diffResp.GetValues()))

				log.Printf("[DIFF-GetValuesForPrefixes] orig lastKey: %s\n", hex.EncodeToString(resp.GetLastKey()))
				log.Printf("[DIFF-GetValuesForPrefixes] diff lastKey: %s\n", hex.EncodeToString(diffResp.GetLastKey()))

				a := resp.GetValues()
				b := diffResp.GetValues()
				for k, values := range a {
					if other, ok := b[k]; !ok {
						log.Printf("[DIFF-GetValuesForPrefixes] Missing from diff: %s", hex.EncodeToString([]byte(k)))
					} else if !reflect.DeepEqual(values, other) {
						log.Printf("[DIFF-GetValuesForPrefixes] Different values for: %s", hex.EncodeToString([]byte(k)))
						log.Printf("[DIFF-GetValuesForPrefixes] orig (%d): %s", len(values), util.PrettyKeys(values))
						log.Printf("[DIFF-GetValuesForPrefixes] diff (%d): %s", len(other), util.PrettyKeys(other))
					}
				}
				for k, _ := range b {
					if _, ok := a[k]; !ok {
						log.Printf("[DIFF-GetValuesForPrefixes] Missing from orig: %s", hex.EncodeToString([]byte(k)))
					}
				}
				log.Println("\n")
			} else {
				log.Printf("[DIFF-GetValuesForPrefixes] req: %v\n \torig: %v\n\n\tdiff: %v\n", r, resp, diffResp)
			}
		}
	}
}