Skip to content

Commit d15000e

Browse files
committed
chore: run goimports
1 parent 15fabf6 commit d15000e

File tree

3 files changed

+72
-72
lines changed

3 files changed

+72
-72
lines changed

pkg/activator/handler/handler_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -500,31 +500,31 @@ func (rr *responseRecorder) WriteHeader(code int) {
500500

501501
func TestWrapActivatorHandlerWithFullDuplex(t *testing.T) {
502502
logger := ktesting.TestLogger(t)
503-
503+
504504
tests := []struct {
505-
name string
506-
annotation string
507-
expectFullDuplex bool
505+
name string
506+
annotation string
507+
expectFullDuplex bool
508508
}{
509509
{
510-
name: "full duplex enabled",
511-
annotation: "Enabled",
512-
expectFullDuplex: true,
510+
name: "full duplex enabled",
511+
annotation: "Enabled",
512+
expectFullDuplex: true,
513513
},
514514
{
515-
name: "full duplex disabled",
516-
annotation: "Disabled",
517-
expectFullDuplex: false,
515+
name: "full duplex disabled",
516+
annotation: "Disabled",
517+
expectFullDuplex: false,
518518
},
519519
{
520-
name: "full duplex missing annotation",
521-
annotation: "",
522-
expectFullDuplex: false,
520+
name: "full duplex missing annotation",
521+
annotation: "",
522+
expectFullDuplex: false,
523523
},
524524
{
525-
name: "full duplex case insensitive",
526-
annotation: "enabled",
527-
expectFullDuplex: true,
525+
name: "full duplex case insensitive",
526+
annotation: "enabled",
527+
expectFullDuplex: true,
528528
},
529529
}
530530

@@ -535,13 +535,13 @@ func TestWrapActivatorHandlerWithFullDuplex(t *testing.T) {
535535
// Just respond with OK
536536
w.WriteHeader(http.StatusOK)
537537
})
538-
538+
539539
// Wrap with full duplex handler
540540
wrapped := WrapActivatorHandlerWithFullDuplex(testHandler, logger)
541-
541+
542542
// Create request with context
543543
req := httptest.NewRequest(http.MethodGet, "/", nil)
544-
544+
545545
// Set up revision context with annotation
546546
rev := &v1.Revision{
547547
ObjectMeta: metav1.ObjectMeta{
@@ -551,14 +551,14 @@ func TestWrapActivatorHandlerWithFullDuplex(t *testing.T) {
551551
if tt.annotation != "" {
552552
rev.Annotations[apiconfig.AllowHTTPFullDuplexFeatureKey] = tt.annotation
553553
}
554-
554+
555555
ctx := WithRevisionAndID(context.Background(), rev, types.NamespacedName{})
556556
req = req.WithContext(ctx)
557-
557+
558558
// Execute request
559559
resp := httptest.NewRecorder()
560560
wrapped.ServeHTTP(resp, req)
561-
561+
562562
// Verify response code
563563
if resp.Code != http.StatusOK {
564564
t.Errorf("Expected status %d, got %d", http.StatusOK, resp.Code)

pkg/activator/net/throttler_test.go

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,41 +1234,41 @@ func TestResetTrackersRaceCondition(t *testing.T) {
12341234
func TestPodTrackerStateTransitions(t *testing.T) {
12351235
t.Run("initial state is healthy", func(t *testing.T) {
12361236
tracker := newPodTracker("10.0.0.1:8012", nil)
1237-
1237+
12381238
state := podState(tracker.state.Load())
12391239
if state != podHealthy {
12401240
t.Errorf("Expected initial state to be podHealthy, got %v", state)
12411241
}
12421242
})
1243-
1243+
12441244
t.Run("tryDrain transitions from healthy to draining", func(t *testing.T) {
12451245
tracker := newPodTracker("10.0.0.1:8012", nil)
1246-
1246+
12471247
// Should successfully transition to draining
12481248
if !tracker.tryDrain() {
12491249
t.Error("Expected tryDrain to succeed on healthy pod")
12501250
}
1251-
1251+
12521252
state := podState(tracker.state.Load())
12531253
if state != podDraining {
12541254
t.Errorf("Expected state to be podDraining after tryDrain, got %v", state)
12551255
}
1256-
1256+
12571257
// Should not transition again
12581258
if tracker.tryDrain() {
12591259
t.Error("Expected tryDrain to fail on already draining pod")
12601260
}
1261-
1261+
12621262
// Verify draining start time was set
12631263
if tracker.drainingStartTime.Load() == 0 {
12641264
t.Error("Expected drainingStartTime to be set")
12651265
}
12661266
})
1267-
1267+
12681268
t.Run("pending state allows reservation", func(t *testing.T) {
12691269
tracker := newPodTracker("10.0.0.1:8012", nil)
12701270
tracker.state.Store(uint32(podPending))
1271-
1271+
12721272
// Should be able to reserve on pending pod
12731273
release, ok := tracker.Reserve(context.Background())
12741274
if !ok {
@@ -1278,11 +1278,11 @@ func TestPodTrackerStateTransitions(t *testing.T) {
12781278
release()
12791279
}
12801280
})
1281-
1281+
12821282
t.Run("draining state blocks new reservations", func(t *testing.T) {
12831283
tracker := newPodTracker("10.0.0.1:8012", nil)
12841284
tracker.tryDrain()
1285-
1285+
12861286
// Should not be able to reserve on draining pod
12871287
release, ok := tracker.Reserve(context.Background())
12881288
if ok {
@@ -1292,11 +1292,11 @@ func TestPodTrackerStateTransitions(t *testing.T) {
12921292
release()
12931293
}
12941294
})
1295-
1295+
12961296
t.Run("removed state blocks new reservations", func(t *testing.T) {
12971297
tracker := newPodTracker("10.0.0.1:8012", nil)
12981298
tracker.state.Store(uint32(podRemoved))
1299-
1299+
13001300
// Should not be able to reserve on removed pod
13011301
release, ok := tracker.Reserve(context.Background())
13021302
if ok {
@@ -1311,39 +1311,39 @@ func TestPodTrackerStateTransitions(t *testing.T) {
13111311
func TestPodTrackerReferenceCouting(t *testing.T) {
13121312
t.Run("reference counting on successful reserve", func(t *testing.T) {
13131313
tracker := newPodTracker("10.0.0.1:8012", nil)
1314-
1314+
13151315
// Initial ref count should be 0
13161316
if tracker.getRefCount() != 0 {
13171317
t.Errorf("Expected initial ref count to be 0, got %d", tracker.getRefCount())
13181318
}
1319-
1319+
13201320
// Reserve should increment ref count
13211321
release, ok := tracker.Reserve(context.Background())
13221322
if !ok {
13231323
t.Fatal("Expected Reserve to succeed")
13241324
}
1325-
1325+
13261326
if tracker.getRefCount() != 1 {
13271327
t.Errorf("Expected ref count to be 1 after Reserve, got %d", tracker.getRefCount())
13281328
}
1329-
1329+
13301330
// Release should decrement ref count
13311331
release()
1332-
1332+
13331333
if tracker.getRefCount() != 0 {
13341334
t.Errorf("Expected ref count to be 0 after release, got %d", tracker.getRefCount())
13351335
}
13361336
})
1337-
1337+
13381338
t.Run("reference counting on failed reserve", func(t *testing.T) {
13391339
tracker := newPodTracker("10.0.0.1:8012", nil)
13401340
tracker.state.Store(uint32(podDraining))
1341-
1341+
13421342
// Initial ref count should be 0
13431343
if tracker.getRefCount() != 0 {
13441344
t.Errorf("Expected initial ref count to be 0, got %d", tracker.getRefCount())
13451345
}
1346-
1346+
13471347
// Reserve should fail and not increment ref count
13481348
release, ok := tracker.Reserve(context.Background())
13491349
if ok {
@@ -1352,19 +1352,19 @@ func TestPodTrackerReferenceCouting(t *testing.T) {
13521352
if release != nil {
13531353
release()
13541354
}
1355-
1355+
13561356
if tracker.getRefCount() != 0 {
13571357
t.Errorf("Expected ref count to remain 0 after failed Reserve, got %d", tracker.getRefCount())
13581358
}
13591359
})
1360-
1360+
13611361
t.Run("multiple concurrent reservations", func(t *testing.T) {
13621362
tracker := newPodTracker("10.0.0.1:8012", nil)
1363-
1363+
13641364
const numReservations = 10
13651365
var wg sync.WaitGroup
13661366
releases := make([]func(), numReservations)
1367-
1367+
13681368
// Make concurrent reservations
13691369
for i := 0; i < numReservations; i++ {
13701370
wg.Add(1)
@@ -1376,39 +1376,39 @@ func TestPodTrackerReferenceCouting(t *testing.T) {
13761376
}
13771377
}(i)
13781378
}
1379-
1379+
13801380
wg.Wait()
1381-
1381+
13821382
// Check ref count
13831383
expectedCount := uint64(0)
13841384
for _, release := range releases {
13851385
if release != nil {
13861386
expectedCount++
13871387
}
13881388
}
1389-
1389+
13901390
if tracker.getRefCount() != expectedCount {
13911391
t.Errorf("Expected ref count to be %d, got %d", expectedCount, tracker.getRefCount())
13921392
}
1393-
1393+
13941394
// Release all
13951395
for _, release := range releases {
13961396
if release != nil {
13971397
release()
13981398
}
13991399
}
1400-
1400+
14011401
if tracker.getRefCount() != 0 {
14021402
t.Errorf("Expected ref count to be 0 after all releases, got %d", tracker.getRefCount())
14031403
}
14041404
})
1405-
1405+
14061406
t.Run("releaseRef with zero refcount", func(t *testing.T) {
14071407
tracker := newPodTracker("10.0.0.1:8012", nil)
1408-
1408+
14091409
// Should handle gracefully (not panic)
14101410
tracker.releaseRef()
1411-
1411+
14121412
// Ref count should remain 0
14131413
if tracker.getRefCount() != 0 {
14141414
t.Errorf("Expected ref count to remain 0, got %d", tracker.getRefCount())
@@ -1419,31 +1419,31 @@ func TestPodTrackerReferenceCouting(t *testing.T) {
14191419
func TestPodTrackerWeightOperations(t *testing.T) {
14201420
t.Run("weight increment and decrement", func(t *testing.T) {
14211421
tracker := newPodTracker("10.0.0.1:8012", nil)
1422-
1422+
14231423
// Initial weight should be 0
14241424
if tracker.getWeight() != 0 {
14251425
t.Errorf("Expected initial weight to be 0, got %d", tracker.getWeight())
14261426
}
1427-
1427+
14281428
// Increment weight
14291429
tracker.increaseWeight()
14301430
if tracker.getWeight() != 1 {
14311431
t.Errorf("Expected weight to be 1 after increase, got %d", tracker.getWeight())
14321432
}
1433-
1433+
14341434
// Decrement weight
14351435
tracker.decreaseWeight()
14361436
if tracker.getWeight() != 0 {
14371437
t.Errorf("Expected weight to be 0 after decrease, got %d", tracker.getWeight())
14381438
}
14391439
})
1440-
1440+
14411441
t.Run("weight underflow protection", func(t *testing.T) {
14421442
tracker := newPodTracker("10.0.0.1:8012", nil)
1443-
1443+
14441444
// Decrement from 0 should not underflow
14451445
tracker.decreaseWeight()
1446-
1446+
14471447
// Weight should remain 0 (not wrap around to max uint32)
14481448
weight := tracker.getWeight()
14491449
if weight != 0 && weight != ^uint32(0) {
@@ -1461,63 +1461,63 @@ func TestPodTrackerWithBreaker(t *testing.T) {
14611461
InitialCapacity: 5,
14621462
})
14631463
tracker := newPodTracker("10.0.0.1:8012", breaker)
1464-
1464+
14651465
if tracker.Capacity() != 5 {
14661466
t.Errorf("Expected capacity to be 5, got %d", tracker.Capacity())
14671467
}
14681468
})
1469-
1469+
14701470
t.Run("pending with breaker", func(t *testing.T) {
14711471
breaker := queue.NewBreaker(queue.BreakerParams{
14721472
QueueDepth: 10,
14731473
MaxConcurrency: 5,
14741474
InitialCapacity: 5,
14751475
})
14761476
tracker := newPodTracker("10.0.0.1:8012", breaker)
1477-
1477+
14781478
// Initially should have 0 pending
14791479
if tracker.Pending() != 0 {
14801480
t.Errorf("Expected pending to be 0, got %d", tracker.Pending())
14811481
}
14821482
})
1483-
1483+
14841484
t.Run("in-flight with breaker", func(t *testing.T) {
14851485
breaker := queue.NewBreaker(queue.BreakerParams{
14861486
QueueDepth: 10,
14871487
MaxConcurrency: 5,
14881488
InitialCapacity: 5,
14891489
})
14901490
tracker := newPodTracker("10.0.0.1:8012", breaker)
1491-
1491+
14921492
// Initially should have 0 in-flight
14931493
if tracker.InFlight() != 0 {
14941494
t.Errorf("Expected in-flight to be 0, got %d", tracker.InFlight())
14951495
}
1496-
1496+
14971497
// Reserve should increment in-flight
14981498
ctx := context.Background()
14991499
release, ok := breaker.Reserve(ctx)
15001500
if !ok {
15011501
t.Fatal("Expected Reserve to succeed")
15021502
}
15031503
defer release()
1504-
1504+
15051505
if tracker.InFlight() != 1 {
15061506
t.Errorf("Expected in-flight to be 1, got %d", tracker.InFlight())
15071507
}
15081508
})
1509-
1509+
15101510
t.Run("update concurrency with breaker", func(t *testing.T) {
15111511
breaker := queue.NewBreaker(queue.BreakerParams{
15121512
QueueDepth: 10,
15131513
MaxConcurrency: 5,
15141514
InitialCapacity: 5,
15151515
})
15161516
tracker := newPodTracker("10.0.0.1:8012", breaker)
1517-
1517+
15181518
// Update concurrency
15191519
tracker.UpdateConcurrency(10)
1520-
1520+
15211521
// Capacity should be updated
15221522
if tracker.Capacity() != 10 {
15231523
t.Errorf("Expected capacity to be 10 after update, got %d", tracker.Capacity())

0 commit comments

Comments
 (0)