From 1db7b219e8732a708a8bc8368c32f9a69e780049 Mon Sep 17 00:00:00 2001 From: Mic Neale Date: Fri, 26 Jul 2024 18:27:02 +1000 Subject: [PATCH] use local dht container --- impl/concurrencytest/main.go | 52 +++++++++++++++++--------------- impl/internal/did/client_test.go | 4 +-- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/impl/concurrencytest/main.go b/impl/concurrencytest/main.go index 084db2b2..37386093 100644 --- a/impl/concurrencytest/main.go +++ b/impl/concurrencytest/main.go @@ -17,7 +17,7 @@ import ( var ( iterationsPerServer = 1000 - server = "http://localhost:8305" + servers = []string{"http://localhost:8305", "http://localhost:8305"} ) func main() { @@ -26,30 +26,32 @@ func main() { programStart := time.Now() var wg sync.WaitGroup - for i := 0; i < iterationsPerServer; i++ { - log := logrus.WithField("server", server).WithField("i", i) - - s := server - wg.Add(1) - go func() { - putStart := time.Now() - suffix, err := put(s) - if err != nil { - log = log.WithError(err) - } - log.WithField("time", time.Since(putStart)).Info("PUT request completed") - if err != nil { - return - } - - getStart := time.Now() - if err = get(s, suffix); err != nil { - log = log.WithError(err) - } - log.WithField("time", time.Since(getStart)).Info("GET request completed") - - wg.Done() - }() + for _, server := range servers { + for i := 0; i < iterationsPerServer; i++ { + log := logrus.WithField("server", server).WithField("i", i) + + s := server + wg.Add(1) + go func() { + putStart := time.Now() + suffix, err := put(s) + if err != nil { + log = log.WithError(err) + } + log.WithField("time", time.Since(putStart)).Info("PUT request completed") + if err != nil { + return + } + + getStart := time.Now() + if err = get(s, suffix); err != nil { + log = log.WithError(err) + } + log.WithField("time", time.Since(getStart)).Info("GET request completed") + + wg.Done() + }() + } } wg.Wait() diff --git a/impl/internal/did/client_test.go b/impl/internal/did/client_test.go index 5080d976..57c301b8 100644 --- a/impl/internal/did/client_test.go +++ b/impl/internal/did/client_test.go @@ -12,7 +12,7 @@ import ( ) func TestClient(t *testing.T) { - client, err := NewGatewayClient("https://diddht.tbddev.org") + client, err := NewGatewayClient("http://localhost:8305") require.NoError(t, err) require.NotNil(t, client) @@ -49,7 +49,7 @@ func TestClientInvalidGateway(t *testing.T) { } func TestInvalidDIDDocument(t *testing.T) { - client, err := NewGatewayClient("https://diddht.tbddev.test") + client, err := NewGatewayClient("http://localhost:8305") require.NoError(t, err) require.NotEmpty(t, client)