private void initRuntimeInfo() { Boolean buildCommandProtocolEnabled = systemEnvironment.isBuildCommandProtocolEnabled(); agentAutoRegistrationProperties = new AgentAutoRegistrationPropertiesImpl(new File("config", "autoregister.properties")); if (agentAutoRegistrationProperties.isElastic()) { agentRuntimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), agentAutoRegistrationProperties.agentAutoRegisterElasticAgentId(), agentAutoRegistrationProperties.agentAutoRegisterElasticPluginId()); } else { agentRuntimeInfo = AgentRuntimeInfo.fromAgent(identifier, AgentStatus.Idle.getRuntimeStatus(), currentWorkingDirectory(), buildCommandProtocolEnabled); } }
@Test public void shouldRefreshUsableSpaceOfAgent() throws Exception { AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1"); String workingDirectory = FileUtils.getTempDirectory().getAbsolutePath(); AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, workingDirectory, false); long space = ElasticAgentRuntimeInfo.usableSpace(workingDirectory); assertThat(runtimeInfo.getUsableSpace(), is(space)); } }
@Test public void shouldRefreshOperatingSystemOfAgent() throws Exception { AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1"); AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, "/tmp/foo", false); String os = new SystemEnvironment().getOperatingSystemCompleteName(); assertThat(runtimeInfo.getOperatingSystem(), is(os)); }