From 3083c392156cc732acd2b292e54d380ff4ab9839 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Mon, 12 Jan 2026 14:38:49 +0100 Subject: [PATCH] Rename package of etcd test helpers. --- etcd/{etcdtest/etcdtest.go => test/etcd.go} | 40 +++++++++---------- .../etcdtest_test.go => test/etcd_test.go} | 2 +- grpc/client_test.go | 4 +- grpc/test/client.go | 4 +- grpc/test/client_test.go | 2 +- server/hub_sfu_proxy_test.go | 2 +- sfu/proxy/config_etcd_test.go | 6 +-- sfu/proxy/proxy_test.go | 2 +- sfu/proxy/test/proxy.go | 2 +- sfu/proxy/testserver/server.go | 4 +- talk/backend_configuration_test.go | 2 +- talk/backend_storage_etcd_test.go | 4 +- 12 files changed, 37 insertions(+), 37 deletions(-) rename etcd/{etcdtest/etcdtest.go => test/etcd.go} (92%) rename etcd/{etcdtest/etcdtest_test.go => test/etcd_test.go} (99%) diff --git a/etcd/etcdtest/etcdtest.go b/etcd/test/etcd.go similarity index 92% rename from etcd/etcdtest/etcdtest.go rename to etcd/test/etcd.go index cd4f7c7..1cb8f52 100644 --- a/etcd/etcdtest/etcdtest.go +++ b/etcd/test/etcd.go @@ -19,7 +19,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package etcdtest +package test import ( "bytes" @@ -54,29 +54,29 @@ var ( etcdListenUrl = "http://localhost:8080" ) -type Server struct { +type EtcdServer struct { embed *embed.Etcd } -func (s *Server) URL() *url.URL { +func (s *EtcdServer) URL() *url.URL { return &s.embed.Config().ListenClientUrls[0] } -func (s *Server) SetValue(key string, value []byte) { +func (s *EtcdServer) SetValue(key string, value []byte) { if kv := s.embed.Server.KV(); kv != nil { kv.Put([]byte(key), value, lease.NoLease) kv.Commit() } } -func (s *Server) DeleteValue(key string) { +func (s *EtcdServer) DeleteValue(key string) { if kv := s.embed.Server.KV(); kv != nil { kv.DeleteRange([]byte(key), nil) kv.Commit() } } -func NewServerForTest(t *testing.T) *Server { +func NewServerForTest(t *testing.T) *EtcdServer { t.Helper() require := require.New(t) cfg := embed.NewConfig() @@ -120,13 +120,13 @@ func NewServerForTest(t *testing.T) *Server { // Wait for server to be ready. <-etcd.Server.ReadyNotify() - server := &Server{ + server := &EtcdServer{ embed: etcd, } return server } -func NewEtcdClientForTest(t *testing.T, server *Server) etcd.Client { +func NewEtcdClientForTest(t *testing.T, server *EtcdServer) etcd.Client { t.Helper() logger := logtest.NewLoggerForTest(t) @@ -154,7 +154,7 @@ type testWatch struct { type testClient struct { mu sync.Mutex - server *TestServer + server *Server // +checklocks:mu closed bool @@ -166,7 +166,7 @@ type testClient struct { watchers []*testWatch } -func newTestClient(server *TestServer) *testClient { +func newTestClient(server *Server) *testClient { client := &testClient{ server: server, closeCh: make(chan struct{}), @@ -340,7 +340,7 @@ type testServerValue struct { revision int64 } -type TestServer struct { +type Server struct { t *testing.T mu sync.Mutex // +checklocks:mu @@ -351,20 +351,20 @@ type TestServer struct { revision int64 } -func (s *TestServer) newClient() *testClient { +func (s *Server) newClient() *testClient { client := newTestClient(s) s.addClient(client) return client } -func (s *TestServer) addClient(client *testClient) { +func (s *Server) addClient(client *testClient) { s.mu.Lock() defer s.mu.Unlock() s.clients = append(s.clients, client) } -func (s *TestServer) removeClient(client *testClient) { +func (s *Server) removeClient(client *testClient) { s.mu.Lock() defer s.mu.Unlock() @@ -373,14 +373,14 @@ func (s *TestServer) removeClient(client *testClient) { }) } -func (s *TestServer) getRevision() int64 { +func (s *Server) getRevision() int64 { s.mu.Lock() defer s.mu.Unlock() return s.revision } -func (s *TestServer) getValues(key string, minRevision int64, opts ...clientv3.OpOption) (keys []string, values [][]byte, revision int64) { +func (s *Server) getValues(key string, minRevision int64, opts ...clientv3.OpOption) (keys []string, values [][]byte, revision int64) { s.mu.Lock() defer s.mu.Unlock() @@ -409,7 +409,7 @@ func (s *TestServer) getValues(key string, minRevision int64, opts ...clientv3.O return } -func (s *TestServer) SetValue(key string, value []byte) { +func (s *Server) SetValue(key string, value []byte) { s.mu.Lock() defer s.mu.Unlock() @@ -435,7 +435,7 @@ func (s *TestServer) SetValue(key string, value []byte) { } } -func (s *TestServer) DeleteValue(key string) { +func (s *Server) DeleteValue(key string) { s.mu.Lock() defer s.mu.Unlock() @@ -452,9 +452,9 @@ func (s *TestServer) DeleteValue(key string) { } } -func NewClientForTest(t *testing.T) (*TestServer, etcd.Client) { +func NewClientForTest(t *testing.T) (*Server, etcd.Client) { t.Helper() - server := &TestServer{ + server := &Server{ t: t, revision: 1, } diff --git a/etcd/etcdtest/etcdtest_test.go b/etcd/test/etcd_test.go similarity index 99% rename from etcd/etcdtest/etcdtest_test.go rename to etcd/test/etcd_test.go index 2302c73..2278d68 100644 --- a/etcd/etcdtest/etcdtest_test.go +++ b/etcd/test/etcd_test.go @@ -19,7 +19,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package etcdtest +package test import ( "context" diff --git a/grpc/client_test.go b/grpc/client_test.go index db5c444..c17c972 100644 --- a/grpc/client_test.go +++ b/grpc/client_test.go @@ -35,7 +35,7 @@ import ( "github.com/strukturag/nextcloud-spreed-signaling/dns" dnstest "github.com/strukturag/nextcloud-spreed-signaling/dns/test" "github.com/strukturag/nextcloud-spreed-signaling/etcd" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" "github.com/strukturag/nextcloud-spreed-signaling/log" logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test" "github.com/strukturag/nextcloud-spreed-signaling/test" @@ -62,7 +62,7 @@ func NewClientsForTest(t *testing.T, addr string, lookup *dnstest.MockLookup) (* return NewClientsForTestWithConfig(t, config, nil, lookup) } -func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.Server, lookup *dnstest.MockLookup) (*Clients, *dns.Monitor) { +func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.EtcdServer, lookup *dnstest.MockLookup) (*Clients, *dns.Monitor) { config := goconf.NewConfigFile() config.AddOption("etcd", "endpoints", embedEtcd.URL().String()) diff --git a/grpc/test/client.go b/grpc/test/client.go index a6580cb..69c5bfc 100644 --- a/grpc/test/client.go +++ b/grpc/test/client.go @@ -32,7 +32,7 @@ import ( "github.com/strukturag/nextcloud-spreed-signaling/dns" dnstest "github.com/strukturag/nextcloud-spreed-signaling/dns/test" "github.com/strukturag/nextcloud-spreed-signaling/etcd" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" "github.com/strukturag/nextcloud-spreed-signaling/grpc" "github.com/strukturag/nextcloud-spreed-signaling/log" logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test" @@ -59,7 +59,7 @@ func NewClientsForTest(t *testing.T, addr string, lookup *dnstest.MockLookup) (* return NewClientsForTestWithConfig(t, config, nil, lookup) } -func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.Server, lookup *dnstest.MockLookup) (*grpc.Clients, *dns.Monitor) { +func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.EtcdServer, lookup *dnstest.MockLookup) (*grpc.Clients, *dns.Monitor) { config := goconf.NewConfigFile() config.AddOption("etcd", "endpoints", embedEtcd.URL().String()) diff --git a/grpc/test/client_test.go b/grpc/test/client_test.go index ccb09cd..cc9391c 100644 --- a/grpc/test/client_test.go +++ b/grpc/test/client_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" ) func TestClientsWithEtcd(t *testing.T) { diff --git a/server/hub_sfu_proxy_test.go b/server/hub_sfu_proxy_test.go index 28e0721..278f3be 100644 --- a/server/hub_sfu_proxy_test.go +++ b/server/hub_sfu_proxy_test.go @@ -33,7 +33,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/strukturag/nextcloud-spreed-signaling/api" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" "github.com/strukturag/nextcloud-spreed-signaling/grpc" grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test" "github.com/strukturag/nextcloud-spreed-signaling/sfu" diff --git a/sfu/proxy/config_etcd_test.go b/sfu/proxy/config_etcd_test.go index 9bc1561..0eea860 100644 --- a/sfu/proxy/config_etcd_test.go +++ b/sfu/proxy/config_etcd_test.go @@ -30,7 +30,7 @@ import ( "github.com/dlintw/goconf" "github.com/stretchr/testify/require" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test" ) @@ -40,7 +40,7 @@ type TestProxyInformationEtcd struct { OtherData string `json:"otherdata,omitempty"` } -func newProxyConfigEtcd(t *testing.T, proxy McuProxy) (*etcdtest.TestServer, Config) { +func newProxyConfigEtcd(t *testing.T, proxy McuProxy) (*etcdtest.Server, Config) { t.Helper() embedEtcd, client := etcdtest.NewClientForTest(t) cfg := goconf.NewConfigFile() @@ -54,7 +54,7 @@ func newProxyConfigEtcd(t *testing.T, proxy McuProxy) (*etcdtest.TestServer, Con return embedEtcd, p } -func SetEtcdProxy(t *testing.T, server *etcdtest.TestServer, path string, proxy *TestProxyInformationEtcd) { +func SetEtcdProxy(t *testing.T, server *etcdtest.Server, path string, proxy *TestProxyInformationEtcd) { t.Helper() data, _ := json.Marshal(proxy) server.SetValue(path, data) diff --git a/sfu/proxy/proxy_test.go b/sfu/proxy/proxy_test.go index c4f15d7..41049fd 100644 --- a/sfu/proxy/proxy_test.go +++ b/sfu/proxy/proxy_test.go @@ -42,7 +42,7 @@ import ( "github.com/strukturag/nextcloud-spreed-signaling/api" dnstest "github.com/strukturag/nextcloud-spreed-signaling/dns/test" "github.com/strukturag/nextcloud-spreed-signaling/etcd" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" "github.com/strukturag/nextcloud-spreed-signaling/geoip" grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test" "github.com/strukturag/nextcloud-spreed-signaling/internal" diff --git a/sfu/proxy/test/proxy.go b/sfu/proxy/test/proxy.go index a288125..809c673 100644 --- a/sfu/proxy/test/proxy.go +++ b/sfu/proxy/test/proxy.go @@ -38,7 +38,7 @@ import ( dnstest "github.com/strukturag/nextcloud-spreed-signaling/dns/test" "github.com/strukturag/nextcloud-spreed-signaling/etcd" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test" "github.com/strukturag/nextcloud-spreed-signaling/internal" "github.com/strukturag/nextcloud-spreed-signaling/log" diff --git a/sfu/proxy/testserver/server.go b/sfu/proxy/testserver/server.go index 08ad5eb..7b2d6bd 100644 --- a/sfu/proxy/testserver/server.go +++ b/sfu/proxy/testserver/server.go @@ -42,7 +42,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/strukturag/nextcloud-spreed-signaling/api" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" "github.com/strukturag/nextcloud-spreed-signaling/geoip" "github.com/strukturag/nextcloud-spreed-signaling/internal" "github.com/strukturag/nextcloud-spreed-signaling/proxy" @@ -62,7 +62,7 @@ type ProxyTestServer interface { } type ProxyTestOptions struct { - Etcd *etcdtest.Server + Etcd *etcdtest.EtcdServer Servers []ProxyTestServer } diff --git a/talk/backend_configuration_test.go b/talk/backend_configuration_test.go index bb3d7e8..c2c8b41 100644 --- a/talk/backend_configuration_test.go +++ b/talk/backend_configuration_test.go @@ -33,7 +33,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test" "github.com/strukturag/nextcloud-spreed-signaling/test" ) diff --git a/talk/backend_storage_etcd_test.go b/talk/backend_storage_etcd_test.go index 6adca58..3f5a2ab 100644 --- a/talk/backend_storage_etcd_test.go +++ b/talk/backend_storage_etcd_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/require" "github.com/strukturag/nextcloud-spreed-signaling/etcd" - "github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest" + etcdtest "github.com/strukturag/nextcloud-spreed-signaling/etcd/test" logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test" "github.com/strukturag/nextcloud-spreed-signaling/test" ) @@ -47,7 +47,7 @@ func (s *backendStorageEtcd) getWakeupChannelForTesting() <-chan struct{} { } type testListener struct { - etcd *etcdtest.TestServer + etcd *etcdtest.Server closed chan struct{} }