|
@@ -180,9 +180,9 @@ func TestHTTPServer(t *testing.T) {
|
|
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
|
|
So(m.Size, ShouldEqual, status.Size)
|
|
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
|
|
- So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 1*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate), ShouldBeLessThan, 1*time.Second)
|
|
|
So(m.LastStarted.IsZero(), ShouldBeTrue) // hasn't been initialized yet
|
|
|
- So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 1*time.Second)
|
|
|
+ So(time.Since(m.LastEnded), ShouldBeLessThan, 1*time.Second)
|
|
|
|
|
|
})
|
|
|
|
|
@@ -208,11 +208,11 @@ func TestHTTPServer(t *testing.T) {
|
|
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
|
|
So(m.Size, ShouldEqual, status.Size)
|
|
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
|
|
- So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
|
|
|
- So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
|
|
- So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastEnded), ShouldBeGreaterThan, 1*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
|
|
|
+ So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
|
|
+ So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastEnded), ShouldBeGreaterThan, 1*time.Second)
|
|
|
|
|
|
})
|
|
|
|
|
@@ -228,9 +228,9 @@ func TestHTTPServer(t *testing.T) {
|
|
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
|
|
So(m.Size, ShouldEqual, status.Size)
|
|
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
|
|
- So(time.Now().Sub(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
|
|
|
- So(time.Now().Sub(m.LastEnded.Time), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
|
|
|
+ So(time.Since(m.LastEnded.Time), ShouldBeLessThan, 3*time.Second)
|
|
|
|
|
|
})
|
|
|
|
|
@@ -259,17 +259,17 @@ func TestHTTPServer(t *testing.T) {
|
|
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
|
|
So(m.Size, ShouldEqual, "5GB")
|
|
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
|
|
- So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
|
|
- So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
|
|
+ So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
Convey("Update schedule of valid mirrors", func(ctx C) {
|
|
|
msg := MirrorSchedules{
|
|
|
- []MirrorSchedule{
|
|
|
- MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
|
|
|
- MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
|
|
|
+ Schedules: []MirrorSchedule{
|
|
|
+ MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
|
|
|
+ MirrorSchedule{MirrorName: "arch-sync2", NextSchedule: time.Now().Add(time.Minute * 7)},
|
|
|
},
|
|
|
}
|
|
|
|
|
@@ -313,9 +313,9 @@ func TestHTTPServer(t *testing.T) {
|
|
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
|
|
So(m.Size, ShouldEqual, status.Size)
|
|
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
|
|
- So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
|
|
|
- So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 1*time.Second)
|
|
|
+ So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
|
|
|
+ So(time.Since(m.LastEnded), ShouldBeLessThan, 1*time.Second)
|
|
|
})
|
|
|
})
|
|
|
|
|
@@ -345,9 +345,9 @@ func TestHTTPServer(t *testing.T) {
|
|
|
Convey("update schedule of an non-existent worker", func(ctx C) {
|
|
|
invalidWorker := "test_worker2"
|
|
|
sch := MirrorSchedules{
|
|
|
- []MirrorSchedule{
|
|
|
- MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
|
|
|
- MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
|
|
|
+ Schedules: []MirrorSchedule{
|
|
|
+ MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
|
|
|
+ MirrorSchedule{MirrorName: "arch-sync2", NextSchedule: time.Now().Add(time.Minute * 7)},
|
|
|
},
|
|
|
}
|
|
|
resp, err := PostJSON(fmt.Sprintf("%s/workers/%s/schedules",
|