Skip to content

Commit

Permalink
Merge branch 'main' into executor-test-names
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r authored Dec 9, 2022
2 parents e40f394 + 8b3a35a commit a3833a0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ require (
github.com/docker/docker v20.10.21+incompatible
github.com/docker/go-units v0.5.0
github.com/gin-gonic/gin v1.8.1
github.com/go-vela/sdk-go v0.16.1
github.com/go-vela/server v0.16.1
github.com/go-vela/types v0.16.1
github.com/go-vela/sdk-go v0.16.2
github.com/go-vela/server v0.16.2
github.com/go-vela/types v0.16.2
github.com/google/go-cmp v0.5.9
github.com/joho/godotenv v1.4.0
github.com/opencontainers/image-spec v1.0.2
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXS
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-vela/sdk-go v0.16.1 h1:TrexXFMRQVs5UQXL9NV0Urv+sRu7RElKyVo8qK/yGLY=
github.com/go-vela/sdk-go v0.16.1/go.mod h1:fm8xpL9t1pBLdB9cQDHn8jyuQX8IapYzexD/cbQwKoc=
github.com/go-vela/server v0.16.1 h1:1ihfbBha098noeM9dbBNSVqj8PLaNy+Sw9VBtc7tabY=
github.com/go-vela/server v0.16.1/go.mod h1:vqSBrSJWw/OpynddskXDS5GggmlYpisQXODEWsGXk6k=
github.com/go-vela/types v0.16.1 h1:PGtOQ0AQLAFJ23wi6ns5JF1y68v4VjA/NbZs5HYZmhY=
github.com/go-vela/types v0.16.1/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
github.com/go-vela/sdk-go v0.16.2 h1:M9+u89mGomJc2uwUPVGWp9UnUIFm0IhIIsFEfxROhZQ=
github.com/go-vela/sdk-go v0.16.2/go.mod h1:BuTkw+MYWbAKJ6+ZtQ/nNmwIcjn/tysCPks4X+csBGE=
github.com/go-vela/server v0.16.2 h1:qovjGN9ZQazjV0JTXzP6o5UPSs1D+wyUMpbG4G6aXZI=
github.com/go-vela/server v0.16.2/go.mod h1:bf9dpkzhL2T6G6fxIwjmMjzoD+e5Xfmg3DcckP6lqHc=
github.com/go-vela/types v0.16.2 h1:c2Kkj7OKv4sjPrsOBbnPSQqfsNpOFM2La7LfP+81EF0=
github.com/go-vela/types v0.16.2/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down
2 changes: 1 addition & 1 deletion runtime/kubernetes/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func TestKubernetes_StreamBuild(t *testing.T) {
cancel()
} else if test.doReady {
// simulate AssembleBuild
close(_engine.PodTracker.Ready)
_engine.MarkPodTrackerReady()
}
}()

Expand Down
5 changes: 1 addition & 4 deletions runtime/kubernetes/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,8 @@ func TestKubernetes_WaitContainer(t *testing.T) {
}

go func() {
oldPod := test.oldPod.DeepCopy()
oldPod.SetResourceVersion("older")

// simulate a re-sync/PodUpdate event
_engine.PodTracker.HandlePodUpdate(oldPod, _engine.Pod)
_engine.SimulateResync(test.oldPod)
}()

err = _engine.WaitContainer(context.Background(), test.container)
Expand Down
31 changes: 31 additions & 0 deletions runtime/kubernetes/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,34 @@ func NewMock(_pod *v1.Pod, opts ...ClientOpt) (*client, error) {

return c, nil
}

// MockKubernetesRuntime makes it possible to use the client mocks in other packages.
//
// This interface is intended for running tests only.
type MockKubernetesRuntime interface {
MarkPodTrackerReady()
SimulateResync(*v1.Pod)
}

// MarkPodTrackerReady signals that PodTracker has been setup with ContainerTrackers.
//
// This function is intended for running tests only.
func (c *client) MarkPodTrackerReady() {
close(c.PodTracker.Ready)
}

// SimulateResync simulates an resync where the PodTracker refreshes its cache.
// This resync is from oldPod to runtime.Pod. If nil, oldPod defaults to runtime.Pod.
//
// This function is intended for running tests only.
func (c *client) SimulateResync(oldPod *v1.Pod) {
if oldPod == nil {
oldPod = c.Pod
}

oldPod = oldPod.DeepCopy()
oldPod.SetResourceVersion("older")

// simulate a re-sync/PodUpdate event
c.PodTracker.HandlePodUpdate(oldPod, c.Pod)
}

0 comments on commit a3833a0

Please sign in to comment.