Commit 9eb425d

Antonio Mika  ·  2026-10-11 20:30:24 -0400 EDT
parent 31fe51c
test(pgs): drop the fixed prometheus port from the test servers
3 files changed,  +2, -13
+0, -2
......@@ -24,7 +24,6 @@ import (
2424 "github.com/picosh/pico/pkg/shared"
2525 "github.com/picosh/pico/pkg/storage"
2626 "github.com/picosh/pico/pkg/storage/storagetest"
27- "github.com/prometheus/client_golang/prometheus"
2827 )
2928
3029 // rsyncFileMax lifts pgs's per-file cap so the test can move files larger
......@@ -62,7 +61,6 @@ func newRsyncEnv(t *testing.T, st storage.StorageServe) *rsyncEnv {
6261 cfg.WebProtocol = "https"
6362 done := make(chan error)
6463 readyCh := make(chan *pssh.SSHServer)
65- prometheus.DefaultRegisterer = prometheus.NewRegistry()
6664 go StartSshServerForTesting(cfg, done, readyCh)
6765 t.Cleanup(func() { close(done) })
6866
+2, -3
......@@ -20,7 +20,6 @@ import (
2020 "github.com/picosh/pico/pkg/shared"
2121 "github.com/picosh/pico/pkg/storage"
2222 "github.com/pkg/sftp"
23- "github.com/prometheus/client_golang/prometheus"
2423 "golang.org/x/crypto/ssh"
2524 )
2625
......@@ -42,6 +41,8 @@ func StartSshServerForTesting(cfg *Config, killCh chan error, readyCh chan *pssh
4241 readyCh <- nil
4342 return
4443 }
44+ // No test reads metrics, and a fixed port collides between test servers.
45+ server.Config.PromListenAddr = ""
4546
4647 logger.Info("Starting SSH server", "addr", server.Config.ListenAddr)
4748
......@@ -90,7 +91,6 @@ func TestSshServerSftp(t *testing.T) {
9091 cfg := NewConfig(logger, dbpool, st, pubsub)
9192 done := make(chan error)
9293 readyCh := make(chan *pssh.SSHServer)
93- prometheus.DefaultRegisterer = prometheus.NewRegistry()
9494
9595 go StartSshServerForTesting(cfg, done, readyCh)
9696
......@@ -193,7 +193,6 @@ func TestSshServerRsync(t *testing.T) {
193193 cfg := NewConfig(logger, dbpool, st, pubsub)
194194 done := make(chan error)
195195 readyCh := make(chan *pssh.SSHServer)
196- prometheus.DefaultRegisterer = prometheus.NewRegistry()
197196
198197 go StartSshServerForTesting(cfg, done, readyCh)
199198
+0, -8
......@@ -20,7 +20,6 @@ import (
2020 "github.com/picosh/pico/pkg/shared"
2121 "github.com/picosh/pico/pkg/storage"
2222 "github.com/pkg/sftp"
23- "github.com/prometheus/client_golang/prometheus"
2423 )
2524
2625 // TestRsyncDeleteDirectory verifies that rsync --delete removes a directory
......@@ -57,12 +56,10 @@ func TestRsyncDeleteDirectory(t *testing.T) {
5756 }()
5857
5958 _ = os.Setenv("PGS_SSH_PORT", "0")
60- _ = os.Setenv("PGS_PROM_PORT", "0")
6159
6260 cfg := NewConfig(logger, dbpool, st, pubsub)
6361 done := make(chan error)
6462 readyCh := make(chan *pssh.SSHServer)
65- prometheus.DefaultRegisterer = prometheus.NewRegistry()
6663
6764 go StartSshServerForTesting(cfg, done, readyCh)
6865
......@@ -248,12 +245,10 @@ func TestRsyncDeleteNestedEmptyDirectories(t *testing.T) {
248245 }()
249246
250247 _ = os.Setenv("PGS_SSH_PORT", "0")
251- _ = os.Setenv("PGS_PROM_PORT", "0")
252248
253249 cfg := NewConfig(logger, dbpool, st, pubsub)
254250 done := make(chan error)
255251 readyCh := make(chan *pssh.SSHServer)
256- prometheus.DefaultRegisterer = prometheus.NewRegistry()
257252
258253 go StartSshServerForTesting(cfg, done, readyCh)
259254
......@@ -387,12 +382,10 @@ func setupPgsTestServer(t *testing.T, dbpool *pgsdb.MemoryDB) (string, func()) {
387382 pubsub := NewPubsubChan()
388383
389384 _ = os.Setenv("PGS_SSH_PORT", "0")
390- _ = os.Setenv("PGS_PROM_PORT", "0")
391385
392386 cfg := NewConfig(logger, dbpool, st, pubsub)
393387 done := make(chan error)
394388 readyCh := make(chan *pssh.SSHServer)
395- prometheus.DefaultRegisterer = prometheus.NewRegistry()
396389
397390 go StartSshServerForTesting(cfg, done, readyCh)
398391
......@@ -727,7 +720,6 @@ func TestSftpDirectories(t *testing.T) {
727720 done := make(chan error)
728721 defer close(done)
729722 readyCh := make(chan *pssh.SSHServer)
730- prometheus.DefaultRegisterer = prometheus.NewRegistry()
731723 go StartSshServerForTesting(cfg, done, readyCh)
732724 server := <-readyCh
733725 if server == nil {