mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #96954 from kensipe/apiservier-staticchecks-tests
Apiservier staticchecks tests
This commit is contained in:
commit
ade10205da
@ -104,7 +104,7 @@ func TestConvertToGVK(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: example2v1.ReplicaSetSpec{
|
Spec: example2v1.ReplicaSetSpec{
|
||||||
Replicas: func() *int32 { var i int32; i = 1; return &i }(),
|
Replicas: func() *int32 { var i int32 = 1; return &i }(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,6 @@ func (c *fakeObjectConvertor) Convert(in, out, context interface{}) error {
|
|||||||
out, err = c.converter.Convert(typedValue, c.apiVersion)
|
out, err = c.converter.Convert(typedValue, c.apiVersion)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out = in
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ func (f *structuredMergeManager) Apply(liveObj, patchObj runtime.Object, managed
|
|||||||
return nil, nil, fmt.Errorf("couldn't get accessor: %v", err)
|
return nil, nil, fmt.Errorf("couldn't get accessor: %v", err)
|
||||||
}
|
}
|
||||||
if patchObjMeta.GetManagedFields() != nil {
|
if patchObjMeta.GetManagedFields() != nil {
|
||||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("metadata.managedFields must be nil"))
|
return nil, nil, errors.NewBadRequest("metadata.managedFields must be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
liveObjVersioned, err := f.toVersioned(liveObj)
|
liveObjVersioned, err := f.toVersioned(liveObj)
|
||||||
|
@ -186,6 +186,9 @@ func TestDryRunUpdateDoesntUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
out := UnstructuredOrDie(`{}`)
|
out := UnstructuredOrDie(`{}`)
|
||||||
err = s.Get(context.Background(), "key", storage.GetOptions{}, out)
|
err = s.Get(context.Background(), "key", storage.GetOptions{}, out)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to get storage: %v", err)
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(created, out) {
|
if !reflect.DeepEqual(created, out) {
|
||||||
t.Fatalf("Returned object %q different from expected %q", created, out)
|
t.Fatalf("Returned object %q different from expected %q", created, out)
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ func (t *Tester) testDeleteWithUID(obj runtime.Object, createFn CreateFunc, getF
|
|||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
opts.Preconditions = metav1.NewPreconditionDeleteOptions("UID1111").Preconditions
|
opts.Preconditions = metav1.NewPreconditionDeleteOptions("UID1111").Preconditions
|
||||||
obj, _, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), rest.ValidateAllObjectFunc, &opts)
|
_, _, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), rest.ValidateAllObjectFunc, &opts)
|
||||||
if err == nil || !errors.IsConflict(err) {
|
if err == nil || !errors.IsConflict(err) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -923,7 +923,7 @@ func (t *Tester) testDeleteWithResourceVersion(obj runtime.Object, createFn Crea
|
|||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
opts.Preconditions = metav1.NewRVDeletionPrecondition("RV1111").Preconditions
|
opts.Preconditions = metav1.NewRVDeletionPrecondition("RV1111").Preconditions
|
||||||
obj, wasDeleted, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), rest.ValidateAllObjectFunc, &opts)
|
_, wasDeleted, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), rest.ValidateAllObjectFunc, &opts)
|
||||||
if err == nil || !errors.IsConflict(err) {
|
if err == nil || !errors.IsConflict(err) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,6 @@ func TestGOAWAYHTTP1Requests(t *testing.T) {
|
|||||||
s := httptest.NewUnstartedServer(WithProbabilisticGoaway(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
s := httptest.NewUnstartedServer(WithProbabilisticGoaway(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Write([]byte("hello"))
|
w.Write([]byte("hello"))
|
||||||
return
|
|
||||||
}), 1))
|
}), 1))
|
||||||
|
|
||||||
http2Options := &http2.Server{}
|
http2Options := &http2.Server{}
|
||||||
|
@ -877,7 +877,7 @@ func TestDispatchingBookmarkEventsWithConcurrentStop(t *testing.T) {
|
|||||||
resourceVersion := uint64(1000)
|
resourceVersion := uint64(1000)
|
||||||
err = cacher.watchCache.Add(&examplev1.Pod{
|
err = cacher.watchCache.Add(&examplev1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("pod-0"),
|
Name: "pod-0",
|
||||||
Namespace: "ns",
|
Namespace: "ns",
|
||||||
ResourceVersion: fmt.Sprintf("%v", resourceVersion),
|
ResourceVersion: fmt.Sprintf("%v", resourceVersion),
|
||||||
}})
|
}})
|
||||||
|
@ -138,7 +138,7 @@ func TestWatchCacheBasic(t *testing.T) {
|
|||||||
"prefix/ns/pod2": *makeTestStoreElement(makeTestPod("pod2", 5)),
|
"prefix/ns/pod2": *makeTestStoreElement(makeTestPod("pod2", 5)),
|
||||||
"prefix/ns/pod3": *makeTestStoreElement(makeTestPod("pod3", 6)),
|
"prefix/ns/pod3": *makeTestStoreElement(makeTestPod("pod3", 6)),
|
||||||
}
|
}
|
||||||
items := make(map[string]storeElement, 0)
|
items := make(map[string]storeElement)
|
||||||
for _, item := range store.List() {
|
for _, item := range store.List() {
|
||||||
elem := item.(*storeElement)
|
elem := item.(*storeElement)
|
||||||
items[elem.Key] = *elem
|
items[elem.Key] = *elem
|
||||||
@ -405,6 +405,9 @@ func TestWaitUntilFreshAndList(t *testing.T) {
|
|||||||
{IndexName: "l:not-exist-label", Value: "whatever"},
|
{IndexName: "l:not-exist-label", Value: "whatever"},
|
||||||
}
|
}
|
||||||
list, resourceVersion, err = store.WaitUntilFreshAndList(5, matchValues, nil)
|
list, resourceVersion, err = store.WaitUntilFreshAndList(5, matchValues, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
if resourceVersion != 5 {
|
if resourceVersion != 5 {
|
||||||
t.Errorf("unexpected resourceVersion: %v, expected: 5", resourceVersion)
|
t.Errorf("unexpected resourceVersion: %v, expected: 5", resourceVersion)
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,7 @@ func TestWatchDeleteEventObjectHaveLatestRV(t *testing.T) {
|
|||||||
|
|
||||||
e := <-w.ResultChan()
|
e := <-w.ResultChan()
|
||||||
watchedDeleteObj := e.Object.(*example.Pod)
|
watchedDeleteObj := e.Object.(*example.Pod)
|
||||||
var wres clientv3.WatchResponse
|
wres := <-etcdW
|
||||||
wres = <-etcdW
|
|
||||||
|
|
||||||
watchedDeleteRev, err := store.versioner.ParseResourceVersion(watchedDeleteObj.ResourceVersion)
|
watchedDeleteRev, err := store.versioner.ParseResourceVersion(watchedDeleteObj.ResourceVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -636,7 +636,6 @@ func (meal *cfgMeal) imaginePL(proto *flowcontrol.PriorityLevelConfiguration, re
|
|||||||
if proto.Spec.Limited != nil {
|
if proto.Spec.Limited != nil {
|
||||||
meal.shareSum += float64(proto.Spec.Limited.AssuredConcurrencyShares)
|
meal.shareSum += float64(proto.Spec.Limited.AssuredConcurrencyShares)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type immediateRequest struct{}
|
type immediateRequest struct{}
|
||||||
|
@ -630,7 +630,6 @@ func (qs *queueSet) cancelWait(req *request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// selectQueueLocked examines the queues in round robin order and
|
// selectQueueLocked examines the queues in round robin order and
|
||||||
|
@ -254,7 +254,6 @@ func TestUniformDistribution(t *testing.T) {
|
|||||||
t.Errorf("Only %v percent of the hands got a central count", goodPct)
|
t.Errorf("Only %v percent of the hands got a central count", goodPct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDealer_DealIntoHand(t *testing.T) {
|
func TestDealer_DealIntoHand(t *testing.T) {
|
||||||
@ -277,7 +276,7 @@ func TestDealer_DealIntoHand(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size: 6 cap: 6 slice",
|
"size: 6 cap: 6 slice",
|
||||||
make([]int, 6, 6),
|
make([]int, 6),
|
||||||
6,
|
6,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -287,7 +286,7 @@ func TestDealer_DealIntoHand(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size: 4 cap: 4 slice",
|
"size: 4 cap: 4 slice",
|
||||||
make([]int, 4, 4),
|
make([]int, 4),
|
||||||
6,
|
6,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -297,7 +296,7 @@ func TestDealer_DealIntoHand(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"size: 10 cap: 10 slice",
|
"size: 10 cap: 10 slice",
|
||||||
make([]int, 10, 10),
|
make([]int, 10),
|
||||||
6,
|
6,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -422,7 +422,6 @@ func TestRequestTimeout(t *testing.T) {
|
|||||||
|
|
||||||
handler := func(w http.ResponseWriter, r *http.Request) {
|
handler := func(w http.ResponseWriter, r *http.Request) {
|
||||||
<-done
|
<-done
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and start a simple HTTPS server
|
// Create and start a simple HTTPS server
|
||||||
|
@ -238,7 +238,7 @@ func TestVersionedConn(t *testing.T) {
|
|||||||
conn := NewConn(supportedProtocols)
|
conn := NewConn(supportedProtocols)
|
||||||
// note that it's not enough to wait for conn.ready to avoid a race here. Hence,
|
// note that it's not enough to wait for conn.ready to avoid a race here. Hence,
|
||||||
// we use a channel.
|
// we use a channel.
|
||||||
selectedProtocol := make(chan string, 0)
|
selectedProtocol := make(chan string)
|
||||||
s, addr := newServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
s, addr := newServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
p, _, _ := conn.Open(w, req)
|
p, _, _ := conn.Open(w, req)
|
||||||
selectedProtocol <- p
|
selectedProtocol <- p
|
||||||
|
Loading…
Reference in New Issue
Block a user