UPSTREAM: 86177: make test framework easier to re-use
@@ -31,6 +31,8 @@ import (
"sync"
"time"
+ "k8s.io/apimachinery/pkg/runtime"
+
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -73,6 +75,7 @@ type Framework struct {
// test multiple times in parallel.
UniqueName string
+ clientConfig *rest.Config
ClientSet clientset.Interface
KubemarkExternalClusterClientSet clientset.Interface
@@ -180,6 +183,7 @@ func (f *Framework) BeforeEach() {
if TestContext.KubeAPIContentType != "" {
config.ContentType = TestContext.KubeAPIContentType
}
+ f.clientConfig = rest.CopyConfig(config)
f.ClientSet, err = clientset.NewForConfig(config)
ExpectNoError(err)
f.DynamicClient, err = dynamic.NewForConfig(config)
@@ -320,6 +324,7 @@ func (f *Framework) AfterEach() {
// Paranoia-- prevent reuse!
f.Namespace = nil
+ f.clientConfig = nil
f.ClientSet = nil
f.namespacesToDelete = nil
@@ -458,6 +463,15 @@ func (f *Framework) WaitForPodNoLongerRunning(podName string) error {
return e2epod.WaitForPodNoLongerRunningInNamespace(f.ClientSet, podName, f.Namespace.Name)
}
+// ClientConfig an externally accessible method for reading the kube client config.
+func (f *Framework) ClientConfig() *rest.Config {
+ ret := rest.CopyConfig(f.clientConfig)
+ // json is least common denominator
+ ret.ContentType = runtime.ContentTypeJSON
+ ret.AcceptContentTypes = runtime.ContentTypeJSON
+ return ret
+}
+
// TestContainerOutput runs the given pod in the given namespace and waits
// for all of the containers in the podSpec to move into the 'Success' status, and tests
// the specified container log against the given expected output using a substring matcher.
