use of org.jboss.pnc.rest.api.parameters.GroupBuildParameters 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);
}
use of org.jboss.pnc.rest.api.parameters.GroupBuildParameters 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);
}
use of org.jboss.pnc.rest.api.parameters.GroupBuildParameters 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();
}
use of org.jboss.pnc.rest.api.parameters.GroupBuildParameters in project bacon by project-ncl.
the class PncBuilder method run.
private GroupBuild run(GroupConfigurationRef group, boolean tempBuild, boolean tempBuildTS, RebuildMode rebuildMode, boolean dryRun) {
log.info("Performing builds of group config {} in PNC ( {} )", group.getId(), UrlGenerator.generateGroupConfigUrl(group.getId()));
if (tempBuildTS)
log.warn("Temporary builds with timestamp alignment are not supported, running temporary builds instead...");
GroupBuildParameters buildParams = new GroupBuildParameters();
buildParams.setRebuildMode(rebuildMode);
buildParams.setTemporaryBuild(tempBuild);
if (dryRun) {
buildParams.setTemporaryBuild(true);
buildParams.setAlignmentPreference(AlignmentPreference.PREFER_PERSISTENT);
}
GroupBuildRequest request = GroupBuildRequest.builder().build();
try {
return groupConfigClient.trigger(group.getId(), buildParams, request);
} catch (ClientException e) {
throw new RuntimeException("Failed to trigger build group " + group.getId(), e);
}
}
use of org.jboss.pnc.rest.api.parameters.GroupBuildParameters in project pnc by project-ncl.
the class BuildParametersValidatorTest method testGroupBuildParametersValidation.
@Test
@Parameterized.Parameters
public void testGroupBuildParametersValidation() {
GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
groupBuildParameters.setTemporaryBuild(temporary);
groupBuildParameters.setAlignmentPreference(alignmentPreference);
Set<ConstraintViolation<GroupBuildParameters>> violations = validator.validate(groupBuildParameters);
Assert.assertEquals(isValid, violations.isEmpty());
}
Aggregations