Use go 1.25 waitgroup Go method instead of Add/Wait (#3265)

* Use go 1.25 waitgroup Go method instead of Add/Wait

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Disable java builder test for now

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

---------

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2025-10-30 14:32:44 +05:30
committed by GitHub
parent 4ebdb077b5
commit ebdce4c0ed
11 changed files with 96 additions and 113 deletions
+30 -29
View File
@@ -224,32 +224,33 @@ func TestPoolCacheRequests(t *testing.T) {
}
for i := 1; i <= tt.requests; i++ {
reqno := i
wg.Add(1)
go func(reqno int) {
defer wg.Done()
svc, err := p.GetSvcValue(context.Background(), key, tt.rpp, tt.concurrency)
if err != nil {
code, _ := ferror.GetHTTPError(err)
if code == http.StatusNotFound {
atomic.AddUint64(&svcCounter, 1)
address := fmt.Sprintf("svc-%d", atomic.LoadUint64(&svcCounter))
p.SetSvcValue(context.Background(), key, address, &FuncSvc{
Name: address,
}, resource.MustParse("45m"), tt.rpp, tt.retainPods)
wg.Go(func() {
func(reqno int) {
svc, err := p.GetSvcValue(context.Background(), key, tt.rpp, tt.concurrency)
if err != nil {
code, _ := ferror.GetHTTPError(err)
if code == http.StatusNotFound {
atomic.AddUint64(&svcCounter, 1)
address := fmt.Sprintf("svc-%d", atomic.LoadUint64(&svcCounter))
p.SetSvcValue(context.Background(), key, address, &FuncSvc{
Name: address,
}, resource.MustParse("45m"), tt.rpp, tt.retainPods)
} else {
t.Log(reqno, "=>", err)
atomic.AddUint64(&failedRequests, 1)
}
} else {
t.Log(reqno, "=>", err)
atomic.AddUint64(&failedRequests, 1)
if svc == nil {
t.Log(reqno, "=>", "svc is nil")
atomic.AddUint64(&failedRequests, 1)
}
// } else {
// t.Log(reqno, "=>", svc.Name)
// }
}
} else {
if svc == nil {
t.Log(reqno, "=>", "svc is nil")
atomic.AddUint64(&failedRequests, 1)
}
// } else {
// t.Log(reqno, "=>", svc.Name)
// }
}
}(reqno)
}(reqno)
})
if reqno%simultaneous == 0 {
wg.Wait()
}
@@ -261,12 +262,12 @@ func TestPoolCacheRequests(t *testing.T) {
for i := 0; i < tt.concurrency; i++ {
for j := 0; j < tt.rpp; j++ {
wg.Add(1)
svcno := i
go func(svcno int) {
defer wg.Done()
p.MarkAvailable(key, fmt.Sprintf("svc-%d", svcno+1))
}(svcno)
wg.Go(func() {
func(svcno int) {
p.MarkAvailable(key, fmt.Sprintf("svc-%d", svcno+1))
}(svcno)
})
}
}
wg.Wait()
+2 -4
View File
@@ -48,16 +48,14 @@ func TestQueuePushWithConcurrentRequest(t *testing.T) {
q := NewQueue()
noOfRequests := 20
var wg sync.WaitGroup
wg.Add(noOfRequests)
for i := 0; i < noOfRequests; i++ {
go func() {
defer wg.Done()
wg.Go(func() {
item := &svcWait{
svcChannel: make(chan *FuncSvc),
ctx: nil,
}
q.Push(item)
}()
})
}
wg.Wait()