mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 14:27:26 +01:00
Merge pull request #667 from cheng--zhang/CA-182881
CA-182881: Fix issue in schedule check in HealthCheckService
This commit is contained in:
commit
d4f736d296
@ -183,13 +183,13 @@ namespace XenServerHealthCheck
|
||||
}
|
||||
|
||||
int TimeOfDay = IntKey(config, HealthCheckSettings.TIME_OF_DAY, HealthCheckSettings.GetDefaultTime());
|
||||
if (currentTime.DayOfWeek != dayOfWeek && currentTime.Hour != TimeOfDay)
|
||||
if (currentTime.DayOfWeek != dayOfWeek || currentTime.Hour != TimeOfDay)
|
||||
{
|
||||
log.InfoFormat("Will not report for XenServer {0} for incorrect schedule", connection.Hostname);
|
||||
return false;
|
||||
}
|
||||
log.InfoFormat("Upload schedule for {0} is {1}:{2}, meet current time {3}", connection.Hostname, dayOfWeek, TimeOfDay, currentTime.ToString());
|
||||
}
|
||||
|
||||
return getLock(connection, session);
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,27 @@ namespace XenServerHealthCheckTests
|
||||
config[HealthCheckSettings.LAST_FAILED_UPLOAD] = "asd";
|
||||
Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config);
|
||||
Assert.IsFalse (RequestUploadTask.Request(connection, _session));
|
||||
|
||||
//13. For schedule not meet the day
|
||||
config = cleanStack();
|
||||
config[HealthCheckSettings.DAY_OF_WEEK] = (DateTime.UtcNow.DayOfWeek +1).ToString();
|
||||
config[HealthCheckSettings.TIME_OF_DAY] = DateTime.UtcNow.Hour.ToString();
|
||||
Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config);
|
||||
Assert.IsFalse (RequestUploadTask.Request(connection, _session));
|
||||
|
||||
//14. For schedule not meet the hour
|
||||
config = cleanStack();
|
||||
config[HealthCheckSettings.DAY_OF_WEEK] = DateTime.UtcNow.DayOfWeek.ToString();
|
||||
config[HealthCheckSettings.TIME_OF_DAY] = (DateTime.UtcNow.Hour + 1).ToString();
|
||||
Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config);
|
||||
Assert.IsFalse(RequestUploadTask.Request(connection, _session));
|
||||
|
||||
//15. For schedule all meet
|
||||
config = cleanStack();
|
||||
config[HealthCheckSettings.DAY_OF_WEEK] = DateTime.UtcNow.DayOfWeek.ToString();
|
||||
config[HealthCheckSettings.TIME_OF_DAY] = (DateTime.UtcNow.Hour).ToString();
|
||||
Pool.set_health_check_config(_session, connection.Cache.Pools[0].opaque_ref, config);
|
||||
Assert.IsTrue(RequestUploadTask.Request(connection, _session));
|
||||
}
|
||||
catch (Exception)
|
||||
{}
|
||||
|
Loading…
Reference in New Issue
Block a user