Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying out running against localhost for test #260

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions impl/concurrencytest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var (
iterationsPerServer = 1000
servers = []string{"diddht-a", "diddht-b"}
servers = []string{"http://localhost:8305", "http://localhost:8305"}
)

func main() {
Expand Down Expand Up @@ -70,7 +70,7 @@ func put(server string) (string, error) {
return "", err
}

req, err := http.NewRequest(http.MethodPut, "http://"+server+":8305/"+suffix, bytes.NewReader(reqData))
req, err := http.NewRequest(http.MethodPut, server+"/"+suffix, bytes.NewReader(reqData))
if err != nil {
return "", err
}
Expand All @@ -94,7 +94,7 @@ func put(server string) (string, error) {
}

func get(server, suffix string) error {
resp, err := http.Get("http://" + server + ":8305/" + suffix)
resp, err := http.Get(server + "/" + suffix)
if err != nil {
return err
}
Expand Down
8 changes: 3 additions & 5 deletions impl/integrationtest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ var (
ticker = time.NewTicker(time.Second * 30)
)

const serverURL = "http://localhost:8305"

func main() {
logrus.SetLevel(logrus.DebugLevel)
if len(os.Args) < 2 {
logrus.Fatal("must specify 1 argument (server URL)")
}

run(os.Args[1])
run(serverURL)
}

func run(server string) {
Expand Down
4 changes: 2 additions & 2 deletions impl/internal/did/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
21 changes: 21 additions & 0 deletions impl/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,24 @@ func Vuln() error {
func installGoVulnIfNotPresent() error {
return installIfNotPresent("govulncheck", "golang.org/x/vuln/cmd/govulncheck@latest")
}

// StartServer starts the local did-dht server.
func StartServer() error {
println("Starting local did-dht server...")
return sh.Run("../scripts/quickstart.sh", "-d", "-n", "did-dht-test-server", "-p", "8305:8305")
}

// StopServer stops the local did-dht server.
func StopServer() error {
println("Stopping local did-dht server...")
return sh.Run("docker", "stop", "did-dht-test-server")
}

// LocalTest runs the tests with a local server.
func LocalTest() error {
if err := StartServer(); err != nil {
return err
}
defer StopServer()
return Test()
}
Loading