Esempio n. 1
0
  @Test
  public void shouldFindAgentsByItHostName() throws Exception {
    AgentInstance idle = AgentInstanceMother.idle(new Date(), "ghost-name");
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, idle, AgentInstanceMother.building());

    AgentInstance byHostname = agentInstances.findFirstByHostname("ghost-name");
    assertThat(byHostname, is(idle));
  }
Esempio n. 2
0
 @Test
 public void shouldAddUpAgentsByStatus() {
   AgentInstances agentInstances = new AgentInstances(null);
   agentInstances.add(idle);
   agentInstances.add(building);
   agentInstances.add(AgentInstanceMother.updateUuid(AgentInstanceMother.building(), "blah"));
   assertThat(agentInstances.numberOf(AgentStatus.Building), is(2));
   assertThat(agentInstances.numberOf(AgentStatus.Idle), is(1));
 }
Esempio n. 3
0
  @Test
  public void shouldReturnEmtpyAgentInstancesWhenNothingMatched() throws Exception {
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.building());
    agentInstances.add(pending);
    agentInstances.add(building);

    assertThat(agentInstances.findAgents(AgentStatus.Cancelled).isEmpty(), is(true));
  }
Esempio n. 4
0
  @Test
  public void shouldReturnNullAgentsWhenHostNameIsNotFound() throws Exception {
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.building());
    agentInstances.add(idle);
    agentInstances.add(building);

    AgentInstance byHostname = agentInstances.findFirstByHostname("not-exist");
    assertThat(byHostname, is(instanceOf(NullAgentInstance.class)));
  }
Esempio n. 5
0
  @Test
  public void shouldFindAgentsByStatus() throws Exception {
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.building());
    agentInstances.add(pending);
    agentInstances.add(building);

    AgentInstances found = agentInstances.findAgents(AgentStatus.Building);

    assertThat(found.size(), is(1));
    assertThat(found.findAgentAndRefreshStatus("uuid3"), is(building));
  }
Esempio n. 6
0
 @Before
 public void setUp() throws Exception {
   initMocks(this);
   virtual = AgentInstanceMother.virtual();
   idle = AgentInstanceMother.idle(new Date(), "CCeDev01", systemEnvironment);
   AgentInstanceMother.updateOS(idle, "linux");
   building = AgentInstanceMother.building("buildLocator", systemEnvironment);
   AgentInstanceMother.updateOS(building, "macOS");
   pending = AgentInstanceMother.pending(systemEnvironment);
   AgentInstanceMother.updateOS(pending, "windows");
   disabled = AgentInstanceMother.disabled("10.18.5.4", systemEnvironment);
   local = AgentInstanceMother.local(systemEnvironment);
 }
Esempio n. 7
0
  @Test
  public void shouldNotRemovePendingAgentDuringSync() throws Exception {
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.building());
    agentInstances.add(pending);
    Agents agents = new Agents();

    agentInstances.sync(agents);

    assertThat(agentInstances.size(), is(1));
    assertThat(
        agentInstances.findAgentAndRefreshStatus("uuid4").getStatus(), is(AgentStatus.Pending));
  }
Esempio n. 8
0
  @Test
  public void shouldSyncAgent() throws Exception {
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.building(), idle);

    AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1");
    agentConfig.setDisabled(true);
    Agents oneAgentIsRemoved = new Agents(agentConfig);

    agentInstances.sync(oneAgentIsRemoved);

    assertThat(
        agentInstances.findAgentAndRefreshStatus("uuid2").getStatus(), is(AgentStatus.Disabled));
  }