Skip to content

Commit 207ccc8

Browse files
committed
fix unit tests
1 parent 9b5f56f commit 207ccc8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

components/supervisor/pkg/ports/ports.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewManager(exposed ExposedPortsInterface, served ServedPortsObserver, confi
4646
T: tunneled,
4747

4848
forceUpdates: make(chan struct{}, 1),
49-
closeSubscriptions: make(chan *Subscription, maxSubscriptions),
49+
closeSubscriptions: make(chan *Subscription, maxSubscriptions*2),
5050

5151
internal: internal,
5252
proxies: make(map[uint32]*localhostProxy),
@@ -772,7 +772,8 @@ func (pm *Manager) Subscribe() (*Subscription, error) {
772772
}
773773

774774
if len(pm.subscriptions) > maxSubscriptions {
775-
return nil, ErrTooManySubscriptions
775+
return nil, fmt.Errorf("too many subscriptions: %d", len(pm.subscriptions))
776+
// return nil, ErrTooManySubscriptions
776777
}
777778

778779
sub := &Subscription{updates: make(chan []*api.PortsStatus, 5)}

components/supervisor/pkg/ports/ports_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ func TestPortsConcurrentSubscribe(t *testing.T) {
864864
}
865865
}()
866866

867-
eg, _ := errgroup.WithContext(context.Background())
868867
for i := 0; i < maxSubscriptions; i++ {
868+
eg, _ := errgroup.WithContext(context.Background())
869869
eg.Go(func() error {
870870
for j := 0; j < subscribes; j++ {
871871
sub, err := pm.Subscribe()
@@ -882,12 +882,13 @@ func TestPortsConcurrentSubscribe(t *testing.T) {
882882
}
883883
return nil
884884
})
885+
err := eg.Wait()
886+
if err != nil {
887+
t.Fatal(err)
888+
}
889+
time.Sleep(50 * time.Millisecond)
885890
}
886-
err := eg.Wait()
887891
close(subscribing)
888-
if err != nil {
889-
t.Fatal(err)
890-
}
891892

892893
wg.Wait()
893894
}

0 commit comments

Comments
 (0)