This commit is contained in:
Shorssaud 2023-02-09 15:36:41 +01:00
parent 6ad4e3bc9e
commit b74dc35cd5

View File

@ -25,10 +25,10 @@ func TestHello(t *testing.T) {
t.Cleanup(c.MustCleanup) t.Cleanup(c.MustCleanup)
t.Logf("Launching %s nodes", name) t.Logf("Launching %s nodes", name)
nodes := c.MustNewNodes(5) nodes := c.MustNewNodes(2)
group, groupCtx := errgroup.WithContext(context.Background()) group, groupCtx := errgroup.WithContext(context.Background())
addrs := "/ip4/0.0.0.0/tcp/8090" // addrs := "/ip4/0.0.0.0/tcp/8090"
for i, node := range nodes { for i, node := range nodes {
node := node.Context(groupCtx) node := node.Context(groupCtx)
if i == 0 { if i == 0 {
@ -37,9 +37,10 @@ func TestHello(t *testing.T) {
stdout := &bytes.Buffer{} stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{} stderr := &bytes.Buffer{}
// when running api on 8080, the host node will not be able to connect to the client node // when running api on 8080, the host node will not be able to connect to the client node
// args "--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8080", "--log-level=TRACE", "-i=" + addrs, "-q=1099511627776"
_, err := node.StartProc(cluster.StartProcRequest{ _, err := node.StartProc(cluster.StartProcRequest{
Command: "./build/codex", Command: "./build/codex",
Args: []string{"--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8080", "--log-level=TRACE", "-i=" + addrs, "-q=1099511627776"}, Args: []string{},
Stdout: stdout, Stdout: stdout,
Stderr: stderr, Stderr: stderr,
}) })
@ -51,13 +52,26 @@ func TestHello(t *testing.T) {
t.Errorf(`waiting for client on node %d: %s`, i, err) t.Errorf(`waiting for client on node %d: %s`, i, err)
return err return err
} }
for true { // codex seems to exit upon function exit
t.Logf("HOST Output: %s\n\n", stdout.String()) time.Sleep(2 * time.Second)
t.Logf("HOST EOutput: %s\n\n", stderr.String()) resp, err := http.Get("http://127.0.0.1:8080/api/codex/v1/info")
if err != nil {
t.Logf(err.Error())
} else {
fmt.Println(resp)
defer resp.Body.Close()
} }
// a, _ := proc.Wait()
// t.Logf("HOST proc: %d", a)
fmt.Println("PENIISSISISISI")
fmt.Printf("HOST Output: %s\n\n", stdout.String())
fmt.Printf("HOST EOutput: %s\n\n", stderr.String())
// t.Logf("HOST Output: %s\n\n", stdout.String())
// t.Logf("HOST EOutput: %s\n\n", stderr.String())
return nil return nil
}) })
time.Sleep(2 * time.Second) time.Sleep(9 * time.Second)
continue continue
} else { } else {
group.Go(func() error { group.Go(func() error {
@ -93,9 +107,8 @@ func TestHello(t *testing.T) {
// } // }
} }
group.Wait() group.Wait()
// TODO ping host using get request
}) })
} }
// run(t, "local cluster", local.MustNewCluster()) // run(t, "local cluster", local.MustNewCluster())
run(t, "Docker cluster", docker.MustNewCluster().WithBaseImage("corbo12/nim-codex:v5")) run(t, "Docker cluster", docker.MustNewCluster().WithBaseImage("corbo12/nim-codex:v4"))
} }