Ejemplo n.º 1
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));
 }
Ejemplo n.º 2
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));
  }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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));
  }
Ejemplo n.º 5
0
  @Test(expected = MaxPendingAgentsLimitReachedException.class)
  public void registerShouldErrorOutIfMaxPendingAgentsLimitIsReached() {
    AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1");
    AgentInstances agentInstances =
        new AgentInstances(null, systemEnvironment, AgentInstanceMother.pending());
    when(systemEnvironment.get(SystemEnvironment.MAX_PENDING_AGENTS_ALLOWED)).thenReturn(1);

    agentInstances.register(
        AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", 0L, "linux", false));
  }
Ejemplo n.º 6
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)));
  }
Ejemplo n.º 7
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));
  }
Ejemplo n.º 8
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));
  }
Ejemplo n.º 9
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));
  }