Rename package of etcd test helpers.

This commit is contained in:
Joachim Bauch 2026-01-12 14:38:49 +01:00
commit 3083c39215
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
12 changed files with 37 additions and 37 deletions

View file

@ -19,7 +19,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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,
}

View file

@ -19,7 +19,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package etcdtest
package test
import (
"context"

View file

@ -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())

View file

@ -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())

View file

@ -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) {

View file

@ -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"

View file

@ -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)

View file

@ -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"

View file

@ -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"

View file

@ -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
}

View file

@ -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"
)

View file

@ -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{}
}