@@ -4,15 +4,19 @@ import (
4
4
"crypto/rand"
5
5
"fmt"
6
6
"os"
7
+ "os/exec"
7
8
"path/filepath"
8
9
"strings"
9
10
"testing"
10
11
"time"
11
12
12
13
"github.com/go-check/check"
13
14
"github.com/iovisor/kubectl-trace/pkg/cmd"
15
+ "github.com/pkg/errors"
14
16
"gotest.tools/icmd"
15
17
"sigs.k8s.io/kind/pkg/cluster"
18
+ "sigs.k8s.io/kind/pkg/cluster/nodes"
19
+ "sigs.k8s.io/kind/pkg/cluster/nodeutils"
16
20
"sigs.k8s.io/kind/pkg/fs"
17
21
)
18
22
@@ -22,10 +26,10 @@ var (
22
26
23
27
type KubectlTraceSuite struct {
24
28
kubeConfigPath string
25
- kindContext * cluster.Context
29
+ // kindContext *cluster.Context
26
30
27
31
provider * cluster.Provider
28
- name string
32
+ name string
29
33
}
30
34
31
35
func init () {
@@ -43,10 +47,15 @@ func (k *KubectlTraceSuite) SetUpSuite(c *check.C) {
43
47
44
48
k .provider = cluster .NewProvider ()
45
49
// Create the cluster
46
- err : = k .provider .Create (
50
+ err = k .provider .Create (
47
51
k .name ,
48
52
cluster .CreateWithRetain (false ),
49
53
cluster .CreateWithWaitForReady (time .Duration (0 )),
54
+ cluster .CreateWithKubeconfigPath (k .kubeConfigPath ),
55
+
56
+ // todo > we need a logger
57
+ // cluster.ProviderWithLogger(logger),
58
+ // runtime.GetDefault(logger),
50
59
)
51
60
c .Assert (err , check .IsNil )
52
61
@@ -70,14 +79,16 @@ func (k *KubectlTraceSuite) SetUpSuite(c *check.C) {
70
79
}
71
80
72
81
func (k * KubectlTraceSuite ) TearDownSuite (c * check.C ) {
73
- err := k .provider .Delete (k .name )
82
+ kubeConfig , err := k .provider .KubeConfig (k .name , false )
83
+ c .Assert (err , check .IsNil )
84
+ err = k .provider .Delete (k .name , kubeConfig )
74
85
c .Assert (err , check .IsNil )
75
86
}
76
87
77
88
func Test (t * testing.T ) { check .TestingT (t ) }
78
89
79
90
func (k * KubectlTraceSuite ) KubectlTraceCmd (c * check.C , args ... string ) string {
80
- args = append ([]string {fmt .Sprintf ("--kubeconfig=%s" , k .kindContext . KubeConfigPath () )}, args ... )
91
+ args = append ([]string {fmt .Sprintf ("--kubeconfig=%s" , k .kubeConfigPath )}, args ... )
81
92
res := icmd .RunCommand (KubectlTraceBinary , args ... )
82
93
c .Assert (res .ExitCode , check .Equals , icmd .Success .ExitCode )
83
94
return res .Combined ()
0 commit comments