use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class EmailMessageDrafterTest method shouldDraftNoArtifactDiskSpaceEmail.
@Test
public void shouldDraftNoArtifactDiskSpaceEmail() throws Exception {
String size = "2345";
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, size);
String email = "admin@mail.com";
SendEmailMessage message = EmailMessageDrafter.noArtifactsDiskSpaceMessage(new SystemEnvironment(), email, artifactRoot);
String ip = SystemUtil.getFirstLocalNonLoopbackIpAddress();
assertThat(message, is(new SendEmailMessage("No artifacts disk space error message from Go Server at " + ip, noArtifactDiskSpaceEmail(ip, size), email)));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class EmailMessageDrafterTest method tearDown.
@After
public void tearDown() throws Exception {
new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT);
new SystemEnvironment().clearProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT);
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class BuildAssignmentServiceTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
buildAssignmentService = new BuildAssignmentService(goConfigService, jobInstanceService, scheduleService, agentService, environmentConfigService, transactionTemplate, scheduledPipelineLoader, pipelineService, builderFactory, agentRemoteHandler, elasticAgentPluginService, systemEnvironment);
elasticProfileId1 = "elastic.profile.id.1";
elasticProfileId2 = "elastic.profile.id.2";
elasticAgent = AgentMother.elasticAgent();
elasticAgentInstance = AgentInstance.createFromConfig(elasticAgent, new SystemEnvironment(), null);
regularAgentInstance = AgentInstance.createFromConfig(AgentMother.approvedAgent(), new SystemEnvironment(), null);
elasticProfile1 = new ElasticProfile(elasticProfileId1, elasticAgent.getElasticPluginId());
elasticProfile2 = new ElasticProfile(elasticProfileId2, elasticAgent.getElasticPluginId());
jobPlans = new ArrayList<>();
HashMap<String, ElasticProfile> profiles = new HashMap<>();
profiles.put(elasticProfile1.getId(), elasticProfile1);
profiles.put(elasticProfile2.getId(), elasticProfile2);
schedulingContext = new DefaultSchedulingContext("me", new Agents(elasticAgent), profiles);
when(jobInstanceService.orderedScheduledBuilds()).thenReturn(jobPlans);
when(environmentConfigService.filterJobsByAgent(Matchers.eq(jobPlans), any(String.class))).thenReturn(jobPlans);
when(environmentConfigService.envForPipeline(any(String.class))).thenReturn("");
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.
@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
String expectedHelpUrl = "https://docs.gocd.org/current/installation/configuring_server_details.html";
ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://test.host"), new ServerSiteUrlConfig("https://test.host"));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(serverConfig);
GoConfigService goConfigService = mock(GoConfigService.class);
when(goConfigService.artifactsDir()).thenReturn(null);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(goConfigService.adminEmail()).thenReturn("admin@email.com");
ArtifactsDiskSpaceFullChecker diskSpaceFullChecker = new ArtifactsDiskSpaceFullChecker(new SystemEnvironment(), null, goConfigService, null) {
@Override
protected String targetFolderCanonicalPath() {
return "";
}
};
SendEmailMessage actual = diskSpaceFullChecker.createEmail();
assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DiskSpaceWarningCheckerTest method shouldShowAbsolutePathOfArtifactDirInWarningMessage.
// #2866
@Test
public void shouldShowAbsolutePathOfArtifactDirInWarningMessage() throws IOException, URISyntaxException {
goConfigService = mockGoConfigServiceToHaveSiteUrl();
TestingEmailSender sender = new TestingEmailSender();
SystemEnvironment systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT, "1200009M");
ArtifactsDiskSpaceWarningChecker checker = new ArtifactsDiskSpaceWarningChecker(systemEnvironment, sender, goConfigService, new SystemDiskSpaceChecker(), serverHealthService);
checker.check(new ServerHealthStateOperationResult());
assertThat(sender.getSentMessage(), containsString(new File(".").getCanonicalPath()));
}
Aggregations