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 ( | |
| 24 | 24 | "github.com/picosh/pico/pkg/shared" | |
| 25 | 25 | "github.com/picosh/pico/pkg/storage" | |
| 26 | 26 | "github.com/picosh/pico/pkg/storage/storagetest" | |
| 27 | - | "github.com/prometheus/client_golang/prometheus" | |
| 28 | 27 | ) | |
| 29 | 28 | ||
| 30 | 29 | // 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 { | |
| 62 | 61 | cfg.WebProtocol = "https" | |
| 63 | 62 | done := make(chan error) | |
| 64 | 63 | readyCh := make(chan *pssh.SSHServer) | |
| 65 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 66 | 64 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 67 | 65 | t.Cleanup(func() { close(done) }) | |
| 68 | 66 |
+2,
-3
| ... | ... | @@ -20,7 +20,6 @@ import ( | |
| 20 | 20 | "github.com/picosh/pico/pkg/shared" | |
| 21 | 21 | "github.com/picosh/pico/pkg/storage" | |
| 22 | 22 | "github.com/pkg/sftp" | |
| 23 | - | "github.com/prometheus/client_golang/prometheus" | |
| 24 | 23 | "golang.org/x/crypto/ssh" | |
| 25 | 24 | ) | |
| 26 | 25 |
| ... | ... | @@ -42,6 +41,8 @@ func StartSshServerForTesting(cfg *Config, killCh chan error, readyCh chan *pssh | |
| 42 | 41 | readyCh <- nil | |
| 43 | 42 | return | |
| 44 | 43 | } | |
| 44 | + | // No test reads metrics, and a fixed port collides between test servers. | |
| 45 | + | server.Config.PromListenAddr = "" | |
| 45 | 46 | ||
| 46 | 47 | logger.Info("Starting SSH server", "addr", server.Config.ListenAddr) | |
| 47 | 48 |
| ... | ... | @@ -90,7 +91,6 @@ func TestSshServerSftp(t *testing.T) { | |
| 90 | 91 | cfg := NewConfig(logger, dbpool, st, pubsub) | |
| 91 | 92 | done := make(chan error) | |
| 92 | 93 | readyCh := make(chan *pssh.SSHServer) | |
| 93 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 94 | 94 | ||
| 95 | 95 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 96 | 96 |
| ... | ... | @@ -193,7 +193,6 @@ func TestSshServerRsync(t *testing.T) { | |
| 193 | 193 | cfg := NewConfig(logger, dbpool, st, pubsub) | |
| 194 | 194 | done := make(chan error) | |
| 195 | 195 | readyCh := make(chan *pssh.SSHServer) | |
| 196 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 197 | 196 | ||
| 198 | 197 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 199 | 198 |
+0,
-8
| ... | ... | @@ -20,7 +20,6 @@ import ( | |
| 20 | 20 | "github.com/picosh/pico/pkg/shared" | |
| 21 | 21 | "github.com/picosh/pico/pkg/storage" | |
| 22 | 22 | "github.com/pkg/sftp" | |
| 23 | - | "github.com/prometheus/client_golang/prometheus" | |
| 24 | 23 | ) | |
| 25 | 24 | ||
| 26 | 25 | // TestRsyncDeleteDirectory verifies that rsync --delete removes a directory |
| ... | ... | @@ -57,12 +56,10 @@ func TestRsyncDeleteDirectory(t *testing.T) { | |
| 57 | 56 | }() | |
| 58 | 57 | ||
| 59 | 58 | _ = os.Setenv("PGS_SSH_PORT", "0") | |
| 60 | - | _ = os.Setenv("PGS_PROM_PORT", "0") | |
| 61 | 59 | ||
| 62 | 60 | cfg := NewConfig(logger, dbpool, st, pubsub) | |
| 63 | 61 | done := make(chan error) | |
| 64 | 62 | readyCh := make(chan *pssh.SSHServer) | |
| 65 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 66 | 63 | ||
| 67 | 64 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 68 | 65 |
| ... | ... | @@ -248,12 +245,10 @@ func TestRsyncDeleteNestedEmptyDirectories(t *testing.T) { | |
| 248 | 245 | }() | |
| 249 | 246 | ||
| 250 | 247 | _ = os.Setenv("PGS_SSH_PORT", "0") | |
| 251 | - | _ = os.Setenv("PGS_PROM_PORT", "0") | |
| 252 | 248 | ||
| 253 | 249 | cfg := NewConfig(logger, dbpool, st, pubsub) | |
| 254 | 250 | done := make(chan error) | |
| 255 | 251 | readyCh := make(chan *pssh.SSHServer) | |
| 256 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 257 | 252 | ||
| 258 | 253 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 259 | 254 |
| ... | ... | @@ -387,12 +382,10 @@ func setupPgsTestServer(t *testing.T, dbpool *pgsdb.MemoryDB) (string, func()) { | |
| 387 | 382 | pubsub := NewPubsubChan() | |
| 388 | 383 | ||
| 389 | 384 | _ = os.Setenv("PGS_SSH_PORT", "0") | |
| 390 | - | _ = os.Setenv("PGS_PROM_PORT", "0") | |
| 391 | 385 | ||
| 392 | 386 | cfg := NewConfig(logger, dbpool, st, pubsub) | |
| 393 | 387 | done := make(chan error) | |
| 394 | 388 | readyCh := make(chan *pssh.SSHServer) | |
| 395 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 396 | 389 | ||
| 397 | 390 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 398 | 391 |
| ... | ... | @@ -727,7 +720,6 @@ func TestSftpDirectories(t *testing.T) { | |
| 727 | 720 | done := make(chan error) | |
| 728 | 721 | defer close(done) | |
| 729 | 722 | readyCh := make(chan *pssh.SSHServer) | |
| 730 | - | prometheus.DefaultRegisterer = prometheus.NewRegistry() | |
| 731 | 723 | go StartSshServerForTesting(cfg, done, readyCh) | |
| 732 | 724 | server := <-readyCh | |
| 733 | 725 | if server == nil { |