diff --git a/tests/info1_test.go b/tests/info1_test.go index 414e3b2..a1e8436 100644 --- a/tests/info1_test.go +++ b/tests/info1_test.go @@ -1,3 +1,5 @@ +// This test is a simple test to check if the cluster is running and can be used + package codex import ( @@ -13,7 +15,7 @@ import ( "golang.org/x/sync/errgroup" ) -func TestHello(t *testing.T) { +func TestInfo1(t *testing.T) { run := func(t *testing.T, name string, impl cluster.Cluster) { t.Run(name, func(t *testing.T) { t.Parallel() @@ -57,7 +59,7 @@ func TestHello(t *testing.T) { } fmt.Println("---------------------") t.Log(output) - assert.Equal(t, 0, code, "should be 200") + assert.Equal(t, 0, code, "should be 0") t.Logf("HOST %d Exit code: %d\n", i, code) // fmt.Println(runout) return nil diff --git a/tests/info2_test.go b/tests/info2_test.go new file mode 100644 index 0000000..7d73c05 --- /dev/null +++ b/tests/info2_test.go @@ -0,0 +1,76 @@ +// This test is a counter test to check if the tests are up to date and running correctly by applying an incorrect ip + +package codex + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/guseggert/clustertest/cluster" + "github.com/guseggert/clustertest/cluster/basic" + "github.com/guseggert/clustertest/cluster/docker" + "github.com/stretchr/testify/assert" + "golang.org/x/sync/errgroup" +) + +func TestInfo2(t *testing.T) { + run := func(t *testing.T, name string, impl cluster.Cluster) { + t.Run(name, func(t *testing.T) { + t.Parallel() + + c := basic.New(impl) + t.Cleanup(c.MustCleanup) + + t.Logf("Launching %s nodes", name) + nodes := c.MustNewNodes(2) + + group, groupCtx := errgroup.WithContext(context.Background()) + addrs := "127.0.0.2" // incorrect ip + for i, node := range nodes { + node := node.Context(groupCtx) + if i <= 1 { + group.Go(func() error { + ip, err := getIp(groupCtx, node) + if err != nil { + t.Errorf("failed to get ip: %s", err) + t.Errorf("HOST EOutput: %s\n", ip) + } + fmt.Println("ip: ", ip) + output, err := createCodexInstance(groupCtx, node) + if err != nil { + t.Errorf(`starting host on node %d: %s`, i, err) + t.Errorf("HOST EOutput: %s\n", output) + return err + } + time.Sleep(2 * time.Second) + t.Log(output) + for x := 0; x < 2; x++ { + group.Go(func() error { + output, code, err := debugInfoCall(groupCtx, node, addrs) + if err != nil { + t.Errorf("failed to get debug info: %s", err) + t.Errorf("HOST EOutput: %s\n", output) + return err + } + fmt.Println("---------------------") + t.Log(output) + assert.NotEqual(t, 0, code, "should be not be 0") + t.Logf("HOST %d Exit code: %d\n", i, code) + return nil + }) + } + return nil + }) + time.Sleep(5 * time.Second) + continue + } + } + group.Wait() + }) + + } + // run(t, "local cluster", local.MustNewCluster()) + run(t, "Docker cluster", docker.MustNewCluster().WithBaseImage("corbo12/nim-codex:v4")) +} diff --git a/tests/upload1_test.go b/tests/upload1_test.go index f466719..d4098ba 100644 --- a/tests/upload1_test.go +++ b/tests/upload1_test.go @@ -13,7 +13,7 @@ import ( "golang.org/x/sync/errgroup" ) -func TestUpload(t *testing.T) { +func TestUpload1(t *testing.T) { run := func(t *testing.T, name string, impl cluster.Cluster) { t.Run(name, func(t *testing.T) { t.Parallel()