Search in sources :

Example 11 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class DiskSpaceFullCheckerTest method shouldReturnTrueIfTheArtifactFolderHasSizeLimit.

@Test
public void shouldReturnTrueIfTheArtifactFolderHasSizeLimit() {
    new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1M");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
    ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    fullChecker.check(result);
    assertThat(result.canContinue(), is(true));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 12 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class ArtifactsDiskCleaner method deleteOldArtifacts.

void deleteOldArtifacts() {
    ServerConfig serverConfig = goConfigService.serverConfig();
    Double requiredSpaceInGb = serverConfig.getPurgeUpto();
    if (serverConfig.isArtifactPurgingAllowed()) {
        double requiredSpace = requiredSpaceInGb * GoConstants.GIGA_BYTE;
        LOGGER.info(String.format("Clearing old artifacts as the disk space is low. Current space: '%s'. Need to clear till we hit: '%s'.", availableSpace(), requiredSpace));
        List<Stage> stages;
        int numberOfStagesPurged = 0;
        do {
            configDbStateRepository.flushConfigState();
            stages = stageService.oldestStagesWithDeletableArtifacts();
            for (Stage stage : stages) {
                if (availableSpace() > requiredSpace) {
                    break;
                }
                numberOfStagesPurged++;
                artifactService.purgeArtifactsForStage(stage);
            }
        } while ((availableSpace() < requiredSpace) && !stages.isEmpty());
        if (availableSpace() < requiredSpace) {
            LOGGER.warn("Ran out of stages to clear artifacts from but the disk space is still low");
        }
        LOGGER.info(String.format("Finished clearing old artifacts. Deleted artifacts for '%s' stages. Current space: '%s'", numberOfStagesPurged, availableSpace()));
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) Stage(com.thoughtworks.go.domain.Stage)

Example 13 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class ArtifactDirValidator method validate.

public void validate(CruiseConfig cruiseConfig) throws Exception {
    ServerConfig serverConfig = cruiseConfig.server();
    String artifactDir = serverConfig.artifactsDir();
    if (isEmpty(artifactDir)) {
        throw new Exception("Please provide a not empty value for artifactsdir");
    }
    if (StringUtils.equals(".", artifactDir) || new File("").getAbsolutePath().equals(new File(artifactDir).getAbsolutePath())) {
        throw new Exception("artifactsdir should not point to the root of sand box [" + new File(artifactDir).getAbsolutePath() + "]");
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) File(java.io.File)

Example 14 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class BaseUrlChangeListener method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    ServerConfig newServerConfig = newCruiseConfig.server();
    ServerSiteUrlConfig newSecureSiteUrl = newServerConfig.getSecureSiteUrl();
    ServerSiteUrlConfig newSiteUrl = newServerConfig.getSiteUrl();
    if (!(secureSiteUrl.equals(newSecureSiteUrl) && siteUrl.equals(newSiteUrl))) {
        goCache.remove(URLS_CACHE_KEY);
        LOGGER.info(String.format("[Configuration Changed] Site URL was changed from [%s] to [%s] and " + "Secure Site URL was changed from [%s] to [%s]", siteUrl, newSiteUrl, secureSiteUrl, newSecureSiteUrl));
    }
    setUrls(newSiteUrl, newSecureSiteUrl);
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig)

Example 15 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesDot.

@Test
public void shouldThrowExceptionWhenUserProvidesDot() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception, see dot will make server check out the repository in the wrong place.");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Aggregations

ServerConfig (com.thoughtworks.go.config.ServerConfig)21 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)12 Test (org.junit.Test)12 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)11 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 Username (com.thoughtworks.go.server.domain.Username)4 File (java.io.File)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)3 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 Before (org.junit.Before)2 Stage (com.thoughtworks.go.domain.Stage)1 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1