-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade client-go and apimachinery to 0.16.15 #1794
Changes from all commits
fbd8296
b2cb3df
f7daa1b
9891346
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import ( | |
"net/http" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
||
"agones.dev/agones/pkg/apis/agones" | ||
agonesv1 "agones.dev/agones/pkg/apis/agones/v1" | ||
|
@@ -37,6 +38,7 @@ import ( | |
k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/labels" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
|
@@ -89,7 +91,11 @@ func TestControllerSyncGameServer(t *testing.T) { | |
assert.Equal(t, fixture.ObjectMeta.Name, pod.ObjectMeta.Name) | ||
watchPods.Add(pod) | ||
// wait for the change to propagate | ||
assert.True(t, cache.WaitForCacheSync(context.Background().Done(), mocks.KubeInformerFactory.Core().V1().Pods().Informer().HasSynced)) | ||
require.Eventually(t, func() bool { | ||
list, err := c.podLister.List(labels.Everything()) | ||
assert.NoError(t, err) | ||
return len(list) == 1 | ||
}, 5*time.Second, time.Second) | ||
return true, pod, nil | ||
}) | ||
mocks.AgonesClient.AddReactor("list", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { | ||
|
@@ -1452,30 +1458,43 @@ func TestControllerGameServerPod(t *testing.T) { | |
} | ||
|
||
t.Run("no pod exists", func(t *testing.T) { | ||
c, gs, _, stop, cancel := setup() | ||
c, gs, _, _, cancel := setup() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like stop is never used from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just found where we do use this (and shows an example of what you mentioned below) SYAC c, gs, fakeWatch, stop, cancel := setup()
defer cancel()
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: gs.ObjectMeta.Name, Labels: map[string]string{agonesv1.GameServerPodLabel: gs.ObjectMeta.Name, "owned": "false"}}}
fakeWatch.Add(pod.DeepCopy())
// gate
cache.WaitForCacheSync(stop, c.podSynced) |
||
defer cancel() | ||
|
||
cache.WaitForCacheSync(stop, c.gameServerSynced) | ||
require.Never(t, func() bool { | ||
list, err := c.podLister.List(labels.Everything()) | ||
assert.NoError(t, err) | ||
return len(list) > 0 | ||
}, time.Second, 100*time.Millisecond) | ||
_, err := c.gameServerPod(gs) | ||
assert.Error(t, err) | ||
assert.True(t, k8serrors.IsNotFound(err)) | ||
}) | ||
|
||
t.Run("a pod exists", func(t *testing.T) { | ||
c, gs, fakeWatch, stop, cancel := setup() | ||
c, gs, fakeWatch, _, cancel := setup() | ||
|
||
defer cancel() | ||
pod, err := gs.Pod() | ||
require.NoError(t, err) | ||
|
||
fakeWatch.Add(pod.DeepCopy()) | ||
cache.WaitForCacheSync(stop, c.gameServerSynced) | ||
require.Eventually(t, func() bool { | ||
list, err := c.podLister.List(labels.Everything()) | ||
assert.NoError(t, err) | ||
return len(list) == 1 | ||
}, 5*time.Second, time.Second) | ||
|
||
pod2, err := c.gameServerPod(gs) | ||
require.NoError(t, err) | ||
assert.Equal(t, pod, pod2) | ||
|
||
fakeWatch.Delete(pod.DeepCopy()) | ||
cache.WaitForCacheSync(stop, c.gameServerSynced) | ||
require.Eventually(t, func() bool { | ||
list, err := c.podLister.List(labels.Everything()) | ||
assert.NoError(t, err) | ||
return len(list) == 0 | ||
}, 5*time.Second, time.Second) | ||
_, err = c.gameServerPod(gs) | ||
assert.Error(t, err) | ||
assert.True(t, k8serrors.IsNotFound(err)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update at some point; want to file a bug to follow up on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - makes sense. We should take this as a motivator to keep grpc up to date 👍