Skip to content

Commit

Permalink
test: fix build issues in integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 28, 2023
1 parent bc585ea commit e61bf48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
18 changes: 8 additions & 10 deletions test/integration/framework/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

Expand Down Expand Up @@ -57,22 +59,18 @@ func NewFixture(ctx context.Context, t *testing.T) *Fixture {
config := ApiserverConfig()

scheme, err := controllermanager.NewScheme()
if err != nil {
t.Fatalf("can't create Scheme: %v", err)
}
require.NoError(t, err)

mapper, err := apiutil.NewDiscoveryRESTMapper(config)
if err != nil {
t.Fatalf("can't create Mapper: %v", err)
}
httpClient, err := rest.HTTPClientFor(config)
require.NoError(t, err)
mapper, err := apiutil.NewDiscoveryRESTMapper(config, httpClient)
require.NoError(t, err)

kubeClient, err := client.New(config, client.Options{
Scheme: scheme,
Mapper: mapper,
})
if err != nil {
t.Fatalf("can't create Client: %v", err)
}
require.NoError(t, err)

return &Fixture{
T: t,
Expand Down
11 changes: 8 additions & 3 deletions test/integration/framework/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"k8s.io/klog"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/manager"

"planetscale.dev/vitess-operator/pkg/operator/controllermanager"
Expand Down Expand Up @@ -204,7 +205,11 @@ func testMain(tests func() int) error {

// Start vitess-operator in this test process.
mgr, err := controllermanager.New("", ApiserverConfig(), manager.Options{
Namespace: "default",
Cache: cache.Options{
DefaultNamespaces: map[string]cache.Config{
"default": {},
},
},
})
if err != nil {
return fmt.Errorf("cannot create controller-manager: %v", err)
Expand Down Expand Up @@ -246,8 +251,8 @@ func execKubectlStdin(stdin io.Reader, args ...string) ([]byte, error) {
"--tls-server-name", "10.0.0.1",
"--certificate-authority", ApiserverCert(),
"--token", ApiserverToken(),
}, args...)
}, args...)

cmd := exec.Command(execPath, cmdline...)
cmd.Stdin = stdin
return cmd.CombinedOutput()
Expand Down

0 comments on commit e61bf48

Please sign in to comment.