mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #86854 from ii/create-namespace-patch-test
Create namespace patch test
This commit is contained in:
commit
c983a3a44e
27
test/e2e/apimachinery/OWNERS
Normal file
27
test/e2e/apimachinery/OWNERS
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# See the OWNERS docs at https://go.k8s.io/owners
|
||||||
|
|
||||||
|
approvers:
|
||||||
|
- lavalamp
|
||||||
|
- smarterclayton
|
||||||
|
- deads2k
|
||||||
|
- sttts
|
||||||
|
- liggitt
|
||||||
|
- caesarxuchao
|
||||||
|
reviewers:
|
||||||
|
- thockin
|
||||||
|
- lavalamp
|
||||||
|
- smarterclayton
|
||||||
|
- wojtek-t
|
||||||
|
- deads2k
|
||||||
|
- derekwaynecarr
|
||||||
|
- caesarxuchao
|
||||||
|
- cheftako
|
||||||
|
- mikedanese
|
||||||
|
- liggitt
|
||||||
|
- gmarek
|
||||||
|
- sttts
|
||||||
|
- ncdc
|
||||||
|
- logicalhan
|
||||||
|
- tallclair
|
||||||
|
labels:
|
||||||
|
- sig/api-machinery
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apimachinery
|
package apimachinery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -26,12 +27,14 @@ import (
|
|||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, maxSeconds int) {
|
func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, maxSeconds int) {
|
||||||
@ -246,4 +249,27 @@ var _ = SIGDescribe("Namespaces [Serial]", func() {
|
|||||||
ginkgo.It("should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]",
|
ginkgo.It("should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]",
|
||||||
func() { extinguish(f, 100, 0, 150) })
|
func() { extinguish(f, 100, 0, 150) })
|
||||||
|
|
||||||
|
ginkgo.It("should patch a Namespace", func() {
|
||||||
|
ginkgo.By("creating a Namespace")
|
||||||
|
namespaceName := "nspatchtest-" + string(uuid.NewUUID())
|
||||||
|
ns, err := f.CreateNamespace(namespaceName, nil)
|
||||||
|
framework.ExpectNoError(err, "failed creating Namespace")
|
||||||
|
namespaceName = ns.ObjectMeta.Name
|
||||||
|
|
||||||
|
ginkgo.By("patching the Namespace")
|
||||||
|
nspatch, err := json.Marshal(map[string]interface{}{
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"labels": map[string]string{"testLabel": "testValue"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
framework.ExpectNoError(err, "failed to marshal JSON patch data")
|
||||||
|
_, err = f.ClientSet.CoreV1().Namespaces().Patch(namespaceName, types.StrategicMergePatchType, []byte(nspatch))
|
||||||
|
framework.ExpectNoError(err, "failed to patch Namespace")
|
||||||
|
|
||||||
|
ginkgo.By("get the Namespace and ensuring it has the label")
|
||||||
|
namespace, err := f.ClientSet.CoreV1().Namespaces().Get(namespaceName, metav1.GetOptions{})
|
||||||
|
framework.ExpectNoError(err, "failed to get Namespace")
|
||||||
|
framework.ExpectEqual(namespace.ObjectMeta.Labels["testLabel"], "testValue", "namespace not patched")
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user