1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-02 06:22:31 +03:00

add additional expect to check output

This commit is contained in:
Nedyalko Dyakov
2025-10-27 08:15:41 +02:00
parent da5fe33cdf
commit 471a828ab1
2 changed files with 22 additions and 9 deletions

View File

@@ -127,9 +127,11 @@ func benchmarkHSETOperationsConcurrent(b *testing.B, rdb *redis.Client, ctx cont
// Perform the specified number of HSET operations
wg := sync.WaitGroup{}
wg.Add(operations)
timesCh := make(chan time.Duration, operations)
errCh := make(chan error, operations)
for j := 0; j < operations; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
field := fmt.Sprintf("field_%d", j)
@@ -137,17 +139,26 @@ func benchmarkHSETOperationsConcurrent(b *testing.B, rdb *redis.Client, ctx cont
err := rdb.HSet(ctx, hashKey, field, value).Err()
if err != nil {
b.Fatalf("HSET operation failed: %v", err)
errCh <- err
return
}
timesCh <- time.Since(startTime)
}(j)
}
wg.Wait()
close(timesCh)
close(errCh)
// Check for errors
for err := range errCh {
b.Errorf("HSET operation failed: %v", err)
}
for d := range timesCh {
totalTimes = append(totalTimes, d)
}
}
}
// Stop the timer to calculate metrics
b.StopTimer()
@@ -206,7 +217,7 @@ func BenchmarkHSET_Concurrent(b *testing.B) {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 0,
PoolSize: 1000,
PoolSize: 100,
})
defer rdb.Close()
@@ -220,7 +231,8 @@ func BenchmarkHSET_Concurrent(b *testing.B) {
rdb.FlushDB(ctx)
}()
scales := []int{1, 10, 100, 1000, 10000, 100000}
// Reduced scales to avoid overwhelming the system with too many concurrent goroutines
scales := []int{1, 10, 100, 1000}
for _, scale := range scales {
b.Run(fmt.Sprintf("HSET_%d_operations_concurrent", scale), func(b *testing.B) {

View File

@@ -323,6 +323,7 @@ var _ = Describe("Client", func() {
cn, err = client.Pool().Get(context.Background())
Expect(err).NotTo(HaveOccurred())
Expect(cn).NotTo(BeNil())
Expect(cn.UsedAt().UnixNano()).To(BeNumerically(">", createdAt.UnixNano()))
Expect(cn.UsedAt().After(createdAt)).To(BeTrue())
})