use of com.thoughtworks.go.domain.GoVersion in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour.
@Test
public void shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour() {
SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
Date yesterday = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
DateTime halfAnHourFromNow = new DateTime(System.currentTimeMillis() - 35 * 60 * 1000);
VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), yesterday);
when(builder.getServerVersionInfo()).thenReturn(versionInfo);
when(systemTimeClock.currentDateTime()).thenReturn(halfAnHourFromNow);
manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
manager.initialize();
VersionInfo serverVersionInfo1 = manager.versionInfoForUpdate();
VersionInfo serverVersionInfo2 = manager.versionInfoForUpdate();
assertNotNull(serverVersionInfo1);
assertNotNull(serverVersionInfo2);
}
use of com.thoughtworks.go.domain.GoVersion in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldAddNewVersionInfoToCacheIfLatestVersionIsGreaterThanInstalledVersion.
@Test
public void shouldAddNewVersionInfoToCacheIfLatestVersionIsGreaterThanInstalledVersion() {
GoVersion currentVersion = new GoVersion("1.2.3-1");
GoVersion latestVersion = new GoVersion("2.3.4-2");
VersionInfo versionInfo = new VersionInfo("go_server", currentVersion, latestVersion, null);
when(builder.getServerVersionInfo()).thenReturn(versionInfo);
manager.initialize();
verify(builder).getServerVersionInfo();
verify(goCache).put("GOUpdate", latestVersion.toString());
}
use of com.thoughtworks.go.domain.GoVersion in project gocd by gocd.
the class ServerVersionInfoBuilder method installedVersion.
private GoVersion installedVersion() {
GoVersion version = null;
String installedVersion = serverVersion.version();
try {
version = new GoVersion(installedVersion);
} catch (VersionFormatException e) {
LOGGER.error("[Go Update Check] Server Version: {} format is Invalid.", installedVersion);
}
return version;
}
use of com.thoughtworks.go.domain.GoVersion in project gocd by gocd.
the class ServerVersionInfoBuilder method update.
private VersionInfo update(VersionInfo versionInfo) {
GoVersion currentGoVersion = installedVersion();
if (currentGoVersion == null)
return versionInfo;
if (!isServerVersionInfoUpToDate(versionInfo, currentGoVersion)) {
versionInfo.setInstalledVersion(currentGoVersion);
versionInfoDao.saveOrUpdate(versionInfo);
}
return versionInfo;
}
use of com.thoughtworks.go.domain.GoVersion in project gocd by gocd.
the class ServerVersionInfoManager method updateLatestVersion.
public VersionInfo updateLatestVersion(String latestVersion) {
synchronized (VERSION_INFO_MUTEX) {
serverVersionInfo.setLatestVersion(new GoVersion(latestVersion));
serverVersionInfo.setLatestVersionUpdatedAt(clock.currentTime());
versionInfoDao.saveOrUpdate(serverVersionInfo);
versionInfoUpdatingFrom = null;
addGoUpdateToCacheIfAvailable();
LOGGER.info("[Go Update Check] Update check done at: {}, latest available version: {}", new Date(), latestVersion);
return serverVersionInfo;
}
}
Aggregations