Add makefile

This commit is contained in:
Shorssaud 2023-02-16 17:52:40 +01:00
parent 490d388dca
commit 1b8b080e24
2 changed files with 57 additions and 49 deletions

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
# Create a makefile that runs all the tests in tests/
SRC = $(wildcard tests/*.go)
all:
go test $(SRC)
verbose:
go test -v $(SRC)

View File

@ -28,59 +28,58 @@ func TestUpload1(t *testing.T) {
group, groupCtx := errgroup.WithContext(context.Background())
addrs := "127.0.0.1"
for i, node := range nodes {
id := i
node := node.Context(groupCtx)
if i <= 1 {
group.Go(func() error {
// gets node ip
ip, err := getIp(groupCtx, node)
if err != nil {
t.Error(Fatal("failed to get ip: %s", err))
t.Error(Fatal("HOST EOutput: %s\n", ip))
}
t.Log(Info("ip: " + ip))
group.Go(func() error {
// gets node ip
ip, err := getIp(groupCtx, node)
if err != nil {
t.Error(Fatal("failed to get ip: %s", err))
t.Error(Fatal("HOST EOutput: %s\n", ip))
}
t.Log(Info("ip: " + ip))
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
_, err = node.StartProc(cluster.StartProcRequest{
Command: "./build/codex",
Args: []string{"--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8070", "--log-level=TRACE"},
Stdout: stdout,
})
if err != nil {
t.Error(Fatal("HOST EOutput: %s\n", stderr.String()))
return err
}
runout := &bytes.Buffer{}
runerr := &bytes.Buffer{}
time.Sleep(2 * time.Second)
if i == 1 {
node.SendFile("tests/dog1.txt", bytes.NewBuffer([]byte("hello my dog")))
for x := 0; x < 2; x++ {
group.Go(func() error {
proc, err := node.StartProc(cluster.StartProcRequest{
Command: "curl",
Args: []string{"-vvv", "-H", "\"content-type: application/octet-stream\"", "-H", "Expect:", "-T", "tests/dog1.txt", "http://" + addrs + ":8090/api/codex/v1/upload", "-X", "POST"},
Stdout: runout,
})
if err != nil {
t.Error(Fatal("HOST EOutput: %s\n", err))
return err
}
code, err := proc.Wait()
if err != nil {
t.Errorf(Fatal("HOST EOutput: %s\n", err))
return err
}
t.Log(Info("HOST Output: ") + runout.String())
assert.Equal(t, 0, code.ExitCode, "HOST EOutput: %s\n", runerr.String())
return nil
})
}
}
return nil
_, err = node.StartProc(cluster.StartProcRequest{
Command: "./build/codex",
Args: []string{"--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8070", "--log-level=TRACE"},
Stdout: stdout,
})
}
if err != nil {
t.Error(Fatal("HOST EOutput: %s\n", stderr.String()))
return err
}
runout := &bytes.Buffer{}
runerr := &bytes.Buffer{}
time.Sleep(2 * time.Second)
if id == 1 {
node.SendFile("tests/dog1.txt", bytes.NewBuffer([]byte("hello my dog")))
for x := 0; x < 10; x++ {
group.Go(func() error {
proc, err := node.StartProc(cluster.StartProcRequest{
Command: "curl",
Args: []string{"-vvv", "-H", "\"content-type: application/octet-stream\"", "-H", "Expect:", "-T", "tests/dog1.txt", "http://" + addrs + ":8090/api/codex/v1/upload", "-X", "POST"},
Stdout: runout,
})
if err != nil {
t.Error(Fatal("HOST EOutput: %s\n", err))
return err
}
code, err := proc.Wait()
if err != nil {
t.Errorf(Fatal("HOST EOutput: %s\n", err))
return err
}
assert.Equal(t, 0, code.ExitCode, "HOST EOutput: %s\n", runerr.String())
return nil
})
}
}
return nil
})
}
group.Wait()
})