@Test public void shouldReturnThePipelineName() { AgentBuildingInfo agentBuildingInfo = new AgentBuildingInfo("buildInfo", "foo"); assertThat(agentBuildingInfo.getPipelineName(), is("foo")); }
@Test public void shouldReturnTheStageName() { AgentBuildingInfo agentBuildingInfo = new AgentBuildingInfo("buildInfo", "foo/1/bar"); assertThat(agentBuildingInfo.getStageName(), is("bar")); }
@Before public void setUp() { systemEnvironment = new SystemEnvironment(); agentConfig = new AgentConfig("uuid2", "CCeDev01", DEFAULT_IP_ADDRESS); defaultBuildingInfo = new AgentBuildingInfo("pipeline", "buildLocator"); agentStatusChangeListener = mock(AgentStatusChangeListener.class); }
@Test public void shouldReturnTheJobName() { AgentBuildingInfo agentBuildingInfo = new AgentBuildingInfo("buildInfo", "foo/1/bar/3/job"); assertThat(agentBuildingInfo.getJobName(), is("job")); }
@Test public void shouldReturnNullTheJobName() { AgentBuildingInfo agentBuildingInfo = new AgentBuildingInfo("buildInfo", "foo"); assertNull(agentBuildingInfo.getJobName()); }
@Test public void shouldReturnNullForStageName() { AgentBuildingInfo agentBuildingInfo = new AgentBuildingInfo("buildInfo", "foo"); assertNull(agentBuildingInfo.getStageName()); }
@Test public void shouldNotifyAgentChangeListenerOnAgentBuilding() throws Exception { AgentInstance idleAgent = AgentInstance.createFromConfig(agentConfig("abc"), new SystemEnvironment(), agentStatusChangeListener); idleAgent.building(new AgentBuildingInfo("running pipeline/stage/build", "buildLocator")); verify(agentStatusChangeListener).onAgentStatusChange(idleAgent); }
@Test public void shouldUpdateBuildingInfoWhenAgentIsBuilding() throws Exception { AgentInstance agentInstance = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class)); AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); AgentBuildingInfo buildingInfo = new AgentBuildingInfo("running pipeline/stage/build", "buildLocator"); agentRuntimeInfo.busy(buildingInfo); agentInstance.update(agentRuntimeInfo); assertThat(agentInstance.getBuildingInfo(), is(buildingInfo)); }
public static AgentInstance lostContact(String buildLocator) { AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1"); AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class)); AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig); newRuntimeInfo.setStatus(AgentStatus.LostContact); newRuntimeInfo.setUsableSpace(1000L); newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator)); instance.update(newRuntimeInfo); return instance; }
public static AgentInstance building(String buildLocator, SystemEnvironment systemEnvironment) { AgentConfig buildingAgentConfig = new AgentConfig("uuid3", "CCeDev01", "10.18.5.1", new ResourceConfigs("java")); AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(buildingAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); agentRuntimeInfo.busy(new AgentBuildingInfo("pipeline", buildLocator)); AgentInstance building = AgentInstance.createFromConfig(buildingAgentConfig, systemEnvironment, mock(AgentStatusChangeListener.class)); building.update(agentRuntimeInfo); return building; }
agentRuntimeInfo.busy(new AgentBuildingInfo("build1ForDisplay", "build1"));
@Override public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) { cancelLatch = new CountDownLatch(1); agentWorkContext.getAgentRuntimeInfo().busy(new AgentBuildingInfo("sleepwork", "sleepwork1")); boolean canceled = false; DefaultGoPublisher goPublisher = new DefaultGoPublisher(agentWorkContext.getArtifactsManipulator(), new JobIdentifier(), agentWorkContext.getRepositoryRemote(), agentWorkContext.getAgentRuntimeInfo(), "utf-8"); try { if (this.sleepInMilliSeconds > 0) { canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS); } String result = canceled ? "done_canceled" : "done"; agentWorkContext.getArtifactsManipulator().setProperty(null, new Property(name + "_result", result)); SystemEnvironment systemEnvironment = new SystemEnvironment(); if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) { goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds)); } } catch (InterruptedException e) { throw new RuntimeException(e); } }
agentRuntimeInfo.busy(new AgentBuildingInfo("build1ForDisplay", "build1"));
if (job != null) { Work buildWork = createWork(agent, job); AgentBuildingInfo buildingInfo = new AgentBuildingInfo(job.getIdentifier().buildLocatorForDisplay(), job.getIdentifier().buildLocator()); agentService.building(agent.getUuid(), buildingInfo);
agentRuntimeInfo.busy(new AgentBuildingInfo("build1ForDisplay", "build1")); agentRuntimeInfo.cancel();
private void initialize(AgentWorkContext agentWorkContext) { JobIdentifier jobIdentifier = assignment.getJobIdentifier(); this.timeProvider = new TimeProvider(); agentWorkContext.getAgentRuntimeInfo().busy(new AgentBuildingInfo(jobIdentifier.buildLocatorForDisplay(), jobIdentifier.buildLocator())); this.workingDirectory = assignment.getWorkingDirectory(); this.materialRevisions = assignment.materialRevisions(); this.goPublisher = new DefaultGoPublisher(agentWorkContext.getArtifactsManipulator(), jobIdentifier, agentWorkContext.getRepositoryRemote(), agentWorkContext.getAgentRuntimeInfo(), consoleLogCharset); this.artifactsPublisher = new ArtifactsPublisher(goPublisher, agentWorkContext.getArtifactExtension(), assignment.getArtifactStores(), agentWorkContext.getPluginRequestProcessorRegistry(), workingDirectory); this.builders = new Builders(assignment.getBuilders(), goPublisher, agentWorkContext.getTaskExtension(), agentWorkContext.getArtifactExtension(), agentWorkContext.getPluginRequestProcessorRegistry()); }
@Test public void shouldUpdateSelfForAnIdleAgent() { AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), null, false); AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("go02", "10.10.10.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("Idle", "")); newRuntimeInfo.setLocation("home"); newRuntimeInfo.setUsableSpace(10L); newRuntimeInfo.setOperatingSystem("Linux"); agentRuntimeInfo.updateSelf(newRuntimeInfo); assertThat(agentRuntimeInfo.getBuildingInfo(), is(newRuntimeInfo.getBuildingInfo())); assertThat(agentRuntimeInfo.getLocation(), is(newRuntimeInfo.getLocation())); assertThat(agentRuntimeInfo.getUsableSpace(), is(newRuntimeInfo.getUsableSpace())); assertThat(agentRuntimeInfo.getOperatingSystem(), is(newRuntimeInfo.getOperatingSystem())); }
getAgentRuntimeInfo().idle(); try { getAgentRuntimeInfo().busy(new AgentBuildingInfo(buildSettings.getBuildLocatorForDisplay(), buildSettings.getBuildLocator())); build.build(buildSettings.getBuildCommand()); } finally {