Commit 60cffa81 authored by Alex Dadgar's avatar Alex Dadgar
Browse files

Unix timestamps not UnixNano

parent 9d6c2e24
Branches unavailable v1.4.3 v1.4.2 v1.4.1 v1.4.0 v1.4.0-rc.1 v1.4.0-beta.1 v1.3.8 v1.3.7 v1.3.6 v1.3.5 v1.3.4 v1.3.3 v1.3.2 v1.3.1 v1.3.0 v1.3.0-rc.1 v1.3.0-beta.1 v1.2.15 v1.2.14 v1.2.13 v1.2.12 v1.2.11 v1.2.10 v1.2.9 v1.2.8 v1.2.7 v1.2.6 v1.2.5 v1.2.4 v1.2.3 v1.2.2 v1.2.1 v1.2.0 v1.2.0-rc1 v1.2.0-beta1 v1.1.18 v1.1.17 v1.1.16 v1.1.15 v1.1.14 v1.1.13 v1.1.12 v1.1.11 v1.1.10 v1.1.9 v1.1.8 v1.1.7 v1.1.6 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.1.0-rc1 v1.1.0-beta1 v1.0.18 v1.0.17 v1.0.16 v1.0.15 v1.0.14 v1.0.13 v1.0.12 v1.0.11 v1.0.10 v1.0.9 v1.0.8 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0.0 v1.0.0-rc1 v1.0.0-beta3 v1.0.0-beta2 v0.12.12 v0.12.11 v0.12.10 v0.12.9 v0.12.8 v0.12.7 v0.12.6 v0.12.5 v0.12.4 v0.12.4-rc1 v0.12.3 v0.12.2 v0.12.1 v0.12.0 v0.12.0-rc1 v0.12.0-beta2 v0.12.0-beta1 v0.11.8 v0.11.7 v0.11.6 v0.11.5 v0.11.4 v0.11.3 v0.11.2 v0.11.1 v0.11.0 v0.11.0-rc1 v0.11.0-beta2 v0.11.0-beta1 v0.10.9 v0.10.8 v0.10.7 v0.10.6 v0.10.5 v0.10.4 v0.10.4-rc1 v0.10.3 v0.10.2 v0.10.2-rc1 v0.10.1 v0.10.0 v0.10.0-rc1 v0.10.0-connect1 v0.10.0-beta1 v0.9.7 v0.9.6 v0.9.5 v0.9.4 v0.9.4-rc1 v0.9.3 v0.9.2 v0.9.2-rc1 v0.9.1 v0.9.1-rc1 v0.9.0 v0.9.0-rc2 v0.9.0-rc1 v0.9.0-beta3 v0.9.0-beta2 v0.9.0-beta1 v0.8.7 v0.8.7-rc1 v0.8.6 v0.8.5 v0.8.4 v0.8.4-rc1 v0.8.3 v0.8.2 v0.8.1 v0.8.0 v0.8.0-rc1 v0.7.1 v0.7.1-rc1 v0.7.1-rc1+pro v0.7.1-rc1+ent v0.7.0 v0.7.0+pro v0.7.0+ent v0.7.0-rc3 v0.7.0-rc2 v0.7.0-rc1 v0.7.0-beta1 v0.6.3 v0.6.3-rc1 v0.6.2 v0.6.1 v0.6.0 v0.6.0-rc2 v0.6.0-rc1 v0.5.6 v0.5.6-rc1 v0.5.5 v0.5.5-rc2 v0.5.5-rc1 v0.5.4 v0.5.3 v0.5.3-rc1 v0.5.2 v0.5.2-rc1 v0.5.1 v0.5.1-rc2 v0.5.1-rc1 v0.5.0 v0.5.0-rc2 v0.5.0-rc1 v0.4.3 v0.4.2 v0.4.1 v0.4.1-rc1 v0.4.0 v0.4.0-rc2 v0.4.0-rc1 v0.3.2 v0.3.2-rc2 v0.3.2-rc1 v0.3.1 v0.3.0 v0.3.0-rc2 v0.3rc1 nightly
No related merge requests found
Showing with 15 additions and 15 deletions
+15 -15
......@@ -398,7 +398,7 @@ func (p *PeriodicDispatch) deriveJob(periodicJob *structs.Job, time time.Time) (
// deriveJobID returns a job ID based on the parent periodic job and the launch
// time.
func (p *PeriodicDispatch) derivedJobID(periodicJob *structs.Job, time time.Time) string {
return fmt.Sprintf("%s%s%d", periodicJob.ID, JobLaunchSuffix, time.UnixNano())
return fmt.Sprintf("%s%s%d", periodicJob.ID, JobLaunchSuffix, time.Unix())
}
// LaunchTime returns the launch time of the job. This is only valid for
......@@ -414,7 +414,7 @@ func (p *PeriodicDispatch) LaunchTime(jobID string) (time.Time, error) {
return time.Time{}, fmt.Errorf("couldn't parse launch time from eval: %v", jobID)
}
return time.Unix(0, int64(launch)), nil
return time.Unix(int64(launch), 0), nil
}
// Flush clears the state of the PeriodicDispatcher
......
......@@ -78,7 +78,7 @@ func testPeriodicJob(times ...time.Time) *structs.Job {
l := make([]string, len(times))
for i, t := range times {
l[i] = strconv.Itoa(int(t.UnixNano()))
l[i] = strconv.Itoa(int(t.Round(1 * time.Second).Unix()))
}
job.Periodic.Spec = strings.Join(l, ",")
......@@ -166,8 +166,8 @@ func TestPeriodicDispatch_Add_TriggersUpdate(t *testing.T) {
}
// Update it to be sooner and re-add.
expected := time.Now().Add(1 * time.Second)
job.Periodic.Spec = fmt.Sprintf("%d", expected.UnixNano())
expected := time.Now().Round(1 * time.Second).Add(1 * time.Second)
job.Periodic.Spec = fmt.Sprintf("%d", expected.Unix())
if err := p.Add(job); err != nil {
t.Fatalf("Add failed %v", err)
}
......@@ -293,8 +293,8 @@ func TestPeriodicDispatch_Run_Multiple(t *testing.T) {
p, m := testPeriodicDispatcher()
// Create a job that will be launched twice.
launch1 := time.Now().Add(1 * time.Second)
launch2 := time.Now().Add(2 * time.Second)
launch1 := time.Now().Round(1 * time.Second).Add(1 * time.Second)
launch2 := time.Now().Round(1 * time.Second).Add(2 * time.Second)
job := testPeriodicJob(launch1, launch2)
// Add it.
......@@ -325,7 +325,7 @@ func TestPeriodicDispatch_Run_SameTime(t *testing.T) {
p, m := testPeriodicDispatcher()
// Create two job that will be launched at the same time.
launch := time.Now().Add(1 * time.Second)
launch := time.Now().Round(1 * time.Second).Add(1 * time.Second)
job := testPeriodicJob(launch)
job2 := testPeriodicJob(launch)
......@@ -362,11 +362,11 @@ func TestPeriodicDispatch_Complex(t *testing.T) {
p, m := testPeriodicDispatcher()
// Create some jobs launching at different times.
now := time.Now()
now := time.Now().Round(1 * time.Second)
same := now.Add(1 * time.Second)
launch1 := same.Add(1 * time.Second)
launch2 := same.Add(1500 * time.Millisecond)
launch3 := same.Add(2 * time.Second)
launch2 := same.Add(2 * time.Second)
launch3 := same.Add(3 * time.Second)
invalid := now.Add(-200 * time.Second)
// Create two jobs launching at the same time.
......@@ -417,7 +417,7 @@ func TestPeriodicDispatch_Complex(t *testing.T) {
}
}
time.Sleep(4 * time.Second)
time.Sleep(5 * time.Second)
actual := make(map[string][]time.Time, len(expected))
for _, job := range jobs {
launches, err := m.LaunchTimes(p, job.ID)
......@@ -439,7 +439,7 @@ func TestPeriodicDispatch_NextLaunch(t *testing.T) {
// Create two job that will be launched at the same time.
invalid := time.Unix(0, 0)
expected := time.Now().Add(1 * time.Second)
expected := time.Now().Round(1 * time.Second).Add(1 * time.Second)
job := testPeriodicJob(invalid)
job2 := testPeriodicJob(expected)
......
......@@ -938,7 +938,7 @@ const (
PeriodicSpecCron = "cron"
// PeriodicSpecTest is only used by unit tests. It is a sorted, comma
// seperated list of unix nanosecond timestamps at which to launch.
// seperated list of unix timestamps at which to launch.
PeriodicSpecTest = "_internal_test"
)
......@@ -1003,7 +1003,7 @@ func (p *PeriodicConfig) Next(fromTime time.Time) time.Time {
return time.Time{}
}
times[i] = time.Unix(0, int64(unix))
times[i] = time.Unix(int64(unix), 0)
}
// Find the next match
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment