Search in sources :

Example 6 with GoVersion

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);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 7 with GoVersion

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());
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Test(org.junit.Test)

Example 8 with GoVersion

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;
}
Also used : VersionFormatException(com.thoughtworks.go.domain.exception.VersionFormatException) GoVersion(com.thoughtworks.go.domain.GoVersion)

Example 9 with GoVersion

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;
}
Also used : GoVersion(com.thoughtworks.go.domain.GoVersion)

Example 10 with GoVersion

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;
    }
}
Also used : GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date)

Aggregations

GoVersion (com.thoughtworks.go.domain.GoVersion)17 VersionInfo (com.thoughtworks.go.domain.VersionInfo)14 Test (org.junit.Test)13 Date (java.util.Date)9 SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)3 VersionFormatException (com.thoughtworks.go.domain.exception.VersionFormatException)1 DateTime (org.joda.time.DateTime)1