Search in sources :

Example 1 with GroupBuild

use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.

the class BuildTest method shouldTriggerGroupBuildAndFinishWithoutProblems.

@Test
public void shouldTriggerGroupBuildAndFinishWithoutProblems() throws ClientException {
    // given
    GroupConfiguration groupConfig = groupConfigurationClient.getAll().iterator().next();
    // when
    GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
    groupBuildParameters.setRebuildMode(RebuildMode.FORCE);
    GroupBuild groupBuild = groupConfigurationClient.trigger(groupConfig.getId(), groupBuildParameters, GroupBuildRequest.builder().buildConfigurationRevisions(new ArrayList<>()).build());
    assertThat(groupBuild).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    // then
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED);
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
Also used : GroupBuild(org.jboss.pnc.dto.GroupBuild) BuildStatus(org.jboss.pnc.enums.BuildStatus) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 2 with GroupBuild

use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.

the class BuildTest method shouldRejectGroupBuildWithNoRebuildsRequired.

@Test
public void shouldRejectGroupBuildWithNoRebuildsRequired() throws ClientException {
    // given
    GroupConfiguration groupConfig = groupConfigurationClient.getAll().iterator().next();
    // and after one build is done
    GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
    groupBuildParameters.setRebuildMode(RebuildMode.FORCE);
    GroupBuild groupBuild1 = groupConfigurationClient.trigger(groupConfig.getId(), groupBuildParameters, GroupBuildRequest.builder().buildConfigurationRevisions(new ArrayList<>()).build());
    assertThat(groupBuild1).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild1.getId(), EnumSet.of(BuildStatus.SUCCESS), null), 15, TimeUnit.SECONDS);
    // when next build is triggered
    GroupBuild groupBuild2 = groupConfigurationClient.trigger(groupConfig.getId(), new GroupBuildParameters(), GroupBuildRequest.builder().buildConfigurationRevisions(new ArrayList<>()).build());
    // then
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.SUCCESS, BuildStatus.REJECTED);
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild2.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
Also used : GroupBuild(org.jboss.pnc.dto.GroupBuild) BuildStatus(org.jboss.pnc.enums.BuildStatus) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with GroupBuild

use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.

the class WebSocketClientTest method testRestGroupBuildFallback.

@Test
public void testRestGroupBuildFallback() throws Exception {
    // with
    WebSocketSessionHandler handler = new WebSocketSessionHandler();
    Undertow wsServer = withHandler(handler);
    wsServer.start();
    WebSocketClient wsClient = new VertxWebSocketClient();
    wsClient.connect("ws://localhost:8082" + NOTIFICATION_PATH).join();
    AdvancedGroupConfigurationClient groupConfigurationClient = new AdvancedGroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gc = groupConfigurationClient.getAll().iterator().next();
    // test the actual fallbackSupplier (it's private -> reflection unfortunately)
    Method supplier = groupConfigurationClient.getClass().getDeclaredMethod("fallbackSupplier", String.class);
    supplier.setAccessible(true);
    // when
    CompletableFuture<GroupBuildChangedNotification> future = wsClient.catchGroupBuildChangedNotification(() -> invokeMethod(supplier, GroupBuild.class, groupConfigurationClient, gc.getId()), withGConfigId(gc.getId()), withGBuildCompleted());
    GroupBuild groupBuild = groupConfigurationClient.trigger(gc.getId(), new GroupBuildParameters(), GroupBuildRequest.builder().build());
    // wait for GroupBuild to finish
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId()), 15, TimeUnit.SECONDS);
    // make client reconnect and use REST fallback
    handler.closeSession();
    // then
    assertThat(future).succeedsWithin(500, TimeUnit.MILLISECONDS);
    wsClient.close();
    wsServer.stop();
}
Also used : GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification) GroupBuild(org.jboss.pnc.dto.GroupBuild) AdvancedGroupConfigurationClient(org.jboss.pnc.restclient.AdvancedGroupConfigurationClient) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Method(java.lang.reflect.Method) WebSocketClient(org.jboss.pnc.restclient.websocket.WebSocketClient) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) Undertow(io.undertow.Undertow) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with GroupBuild

use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.

the class WebSocketsNotificationTest method shouldReceiveBuildSetStatusChangeNotification.

@Test
@InSequence(3)
public void shouldReceiveBuildSetStatusChangeNotification() throws Exception {
    // given
    GroupBuild groupBuild = GroupBuild.builder().id("1").groupConfig(GroupConfigurationRef.refBuilder().id("1").name("BuildSet1").build()).startTime(Instant.ofEpochMilli(1453118400000L)).endTime(Instant.ofEpochMilli(1453122000000L)).user(User.builder().id("1").username("user1").build()).status(BuildStatus.SUCCESS).build();
    BuildSetStatusChangedEvent buildStatusChangedEvent = new DefaultBuildSetStatusChangedEvent(BuildSetStatus.NEW, BuildSetStatus.DONE, groupBuild, "description");
    String groupBuildString = mapperProvider.getMapper().writeValueAsString(groupBuild);
    String expectedJsonResponse = "{\"groupBuild\":" + groupBuildString + ",\"job\":\"GROUP_BUILD\",\"notificationType\":\"GROUP_BUILD_STATUS_CHANGED\",\"progress\":\"FINISHED\",\"oldProgress\":\"IN_PROGRESS\",\"message\":null}";
    // when
    buildSetStatusNotificationEvent.fire(buildStatusChangedEvent);
    // then
    Wait.forCondition(() -> isReceived(expectedJsonResponse), 15, ChronoUnit.SECONDS);
}
Also used : GroupBuild(org.jboss.pnc.dto.GroupBuild) DefaultBuildSetStatusChangedEvent(org.jboss.pnc.spi.coordinator.events.DefaultBuildSetStatusChangedEvent) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) DefaultBuildSetStatusChangedEvent(org.jboss.pnc.spi.coordinator.events.DefaultBuildSetStatusChangedEvent) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with GroupBuild

use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.

the class GroupBuildEndpointTest method shouldGetSpecificGroupBuild.

@Test
public void shouldGetSpecificGroupBuild() throws ClientException {
    GroupBuild build = anonymousClient.getSpecific(groupBuildId1);
    assertThat(build.getId()).isEqualTo(groupBuildId1);
    assertThat(build.getGroupConfig()).isNotNull();
    assertThat(build.getUser()).isNotNull();
    assertThat(build.getStartTime()).isNotNull();
    assertThat(build.getEndTime()).isNotNull();
    assertThat(build.getStatus()).isNotNull();
    assertThat(build.getTemporaryBuild()).isNotNull();
    assertThat(build.getGroupConfig()).isNotNull();
}
Also used : GroupBuild(org.jboss.pnc.dto.GroupBuild) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

Aggregations

GroupBuild (org.jboss.pnc.dto.GroupBuild)14 Test (org.junit.Test)7 ContainerTest (org.jboss.pnc.test.category.ContainerTest)6 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)5 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)4 ClientException (org.jboss.pnc.client.ClientException)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 HashMap (java.util.HashMap)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 RemoteResourceNotFoundException (org.jboss.pnc.client.RemoteResourceNotFoundException)2 Undertow (io.undertow.Undertow)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 InSequence (org.jboss.arquillian.junit.InSequence)1 GroupBuildInfo (org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo)1 BuildInfoCollector (org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector)1 ImportResult (org.jboss.pnc.bacon.pig.impl.pnc.ImportResult)1 PncBuilder (org.jboss.pnc.bacon.pig.impl.pnc.PncBuilder)1