Skip to content

Commit

Permalink
fix(integration): use the new kind cluster creation features correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <[email protected]>
  • Loading branch information
leodido authored and fntlnz committed Oct 30, 2020
1 parent 3a56a6f commit 52df061
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func (k *KubectlTraceSuite) TestRunNode(c *check.C) {
nodes, err := k.provider.ListNodes()
nodes, err := k.provider.ListNodes(k.name)
c.Assert(err, check.IsNil)
c.Assert(len(nodes), check.Equals, 1)

Expand Down
21 changes: 16 additions & 5 deletions integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import (
"crypto/rand"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

"github.com/go-check/check"
"github.com/iovisor/kubectl-trace/pkg/cmd"
"github.com/pkg/errors"
"gotest.tools/icmd"
"sigs.k8s.io/kind/pkg/cluster"
"sigs.k8s.io/kind/pkg/cluster/nodes"
"sigs.k8s.io/kind/pkg/cluster/nodeutils"
"sigs.k8s.io/kind/pkg/fs"
)

Expand All @@ -22,10 +26,10 @@ var (

type KubectlTraceSuite struct {
kubeConfigPath string
kindContext *cluster.Context
// kindContext *cluster.Context

provider *cluster.Provider
name string
name string
}

func init() {
Expand All @@ -43,10 +47,15 @@ func (k *KubectlTraceSuite) SetUpSuite(c *check.C) {

k.provider = cluster.NewProvider()
// Create the cluster
err := k.provider.Create(
err = k.provider.Create(
k.name,
cluster.CreateWithRetain(false),
cluster.CreateWithWaitForReady(time.Duration(0)),
cluster.CreateWithKubeconfigPath(k.kubeConfigPath),

// todo > we need a logger
// cluster.ProviderWithLogger(logger),
// runtime.GetDefault(logger),
)
c.Assert(err, check.IsNil)

Expand All @@ -70,14 +79,16 @@ func (k *KubectlTraceSuite) SetUpSuite(c *check.C) {
}

func (k *KubectlTraceSuite) TearDownSuite(c *check.C) {
err := k.provider.Delete(k.name)
kubeConfig, err := k.provider.KubeConfig(k.name, false)
c.Assert(err, check.IsNil)
err = k.provider.Delete(k.name, kubeConfig)
c.Assert(err, check.IsNil)
}

func Test(t *testing.T) { check.TestingT(t) }

func (k *KubectlTraceSuite) KubectlTraceCmd(c *check.C, args ...string) string {
args = append([]string{fmt.Sprintf("--kubeconfig=%s", k.kindContext.KubeConfigPath())}, args...)
args = append([]string{fmt.Sprintf("--kubeconfig=%s", k.kubeConfigPath)}, args...)
res := icmd.RunCommand(KubectlTraceBinary, args...)
c.Assert(res.ExitCode, check.Equals, icmd.Success.ExitCode)
return res.Combined()
Expand Down

0 comments on commit 52df061

Please sign in to comment.