tests for watchers
parent
435b6eb91b
commit
67ec485b39
|
@ -112,6 +112,80 @@ func TestProvider_checkVersionedDeployment(t *testing.T) {
|
||||||
wantShouldUpdateDeployment: true,
|
wantShouldUpdateDeployment: true,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "staging pre-release",
|
||||||
|
args: args{
|
||||||
|
newVersion: unsafeGetVersion("v1.1.2-staging"),
|
||||||
|
policy: types.PolicyTypeMinor,
|
||||||
|
repo: &types.Repository{Name: "gcr.io/v2-namespace/hello-prerelease", Tag: "v1.1.2-staging"},
|
||||||
|
resource: MustParseGR(&apps_v1.Deployment{
|
||||||
|
meta_v1.TypeMeta{},
|
||||||
|
meta_v1.ObjectMeta{
|
||||||
|
Name: "dep-1",
|
||||||
|
Namespace: "xxxx",
|
||||||
|
Annotations: map[string]string{},
|
||||||
|
Labels: map[string]string{types.KeelPolicyLabel: "minor"},
|
||||||
|
},
|
||||||
|
apps_v1.DeploymentSpec{
|
||||||
|
Template: v1.PodTemplateSpec{
|
||||||
|
ObjectMeta: meta_v1.ObjectMeta{
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"this": "that",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: v1.PodSpec{
|
||||||
|
Containers: []v1.Container{
|
||||||
|
v1.Container{
|
||||||
|
Image: "gcr.io/v2-namespace/hello-prerelease:v1.1.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
apps_v1.DeploymentStatus{},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
wantUpdatePlan: &UpdatePlan{},
|
||||||
|
wantShouldUpdateDeployment: false,
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "normal new tag while there's pre-release",
|
||||||
|
args: args{
|
||||||
|
newVersion: unsafeGetVersion("v1.1.2"),
|
||||||
|
policy: types.PolicyTypeMinor,
|
||||||
|
repo: &types.Repository{Name: "gcr.io/v2-namespace/hello-prerelease", Tag: "v1.1.2"},
|
||||||
|
resource: MustParseGR(&apps_v1.Deployment{
|
||||||
|
meta_v1.TypeMeta{},
|
||||||
|
meta_v1.ObjectMeta{
|
||||||
|
Name: "dep-1",
|
||||||
|
Namespace: "xxxx",
|
||||||
|
Annotations: map[string]string{},
|
||||||
|
Labels: map[string]string{types.KeelPolicyLabel: "minor"},
|
||||||
|
},
|
||||||
|
apps_v1.DeploymentSpec{
|
||||||
|
Template: v1.PodTemplateSpec{
|
||||||
|
ObjectMeta: meta_v1.ObjectMeta{
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"this": "that",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: v1.PodSpec{
|
||||||
|
Containers: []v1.Container{
|
||||||
|
v1.Container{
|
||||||
|
Image: "gcr.io/v2-namespace/hello-prerelease:v1.1.1-staging",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
apps_v1.DeploymentStatus{},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
wantUpdatePlan: &UpdatePlan{},
|
||||||
|
wantShouldUpdateDeployment: false,
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "standard ignore version bump",
|
name: "standard ignore version bump",
|
||||||
args: args{
|
args: args{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package poll
|
package poll
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -369,3 +370,61 @@ func TestWatchTagJobCheckCredentials(t *testing.T) {
|
||||||
t.Errorf("unexpected username for registry: %s", frc.opts.Username)
|
t.Errorf("unexpected username for registry: %s", frc.opts.Username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWatchTagJobLatestECR(t *testing.T) {
|
||||||
|
if os.Getenv("AWS_ACCESS_KEY_ID") == "" {
|
||||||
|
t.Skip()
|
||||||
|
}
|
||||||
|
|
||||||
|
imgA, _ := image.Parse("528670773427.dkr.ecr.us-east-2.amazonaws.com/webhook-demo:master")
|
||||||
|
fp := &fakeProvider{
|
||||||
|
images: []*types.TrackedImage{
|
||||||
|
&types.TrackedImage{
|
||||||
|
Image: imgA,
|
||||||
|
Trigger: types.TriggerTypePoll,
|
||||||
|
Provider: "fp",
|
||||||
|
PollSchedule: types.KeelPollDefaultSchedule,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
mem := memory.NewMemoryCache(100*time.Millisecond, 100*time.Millisecond, 10*time.Millisecond)
|
||||||
|
am := approvals.New(mem, codecs.DefaultSerializer())
|
||||||
|
providers := provider.New([]provider.Provider{fp}, am)
|
||||||
|
rc := registry.New()
|
||||||
|
|
||||||
|
details := &watchDetails{
|
||||||
|
trackedImage: &types.TrackedImage{
|
||||||
|
Image: imgA,
|
||||||
|
},
|
||||||
|
digest: "sha256:123123123",
|
||||||
|
}
|
||||||
|
|
||||||
|
job := NewWatchTagJob(providers, rc, details)
|
||||||
|
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
job.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// checking whether new job was submitted
|
||||||
|
|
||||||
|
submitted := fp.submitted[0]
|
||||||
|
|
||||||
|
if submitted.Repository.Name != "528670773427.dkr.ecr.us-east-2.amazonaws.com/webhook-demo" {
|
||||||
|
t.Errorf("unexpected event repository name: %s", submitted.Repository.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if submitted.Repository.Tag != "master" {
|
||||||
|
t.Errorf("unexpected event repository tag: %s", submitted.Repository.Tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
if submitted.Repository.Digest != "sha256:7712aa425c17c2e413e5f4d64e2761eda009509d05d0e45a26e389d715aebe23" {
|
||||||
|
t.Errorf("unexpected event repository digest: %s", submitted.Repository.Digest)
|
||||||
|
}
|
||||||
|
|
||||||
|
// digest should be updated
|
||||||
|
|
||||||
|
if job.details.digest != "sha256:7712aa425c17c2e413e5f4d64e2761eda009509d05d0e45a26e389d715aebe23" {
|
||||||
|
t.Errorf("job details digest wasn't updated")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue