aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-09-25 13:49:28 -0700
committerchrislu <chris.lu@gmail.com>2022-09-25 13:49:28 -0700
commitcc570a4477a791312355dfd325a49bd276522997 (patch)
tree13bbe64021274c98a2c308c51ea78de3ac35bda8
parent5c8f1467a1c2e6db6025f387d779ecec222fb9b5 (diff)
downloadseaweedfs-cc570a4477a791312355dfd325a49bd276522997.tar.xz
seaweedfs-cc570a4477a791312355dfd325a49bd276522997.zip
assert results are sorted
-rw-r--r--weed/util/limited_async_pool_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/weed/util/limited_async_pool_test.go b/weed/util/limited_async_pool_test.go
index 29a3d0498..935b158da 100644
--- a/weed/util/limited_async_pool_test.go
+++ b/weed/util/limited_async_pool_test.go
@@ -2,6 +2,8 @@ package util
import (
"fmt"
+ "github.com/stretchr/testify/assert"
+ "sort"
"testing"
"time"
)
@@ -16,43 +18,46 @@ func TestAsyncPool(t *testing.T) {
results = append(results, p.Execute(FourthFunc))
results = append(results, p.Execute(FifthFunc))
+ var sorted_results []int
for _, r := range results {
x := r.Await().(int)
println(x)
+ sorted_results = append(sorted_results, x)
}
+ assert.True(t, sort.IntsAreSorted(sorted_results), "results should be sorted")
}
func FirstFunc() any {
fmt.Println("-- Executing first function --")
- time.Sleep(7 * time.Second)
+ time.Sleep(70 * time.Millisecond)
fmt.Println("-- First Function finished --")
return 1
}
func SecondFunc() any {
fmt.Println("-- Executing second function --")
- time.Sleep(5 * time.Second)
+ time.Sleep(50 * time.Millisecond)
fmt.Println("-- Second Function finished --")
return 2
}
func ThirdFunc() any {
fmt.Println("-- Executing third function --")
- time.Sleep(2 * time.Second)
+ time.Sleep(20 * time.Millisecond)
fmt.Println("-- Third Function finished --")
return 3
}
func FourthFunc() any {
fmt.Println("-- Executing fourth function --")
- time.Sleep(10 * time.Second)
+ time.Sleep(100 * time.Millisecond)
fmt.Println("-- Fourth Function finished --")
return 4
}
func FifthFunc() any {
fmt.Println("-- Executing fifth function --")
- time.Sleep(4 * time.Second)
+ time.Sleep(40 * time.Millisecond)
fmt.Println("-- Fourth fifth finished --")
return 5
}