mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
move to go1.24 (#21114)
This commit is contained in:
@@ -46,7 +46,7 @@ func TestCacheCtx(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
cancel() // cancel context to test.
|
||||
|
||||
_, err := cache.GetWithCtx(ctx)
|
||||
@@ -54,7 +54,7 @@ func TestCacheCtx(t *testing.T) {
|
||||
t.Fatalf("expected context.Canceled err, got %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
ctx, cancel = context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
|
||||
t1, err := cache.GetWithCtx(ctx)
|
||||
|
||||
@@ -19,7 +19,6 @@ package openid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -148,7 +147,7 @@ func TestJWTHMACType(t *testing.T) {
|
||||
}
|
||||
|
||||
var claims jwtgo.MapClaims
|
||||
if err = cfg.Validate(context.Background(), DummyRoleARN, token, "", "", claims); err != nil {
|
||||
if err = cfg.Validate(t.Context(), DummyRoleARN, token, "", "", claims); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -200,7 +199,7 @@ func TestJWT(t *testing.T) {
|
||||
}
|
||||
|
||||
var claims jwtgo.MapClaims
|
||||
if err = cfg.Validate(context.Background(), DummyRoleARN, u.Query().Get("Token"), "", "", claims); err == nil {
|
||||
if err = cfg.Validate(t.Context(), DummyRoleARN, u.Query().Get("Token"), "", "", claims); err == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ const (
|
||||
|
||||
func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
drwm1 := NewDRWMutex(ds, "simplelock")
|
||||
ctx1, cancel1 := context.WithCancel(context.Background())
|
||||
ctx1, cancel1 := context.WithCancel(t.Context())
|
||||
if !drwm1.GetRLock(ctx1, cancel1, id, source, Options{Timeout: time.Second}) {
|
||||
panic("Failed to acquire read lock")
|
||||
}
|
||||
// fmt.Println("1st read lock acquired, waiting...")
|
||||
|
||||
drwm2 := NewDRWMutex(ds, "simplelock")
|
||||
ctx2, cancel2 := context.WithCancel(context.Background())
|
||||
ctx2, cancel2 := context.WithCancel(t.Context())
|
||||
if !drwm2.GetRLock(ctx2, cancel2, id, source, Options{Timeout: time.Second}) {
|
||||
panic("Failed to acquire read lock")
|
||||
}
|
||||
@@ -48,25 +48,25 @@ func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
|
||||
go func() {
|
||||
time.Sleep(2 * testDrwMutexAcquireTimeout)
|
||||
drwm1.RUnlock(context.Background())
|
||||
drwm1.RUnlock(t.Context())
|
||||
// fmt.Println("1st read lock released, waiting...")
|
||||
}()
|
||||
|
||||
go func() {
|
||||
time.Sleep(3 * testDrwMutexAcquireTimeout)
|
||||
drwm2.RUnlock(context.Background())
|
||||
drwm2.RUnlock(t.Context())
|
||||
// fmt.Println("2nd read lock released, waiting...")
|
||||
}()
|
||||
|
||||
drwm3 := NewDRWMutex(ds, "simplelock")
|
||||
// fmt.Println("Trying to acquire write lock, waiting...")
|
||||
ctx3, cancel3 := context.WithCancel(context.Background())
|
||||
ctx3, cancel3 := context.WithCancel(t.Context())
|
||||
locked = drwm3.GetLock(ctx3, cancel3, id, source, Options{Timeout: duration})
|
||||
if locked {
|
||||
// fmt.Println("Write lock acquired, waiting...")
|
||||
time.Sleep(testDrwMutexAcquireTimeout)
|
||||
|
||||
drwm3.Unlock(context.Background())
|
||||
drwm3.Unlock(t.Context())
|
||||
}
|
||||
// fmt.Println("Write lock failed due to timeout")
|
||||
return
|
||||
@@ -94,26 +94,26 @@ func testDualWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
drwm1 := NewDRWMutex(ds, "duallock")
|
||||
|
||||
// fmt.Println("Getting initial write lock")
|
||||
ctx1, cancel1 := context.WithCancel(context.Background())
|
||||
ctx1, cancel1 := context.WithCancel(t.Context())
|
||||
if !drwm1.GetLock(ctx1, cancel1, id, source, Options{Timeout: time.Second}) {
|
||||
panic("Failed to acquire initial write lock")
|
||||
}
|
||||
|
||||
go func() {
|
||||
time.Sleep(3 * testDrwMutexAcquireTimeout)
|
||||
drwm1.Unlock(context.Background())
|
||||
drwm1.Unlock(t.Context())
|
||||
// fmt.Println("Initial write lock released, waiting...")
|
||||
}()
|
||||
|
||||
// fmt.Println("Trying to acquire 2nd write lock, waiting...")
|
||||
drwm2 := NewDRWMutex(ds, "duallock")
|
||||
ctx2, cancel2 := context.WithCancel(context.Background())
|
||||
ctx2, cancel2 := context.WithCancel(t.Context())
|
||||
locked = drwm2.GetLock(ctx2, cancel2, id, source, Options{Timeout: duration})
|
||||
if locked {
|
||||
// fmt.Println("2nd write lock acquired, waiting...")
|
||||
time.Sleep(testDrwMutexAcquireTimeout)
|
||||
|
||||
drwm2.Unlock(context.Background())
|
||||
drwm2.Unlock(t.Context())
|
||||
}
|
||||
// fmt.Println("2nd write lock failed due to timeout")
|
||||
return
|
||||
@@ -268,7 +268,7 @@ func TestUnlockPanic(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
mu := NewDRWMutex(ds, "test")
|
||||
mu.Unlock(context.Background())
|
||||
mu.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Borrowed from rwmutex_test.go
|
||||
@@ -278,10 +278,10 @@ func TestUnlockPanic2(t *testing.T) {
|
||||
if recover() == nil {
|
||||
t.Fatalf("unlock of unlocked RWMutex did not panic")
|
||||
}
|
||||
mu.RUnlock(context.Background()) // Unlock, so -test.count > 1 works
|
||||
mu.RUnlock(t.Context()) // Unlock, so -test.count > 1 works
|
||||
}()
|
||||
mu.RLock(id, source)
|
||||
mu.Unlock(context.Background())
|
||||
mu.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Borrowed from rwmutex_test.go
|
||||
@@ -292,7 +292,7 @@ func TestRUnlockPanic(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
mu := NewDRWMutex(ds, "test")
|
||||
mu.RUnlock(context.Background())
|
||||
mu.RUnlock(t.Context())
|
||||
}
|
||||
|
||||
// Borrowed from rwmutex_test.go
|
||||
@@ -302,10 +302,10 @@ func TestRUnlockPanic2(t *testing.T) {
|
||||
if recover() == nil {
|
||||
t.Fatalf("read unlock of unlocked RWMutex did not panic")
|
||||
}
|
||||
mu.Unlock(context.Background()) // Unlock, so -test.count > 1 works
|
||||
mu.Unlock(t.Context()) // Unlock, so -test.count > 1 works
|
||||
}()
|
||||
mu.Lock(id, source)
|
||||
mu.RUnlock(context.Background())
|
||||
mu.RUnlock(t.Context())
|
||||
}
|
||||
|
||||
// Borrowed from rwmutex_test.go
|
||||
@@ -320,14 +320,14 @@ func benchmarkRWMutex(b *testing.B, localWork, writeRatio int) {
|
||||
foo++
|
||||
if foo%writeRatio == 0 {
|
||||
rwm.Lock(id, source)
|
||||
rwm.Unlock(context.Background())
|
||||
rwm.Unlock(b.Context())
|
||||
} else {
|
||||
rwm.RLock(id, source)
|
||||
for i := 0; i != localWork; i++ {
|
||||
foo *= 2
|
||||
foo /= 2
|
||||
}
|
||||
rwm.RUnlock(context.Background())
|
||||
rwm.RUnlock(b.Context())
|
||||
}
|
||||
}
|
||||
_ = foo
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestSimpleLock(t *testing.T) {
|
||||
// fmt.Println("Lock acquired, waiting...")
|
||||
time.Sleep(testDrwMutexRefreshCallTimeout)
|
||||
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
}
|
||||
|
||||
func TestSimpleLockUnlockMultipleTimes(t *testing.T) {
|
||||
@@ -77,23 +77,23 @@ func TestSimpleLockUnlockMultipleTimes(t *testing.T) {
|
||||
|
||||
dm.Lock(id, source)
|
||||
time.Sleep(time.Duration(10+(rand.Float32()*50)) * time.Millisecond)
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
|
||||
dm.Lock(id, source)
|
||||
time.Sleep(time.Duration(10+(rand.Float32()*50)) * time.Millisecond)
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
|
||||
dm.Lock(id, source)
|
||||
time.Sleep(time.Duration(10+(rand.Float32()*50)) * time.Millisecond)
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
|
||||
dm.Lock(id, source)
|
||||
time.Sleep(time.Duration(10+(rand.Float32()*50)) * time.Millisecond)
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
|
||||
dm.Lock(id, source)
|
||||
time.Sleep(time.Duration(10+(rand.Float32()*50)) * time.Millisecond)
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Test two locks for same resource, one succeeds, one fails (after timeout)
|
||||
@@ -108,7 +108,7 @@ func TestTwoSimultaneousLocksForSameResource(t *testing.T) {
|
||||
time.Sleep(5 * testDrwMutexAcquireTimeout)
|
||||
// fmt.Println("Unlocking dm1")
|
||||
|
||||
dm1st.Unlock(context.Background())
|
||||
dm1st.Unlock(t.Context())
|
||||
}()
|
||||
|
||||
dm2nd.Lock(id, source)
|
||||
@@ -116,7 +116,7 @@ func TestTwoSimultaneousLocksForSameResource(t *testing.T) {
|
||||
// fmt.Printf("2nd lock obtained after 1st lock is released\n")
|
||||
time.Sleep(testDrwMutexRefreshCallTimeout * 2)
|
||||
|
||||
dm2nd.Unlock(context.Background())
|
||||
dm2nd.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Test three locks for same resource, one succeeds, one fails (after timeout)
|
||||
@@ -134,7 +134,7 @@ func TestThreeSimultaneousLocksForSameResource(t *testing.T) {
|
||||
time.Sleep(2 * testDrwMutexAcquireTimeout)
|
||||
// fmt.Println("Unlocking dm1")
|
||||
|
||||
dm1st.Unlock(context.Background())
|
||||
dm1st.Unlock(t.Context())
|
||||
}()
|
||||
expect += 2 * testDrwMutexAcquireTimeout
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestThreeSimultaneousLocksForSameResource(t *testing.T) {
|
||||
time.Sleep(2 * testDrwMutexAcquireTimeout)
|
||||
// fmt.Println("Unlocking dm2")
|
||||
|
||||
dm2nd.Unlock(context.Background())
|
||||
dm2nd.Unlock(t.Context())
|
||||
}()
|
||||
|
||||
dm3rd.Lock(id, source)
|
||||
@@ -159,7 +159,7 @@ func TestThreeSimultaneousLocksForSameResource(t *testing.T) {
|
||||
// fmt.Printf("3rd lock obtained after 1st & 2nd locks are released\n")
|
||||
time.Sleep(testDrwMutexRefreshCallTimeout)
|
||||
|
||||
dm3rd.Unlock(context.Background())
|
||||
dm3rd.Unlock(t.Context())
|
||||
}()
|
||||
expect += 2*testDrwMutexAcquireTimeout + testDrwMutexRefreshCallTimeout
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestThreeSimultaneousLocksForSameResource(t *testing.T) {
|
||||
time.Sleep(2 * testDrwMutexAcquireTimeout)
|
||||
// fmt.Println("Unlocking dm3")
|
||||
|
||||
dm3rd.Unlock(context.Background())
|
||||
dm3rd.Unlock(t.Context())
|
||||
}()
|
||||
|
||||
dm2nd.Lock(id, source)
|
||||
@@ -181,7 +181,7 @@ func TestThreeSimultaneousLocksForSameResource(t *testing.T) {
|
||||
// fmt.Printf("2nd lock obtained after 1st & 3rd locks are released\n")
|
||||
time.Sleep(testDrwMutexRefreshCallTimeout)
|
||||
|
||||
dm2nd.Unlock(context.Background())
|
||||
dm2nd.Unlock(t.Context())
|
||||
}()
|
||||
expect += 2*testDrwMutexAcquireTimeout + testDrwMutexRefreshCallTimeout
|
||||
|
||||
@@ -201,8 +201,8 @@ func TestTwoSimultaneousLocksForDifferentResources(t *testing.T) {
|
||||
|
||||
dm1.Lock(id, source)
|
||||
dm2.Lock(id, source)
|
||||
dm1.Unlock(context.Background())
|
||||
dm2.Unlock(context.Background())
|
||||
dm1.Unlock(t.Context())
|
||||
dm2.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Test refreshing lock - refresh should always return true
|
||||
@@ -214,7 +214,7 @@ func TestSuccessfulLockRefresh(t *testing.T) {
|
||||
dm := NewDRWMutex(ds, "aap")
|
||||
dm.refreshInterval = testDrwMutexRefreshInterval
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
|
||||
if !dm.GetLock(ctx, cancel, id, source, Options{Timeout: 5 * time.Minute}) {
|
||||
t.Fatal("GetLock() should be successful")
|
||||
@@ -230,7 +230,7 @@ func TestSuccessfulLockRefresh(t *testing.T) {
|
||||
}
|
||||
|
||||
// Should be safe operation in all cases
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Test canceling context while quorum servers report lock not found
|
||||
@@ -250,7 +250,7 @@ func TestFailedRefreshLock(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
ctx, cl := context.WithCancel(context.Background())
|
||||
ctx, cl := context.WithCancel(t.Context())
|
||||
cancel := func() {
|
||||
cl()
|
||||
wg.Done()
|
||||
@@ -267,7 +267,7 @@ func TestFailedRefreshLock(t *testing.T) {
|
||||
}
|
||||
|
||||
// Should be safe operation in all cases
|
||||
dm.Unlock(context.Background())
|
||||
dm.Unlock(t.Context())
|
||||
}
|
||||
|
||||
// Test Unlock should not timeout
|
||||
@@ -278,7 +278,7 @@ func TestUnlockShouldNotTimeout(t *testing.T) {
|
||||
|
||||
dm := NewDRWMutex(ds, "aap")
|
||||
dm.refreshInterval = testDrwMutexUnlockCallTimeout
|
||||
if !dm.GetLock(context.Background(), nil, id, source, Options{Timeout: 5 * time.Minute}) {
|
||||
if !dm.GetLock(t.Context(), nil, id, source, Options{Timeout: 5 * time.Minute}) {
|
||||
t.Fatal("GetLock() should be successful")
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ func TestUnlockShouldNotTimeout(t *testing.T) {
|
||||
|
||||
unlockReturned := make(chan struct{}, 1)
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
dm.Unlock(ctx)
|
||||
// Unlock is not blocking. Try to get a new lock.
|
||||
@@ -344,7 +344,7 @@ func BenchmarkMutexUncontended(b *testing.B) {
|
||||
mu := PaddedMutex{NewDRWMutex(ds, "")}
|
||||
for pb.Next() {
|
||||
mu.Lock(id, source)
|
||||
mu.Unlock(context.Background())
|
||||
mu.Unlock(b.Context())
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -361,7 +361,7 @@ func benchmarkMutex(b *testing.B, slack, work bool) {
|
||||
foo := 0
|
||||
for pb.Next() {
|
||||
mu.Lock(id, source)
|
||||
mu.Unlock(context.Background())
|
||||
mu.Unlock(b.Context())
|
||||
if work {
|
||||
for i := 0; i < 100; i++ {
|
||||
foo *= 2
|
||||
@@ -410,7 +410,7 @@ func BenchmarkMutexNoSpin(b *testing.B) {
|
||||
m.Lock(id, source)
|
||||
acc0 -= 100
|
||||
acc1 += 100
|
||||
m.Unlock(context.Background())
|
||||
m.Unlock(b.Context())
|
||||
} else {
|
||||
for i := 0; i < len(data); i += 4 {
|
||||
data[i]++
|
||||
@@ -442,7 +442,7 @@ func BenchmarkMutexSpin(b *testing.B) {
|
||||
m.Lock(id, source)
|
||||
acc0 -= 100
|
||||
acc1 += 100
|
||||
m.Unlock(context.Background())
|
||||
m.Unlock(b.Context())
|
||||
for i := 0; i < len(data); i += 4 {
|
||||
data[i]++
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package etag
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -138,7 +137,7 @@ var readerTests = []struct { // Reference values computed by: echo <content> | m
|
||||
|
||||
func TestReader(t *testing.T) {
|
||||
for i, test := range readerTests {
|
||||
reader := NewReader(context.Background(), strings.NewReader(test.Content), test.ETag, nil)
|
||||
reader := NewReader(t.Context(), strings.NewReader(test.Content), test.ETag, nil)
|
||||
if _, err := io.Copy(io.Discard, reader); err != nil {
|
||||
t.Fatalf("Test %d: read failed: %v", i, err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -252,9 +251,9 @@ func TestQueueValidate(t *testing.T) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targetList1 := NewTargetList(context.Background())
|
||||
targetList1 := NewTargetList(t.Context())
|
||||
|
||||
targetList2 := NewTargetList(context.Background())
|
||||
targetList2 := NewTargetList(t.Context())
|
||||
if err := targetList2.Add(&ExampleTarget{TargetID{"1", "webhook"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -596,9 +595,9 @@ func TestConfigValidate(t *testing.T) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targetList1 := NewTargetList(context.Background())
|
||||
targetList1 := NewTargetList(t.Context())
|
||||
|
||||
targetList2 := NewTargetList(context.Background())
|
||||
targetList2 := NewTargetList(t.Context())
|
||||
if err := targetList2.Add(&ExampleTarget{TargetID{"1", "webhook"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -928,9 +927,9 @@ func TestParseConfig(t *testing.T) {
|
||||
</NotificationConfiguration>
|
||||
`)
|
||||
|
||||
targetList1 := NewTargetList(context.Background())
|
||||
targetList1 := NewTargetList(t.Context())
|
||||
|
||||
targetList2 := NewTargetList(context.Background())
|
||||
targetList2 := NewTargetList(t.Context())
|
||||
if err := targetList2.Add(&ExampleTarget{TargetID{"1", "webhook"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"reflect"
|
||||
@@ -86,14 +85,14 @@ func (target ExampleTarget) FlushQueueStore() error {
|
||||
}
|
||||
|
||||
func TestTargetListAdd(t *testing.T) {
|
||||
targetListCase1 := NewTargetList(context.Background())
|
||||
targetListCase1 := NewTargetList(t.Context())
|
||||
|
||||
targetListCase2 := NewTargetList(context.Background())
|
||||
targetListCase2 := NewTargetList(t.Context())
|
||||
if err := targetListCase2.Add(&ExampleTarget{TargetID{"2", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targetListCase3 := NewTargetList(context.Background())
|
||||
targetListCase3 := NewTargetList(t.Context())
|
||||
if err := targetListCase3.Add(&ExampleTarget{TargetID{"3", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -141,14 +140,14 @@ func TestTargetListAdd(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTargetListExists(t *testing.T) {
|
||||
targetListCase1 := NewTargetList(context.Background())
|
||||
targetListCase1 := NewTargetList(t.Context())
|
||||
|
||||
targetListCase2 := NewTargetList(context.Background())
|
||||
targetListCase2 := NewTargetList(t.Context())
|
||||
if err := targetListCase2.Add(&ExampleTarget{TargetID{"2", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targetListCase3 := NewTargetList(context.Background())
|
||||
targetListCase3 := NewTargetList(t.Context())
|
||||
if err := targetListCase3.Add(&ExampleTarget{TargetID{"3", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -173,14 +172,14 @@ func TestTargetListExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTargetListList(t *testing.T) {
|
||||
targetListCase1 := NewTargetList(context.Background())
|
||||
targetListCase1 := NewTargetList(t.Context())
|
||||
|
||||
targetListCase2 := NewTargetList(context.Background())
|
||||
targetListCase2 := NewTargetList(t.Context())
|
||||
if err := targetListCase2.Add(&ExampleTarget{TargetID{"2", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
targetListCase3 := NewTargetList(context.Background())
|
||||
targetListCase3 := NewTargetList(t.Context())
|
||||
if err := targetListCase3.Add(&ExampleTarget{TargetID{"3", "testcase"}, false, false}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -220,7 +219,7 @@ func TestTargetListList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewTargetList(t *testing.T) {
|
||||
if result := NewTargetList(context.Background()); result == nil {
|
||||
if result := NewTargetList(t.Context()); result == nil {
|
||||
t.Fatalf("test: result: expected: <non-nil>, got: <nil>")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func benchmarkGridRequests(b *testing.B, n int) {
|
||||
for par := 1; par <= 32; par *= 2 {
|
||||
b.Run("par="+strconv.Itoa(par*runtime.GOMAXPROCS(0)), func(b *testing.B) {
|
||||
defer timeout(60 * time.Second)()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(b.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
b.ReportAllocs()
|
||||
b.SetBytes(int64(len(payload) * 2))
|
||||
@@ -135,7 +135,7 @@ func benchmarkGridRequests(b *testing.B, n int) {
|
||||
for par := 1; par <= 32; par *= 2 {
|
||||
b.Run("par="+strconv.Itoa(par*runtime.GOMAXPROCS(0)), func(b *testing.B) {
|
||||
defer timeout(60 * time.Second)()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(b.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
@@ -285,7 +285,7 @@ func benchmarkGridStreamRespOnly(b *testing.B, n int) {
|
||||
if conn == nil {
|
||||
b.Fatal("No connection")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(b.Context(), 30*time.Second)
|
||||
// Send the payload.
|
||||
t := time.Now()
|
||||
st, err := conn.NewStream(ctx, handlerTest, payload)
|
||||
@@ -396,7 +396,7 @@ func benchmarkGridStreamReqOnly(b *testing.B, n int) {
|
||||
if conn == nil {
|
||||
b.Fatal("No connection")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(b.Context(), 30*time.Second)
|
||||
// Send the payload.
|
||||
t := time.Now()
|
||||
st, err := conn.NewStream(ctx, handlerTest, payload)
|
||||
@@ -512,7 +512,7 @@ func benchmarkGridStreamTwoway(b *testing.B, n int) {
|
||||
if conn == nil {
|
||||
b.Fatal("No connection")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
ctx, cancel := context.WithTimeout(b.Context(), 30*time.Second)
|
||||
// Send the payload.
|
||||
t := time.Now()
|
||||
st, err := conn.NewStream(ctx, handlerTest, payload)
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestDisconnect(t *testing.T) {
|
||||
// We fake a local and remote server.
|
||||
localHost := hosts[0]
|
||||
remoteHost := hosts[1]
|
||||
local, err := NewManager(context.Background(), ManagerOptions{
|
||||
local, err := NewManager(t.Context(), ManagerOptions{
|
||||
Dialer: ConnectWS(dialer.DialContext,
|
||||
dummyNewToken,
|
||||
nil),
|
||||
@@ -75,7 +75,7 @@ func TestDisconnect(t *testing.T) {
|
||||
return nil, &err
|
||||
}))
|
||||
|
||||
remote, err := NewManager(context.Background(), ManagerOptions{
|
||||
remote, err := NewManager(t.Context(), ManagerOptions{
|
||||
Dialer: ConnectWS(dialer.DialContext,
|
||||
dummyNewToken,
|
||||
nil),
|
||||
@@ -131,14 +131,14 @@ func TestDisconnect(t *testing.T) {
|
||||
|
||||
// local to remote
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
errFatal(remoteConn.WaitForConnect(context.Background()))
|
||||
errFatal(remoteConn.WaitForConnect(t.Context()))
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
gotResp := make(chan struct{})
|
||||
go func() {
|
||||
start := time.Now()
|
||||
t.Log("Roundtrip: sending request")
|
||||
resp, err := remoteConn.Request(context.Background(), handlerTest, []byte(testPayload))
|
||||
resp, err := remoteConn.Request(t.Context(), handlerTest, []byte(testPayload))
|
||||
t.Log("Roundtrip:", time.Since(start), resp, err)
|
||||
gotResp <- struct{}{}
|
||||
}()
|
||||
@@ -148,9 +148,9 @@ func TestDisconnect(t *testing.T) {
|
||||
<-gotResp
|
||||
|
||||
// Must reconnect
|
||||
errFatal(remoteConn.WaitForConnect(context.Background()))
|
||||
errFatal(remoteConn.WaitForConnect(t.Context()))
|
||||
|
||||
stream, err := remoteConn.NewStream(context.Background(), handlerTest2, []byte(testPayload))
|
||||
stream, err := remoteConn.NewStream(t.Context(), handlerTest2, []byte(testPayload))
|
||||
errFatal(err)
|
||||
go func() {
|
||||
for resp := range stream.responses {
|
||||
@@ -162,7 +162,7 @@ func TestDisconnect(t *testing.T) {
|
||||
<-gotCall
|
||||
remote.debugMsg(debugKillOutbound)
|
||||
local.debugMsg(debugKillOutbound)
|
||||
errFatal(remoteConn.WaitForConnect(context.Background()))
|
||||
errFatal(remoteConn.WaitForConnect(t.Context()))
|
||||
|
||||
<-gotResp
|
||||
// Killing should cancel the context on the request.
|
||||
|
||||
@@ -74,14 +74,14 @@ func TestSingleRoundtrip(t *testing.T) {
|
||||
|
||||
// local to remote
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
remoteConn.WaitForConnect(context.Background())
|
||||
remoteConn.WaitForConnect(t.Context())
|
||||
defer testlogger.T.SetErrorTB(t)()
|
||||
|
||||
t.Run("localToRemote", func(t *testing.T) {
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
start := time.Now()
|
||||
resp, err := remoteConn.Request(context.Background(), handlerTest, []byte(testPayload))
|
||||
resp, err := remoteConn.Request(t.Context(), handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
if string(resp) != testPayload {
|
||||
t.Errorf("want %q, got %q", testPayload, string(resp))
|
||||
@@ -92,7 +92,7 @@ func TestSingleRoundtrip(t *testing.T) {
|
||||
t.Run("localToRemoteErr", func(t *testing.T) {
|
||||
const testPayload = "Hello Grid World!"
|
||||
start := time.Now()
|
||||
resp, err := remoteConn.Request(context.Background(), handlerTest2, []byte(testPayload))
|
||||
resp, err := remoteConn.Request(t.Context(), handlerTest2, []byte(testPayload))
|
||||
t.Log("Roundtrip:", time.Since(start))
|
||||
if len(resp) != 0 {
|
||||
t.Errorf("want nil, got %q", string(resp))
|
||||
@@ -107,7 +107,7 @@ func TestSingleRoundtrip(t *testing.T) {
|
||||
testPayload := bytes.Repeat([]byte("?"), 1<<20)
|
||||
|
||||
start := time.Now()
|
||||
resp, err := remoteConn.Request(context.Background(), handlerTest, testPayload)
|
||||
resp, err := remoteConn.Request(t.Context(), handlerTest, testPayload)
|
||||
errFatal(err)
|
||||
if string(resp) != string(testPayload) {
|
||||
t.Errorf("want %q, got %q", testPayload, string(resp))
|
||||
@@ -119,7 +119,7 @@ func TestSingleRoundtrip(t *testing.T) {
|
||||
testPayload := bytes.Repeat([]byte("!"), 1<<10)
|
||||
|
||||
start := time.Now()
|
||||
resp, err := remoteConn.Request(context.Background(), handlerTest2, testPayload)
|
||||
resp, err := remoteConn.Request(t.Context(), handlerTest2, testPayload)
|
||||
if len(resp) != 0 {
|
||||
t.Errorf("want nil, got %q", string(resp))
|
||||
}
|
||||
@@ -159,19 +159,19 @@ func TestSingleRoundtripNotReady(t *testing.T) {
|
||||
|
||||
// local to remote
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
remoteConn.WaitForConnect(context.Background())
|
||||
remoteConn.WaitForConnect(t.Context())
|
||||
defer testlogger.T.SetErrorTB(t)()
|
||||
|
||||
t.Run("localToRemote", func(t *testing.T) {
|
||||
const testPayload = "Hello Grid World!"
|
||||
// Single requests should have remote errors.
|
||||
_, err := remoteConn.Request(context.Background(), handlerTest, []byte(testPayload))
|
||||
_, err := remoteConn.Request(t.Context(), handlerTest, []byte(testPayload))
|
||||
if _, ok := err.(*RemoteErr); !ok {
|
||||
t.Fatalf("Unexpected error: %v, %T", err, err)
|
||||
}
|
||||
// Streams should not be able to set up until registered.
|
||||
// Thus, the error is a local error.
|
||||
_, err = remoteConn.NewStream(context.Background(), handlerTest, []byte(testPayload))
|
||||
_, err = remoteConn.NewStream(t.Context(), handlerTest, []byte(testPayload))
|
||||
if !errors.Is(err, ErrUnknownHandler) {
|
||||
t.Fatalf("Unexpected error: %v, %T", err, err)
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func TestSingleRoundtripGenerics(t *testing.T) {
|
||||
|
||||
start := time.Now()
|
||||
req := testRequest{Num: 1, String: testPayload}
|
||||
resp, err := h1.Call(context.Background(), remoteConn, &req)
|
||||
resp, err := h1.Call(t.Context(), remoteConn, &req)
|
||||
errFatal(err)
|
||||
if resp.OrgString != testPayload {
|
||||
t.Errorf("want %q, got %q", testPayload, resp.OrgString)
|
||||
@@ -235,7 +235,7 @@ func TestSingleRoundtripGenerics(t *testing.T) {
|
||||
h1.PutResponse(resp)
|
||||
|
||||
start = time.Now()
|
||||
resp, err = h2.Call(context.Background(), remoteConn, &testRequest{Num: 1, String: testPayload})
|
||||
resp, err = h2.Call(t.Context(), remoteConn, &testRequest{Num: 1, String: testPayload})
|
||||
t.Log("Roundtrip:", time.Since(start))
|
||||
if err != RemoteErr(testPayload) {
|
||||
t.Errorf("want error %v(%T), got %v(%T)", RemoteErr(testPayload), RemoteErr(testPayload), err, err)
|
||||
@@ -290,7 +290,7 @@ func TestSingleRoundtripGenericsRecycle(t *testing.T) {
|
||||
|
||||
start := time.Now()
|
||||
req := NewMSSWith(map[string]string{"test": testPayload})
|
||||
resp, err := h1.Call(context.Background(), remoteConn, req)
|
||||
resp, err := h1.Call(t.Context(), remoteConn, req)
|
||||
errFatal(err)
|
||||
if resp.Get("test") != testPayload {
|
||||
t.Errorf("want %q, got %q", testPayload, resp.Get("test"))
|
||||
@@ -299,7 +299,7 @@ func TestSingleRoundtripGenericsRecycle(t *testing.T) {
|
||||
h1.PutResponse(resp)
|
||||
|
||||
start = time.Now()
|
||||
resp, err = h2.Call(context.Background(), remoteConn, NewMSSWith(map[string]string{"err": testPayload}))
|
||||
resp, err = h2.Call(t.Context(), remoteConn, NewMSSWith(map[string]string{"err": testPayload}))
|
||||
t.Log("Roundtrip:", time.Since(start))
|
||||
if err != RemoteErr(testPayload) {
|
||||
t.Errorf("want error %v(%T), got %v(%T)", RemoteErr(testPayload), RemoteErr(testPayload), err, err)
|
||||
@@ -479,7 +479,7 @@ func testStreamRoundtrip(t *testing.T, local, remote *Manager) {
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
start := time.Now()
|
||||
stream, err := remoteConn.NewStream(context.Background(), handlerTest, []byte(testPayload))
|
||||
stream, err := remoteConn.NewStream(t.Context(), handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
var n int
|
||||
stream.Requests <- []byte(strconv.Itoa(n))
|
||||
@@ -544,7 +544,7 @@ func testStreamCancel(t *testing.T, local, remote *Manager) {
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
st, err := remoteConn.NewStream(ctx, handler, []byte(testPayload))
|
||||
errFatal(err)
|
||||
clientCanceled := make(chan time.Time, 1)
|
||||
@@ -659,7 +659,7 @@ func testStreamDeadline(t *testing.T, local, remote *Manager) {
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), wantDL)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), wantDL)
|
||||
defer cancel()
|
||||
st, err := remoteConn.NewStream(ctx, handler, []byte(testPayload))
|
||||
errFatal(err)
|
||||
@@ -735,7 +735,7 @@ func testServerOutCongestion(t *testing.T, local, remote *Manager) {
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
|
||||
defer cancel()
|
||||
st, err := remoteConn.NewStream(ctx, handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
@@ -813,7 +813,7 @@ func testServerInCongestion(t *testing.T, local, remote *Manager) {
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
|
||||
defer cancel()
|
||||
st, err := remoteConn.NewStream(ctx, handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
@@ -893,7 +893,7 @@ func testGenericsStreamRoundtrip(t *testing.T, local, remote *Manager) {
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
start := time.Now()
|
||||
stream, err := handler.Call(context.Background(), remoteConn, &testRequest{Num: 1, String: testPayload})
|
||||
stream, err := handler.Call(t.Context(), remoteConn, &testRequest{Num: 1, String: testPayload})
|
||||
errFatal(err)
|
||||
go func() {
|
||||
defer close(stream.Requests)
|
||||
@@ -970,7 +970,7 @@ func testGenericsStreamRoundtripSubroute(t *testing.T, local, remote *Manager) {
|
||||
remoteSub := remoteConn.Subroute(strings.Join([]string{"subroute", "1"}, "/"))
|
||||
|
||||
start := time.Now()
|
||||
stream, err := handler.Call(context.Background(), remoteSub, &testRequest{Num: 1, String: testPayload})
|
||||
stream, err := handler.Call(t.Context(), remoteSub, &testRequest{Num: 1, String: testPayload})
|
||||
errFatal(err)
|
||||
go func() {
|
||||
defer close(stream.Requests)
|
||||
@@ -1043,7 +1043,7 @@ func testServerStreamResponseBlocked(t *testing.T, local, remote *Manager) {
|
||||
remoteConn := local.Connection(remoteHost)
|
||||
const testPayload = "Hello Grid World!"
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
|
||||
|
||||
st, err := remoteConn.NewStream(ctx, handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
@@ -1125,7 +1125,7 @@ func testServerStreamNoPing(t *testing.T, local, remote *Manager, inCap int) {
|
||||
remoteConn.debugMsg(debugSetClientPingDuration, 100*time.Millisecond)
|
||||
defer remoteConn.debugMsg(debugSetClientPingDuration, clientPingInterval)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
|
||||
defer cancel()
|
||||
st, err := remoteConn.NewStream(ctx, handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
@@ -1198,7 +1198,7 @@ func testServerStreamPingRunning(t *testing.T, local, remote *Manager, inCap int
|
||||
remoteConn.debugMsg(debugSetClientPingDuration, 100*time.Millisecond)
|
||||
defer remoteConn.debugMsg(debugSetClientPingDuration, clientPingInterval)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
|
||||
defer cancel()
|
||||
st, err := remoteConn.NewStream(ctx, handlerTest, []byte(testPayload))
|
||||
errFatal(err)
|
||||
|
||||
@@ -19,7 +19,6 @@ package hash
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@@ -31,7 +30,7 @@ import (
|
||||
|
||||
// Tests functions like Size(), MD5*(), SHA256*()
|
||||
func TestHashReaderHelperMethods(t *testing.T) {
|
||||
r, err := NewReader(context.Background(), bytes.NewReader([]byte("abcd")), 4, "e2fc714c4727ee9395f324cd2e7f331f", "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589", 4)
|
||||
r, err := NewReader(t.Context(), bytes.NewReader([]byte("abcd")), 4, "e2fc714c4727ee9395f324cd2e7f331f", "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589", 4)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -195,7 +194,7 @@ func TestHashReaderVerification(t *testing.T) {
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
t.Run(fmt.Sprintf("case-%d", i+1), func(t *testing.T) {
|
||||
r, err := NewReader(context.Background(), testCase.src, testCase.size, testCase.md5hex, testCase.sha256hex, testCase.actualSize)
|
||||
r, err := NewReader(t.Context(), testCase.src, testCase.size, testCase.md5hex, testCase.sha256hex, testCase.actualSize)
|
||||
if err != nil {
|
||||
t.Fatalf("Test %q: Initializing reader failed %s", testCase.desc, err)
|
||||
}
|
||||
@@ -214,7 +213,7 @@ func TestHashReaderVerification(t *testing.T) {
|
||||
}
|
||||
|
||||
func mustReader(t *testing.T, src io.Reader, size int64, md5Hex, sha256Hex string, actualSize int64) *Reader {
|
||||
r, err := NewReader(context.Background(), src, size, md5Hex, sha256Hex, actualSize)
|
||||
r, err := NewReader(t.Context(), src, size, md5Hex, sha256Hex, actualSize)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -304,7 +303,7 @@ func TestHashReaderInvalidArguments(t *testing.T) {
|
||||
|
||||
for i, testCase := range testCases {
|
||||
t.Run(fmt.Sprintf("case-%d", i+1), func(t *testing.T) {
|
||||
_, err := NewReader(context.Background(), testCase.src, testCase.size, testCase.md5hex, testCase.sha256hex, testCase.actualSize)
|
||||
_, err := NewReader(t.Context(), testCase.src, testCase.size, testCase.md5hex, testCase.sha256hex, testCase.actualSize)
|
||||
if err != nil && testCase.success {
|
||||
t.Errorf("Test %q: Expected success, but got error %s instead", testCase.desc, err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"runtime"
|
||||
@@ -153,7 +152,7 @@ func TestNewHTTPListener(t *testing.T) {
|
||||
}
|
||||
|
||||
for testIdx, testCase := range testCases {
|
||||
listener, listenErrs := newHTTPListener(context.Background(),
|
||||
listener, listenErrs := newHTTPListener(t.Context(),
|
||||
testCase.serverAddrs,
|
||||
TCPOptions{},
|
||||
)
|
||||
@@ -192,7 +191,7 @@ func TestHTTPListenerStartClose(t *testing.T) {
|
||||
|
||||
nextTest:
|
||||
for i, testCase := range testCases {
|
||||
listener, errs := newHTTPListener(context.Background(),
|
||||
listener, errs := newHTTPListener(t.Context(),
|
||||
testCase.serverAddrs,
|
||||
TCPOptions{},
|
||||
)
|
||||
@@ -246,7 +245,7 @@ func TestHTTPListenerAddr(t *testing.T) {
|
||||
|
||||
nextTest:
|
||||
for i, testCase := range testCases {
|
||||
listener, errs := newHTTPListener(context.Background(),
|
||||
listener, errs := newHTTPListener(t.Context(),
|
||||
testCase.serverAddrs,
|
||||
TCPOptions{},
|
||||
)
|
||||
@@ -297,7 +296,7 @@ func TestHTTPListenerAddrs(t *testing.T) {
|
||||
|
||||
nextTest:
|
||||
for i, testCase := range testCases {
|
||||
listener, errs := newHTTPListener(context.Background(),
|
||||
listener, errs := newHTTPListener(t.Context(),
|
||||
testCase.serverAddrs,
|
||||
TCPOptions{},
|
||||
)
|
||||
|
||||
@@ -19,7 +19,6 @@ package kms
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
)
|
||||
@@ -30,11 +29,11 @@ func TestSingleKeyRoundtrip(t *testing.T) {
|
||||
t.Fatalf("Failed to initialize KMS: %v", err)
|
||||
}
|
||||
|
||||
key, err := KMS.GenerateKey(context.Background(), &GenerateKeyRequest{Name: "my-key"})
|
||||
key, err := KMS.GenerateKey(t.Context(), &GenerateKeyRequest{Name: "my-key"})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to generate key: %v", err)
|
||||
}
|
||||
plaintext, err := KMS.Decrypt(context.TODO(), &DecryptRequest{
|
||||
plaintext, err := KMS.Decrypt(t.Context(), &DecryptRequest{
|
||||
Name: key.KeyID,
|
||||
Ciphertext: key.Ciphertext,
|
||||
})
|
||||
@@ -57,7 +56,7 @@ func TestDecryptKey(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Test %d: failed to decode plaintext key: %v", i, err)
|
||||
}
|
||||
plaintext, err := KMS.Decrypt(context.TODO(), &DecryptRequest{
|
||||
plaintext, err := KMS.Decrypt(t.Context(), &DecryptRequest{
|
||||
Name: test.KeyID,
|
||||
Ciphertext: []byte(test.Ciphertext),
|
||||
AssociatedData: test.Context,
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
lrwm := NewLRWMutex()
|
||||
|
||||
if !lrwm.GetRLock(ctx, "", "object1", time.Second) {
|
||||
@@ -87,7 +87,7 @@ func TestSimpleWriteLockTimedOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func testDualWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
lrwm := NewLRWMutex()
|
||||
|
||||
// fmt.Println("Getting initial write lock")
|
||||
|
||||
Reference in New Issue
Block a user