Search in sources :

Example 6 with Configuration

use of org.jboss.pnc.common.Configuration in project pnc by project-ncl.

the class EarlyCancellationTest method testBuild.

private void testBuild(BuildExecutionStatus cancelAfter, BuildExecutionStatus[] expectedStatuses, BuildExecutionStatus[] unexpectedStatuses) throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException, ConfigurationParseException {
    BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
    Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
    ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
    DefaultBuildExecutor executor = new DefaultBuildExecutor(repositoryManagerFactory, buildDriverFactory, environmentDriverFactory, new Configuration(), null);
    Consumer<BuildExecutionStatusChangedEvent> cancel = (e) -> {
        if (cancelAfter.equals(e.getNewStatus())) {
            try {
                log.info("Cancelling build ...");
                executor.cancel("1");
            } catch (ExecutorException e0) {
                e0.printStackTrace();
            }
        }
    };
    runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, cancel, executor);
    // check build statuses
    checkBuildStatuses(statusChangedEvents, Arrays.asList(expectedStatuses));
    buildStatusesShouldNotContain(statusChangedEvents, Arrays.asList(unexpectedStatuses));
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Arrays(java.util.Arrays) BuildDriverException(org.jboss.pnc.spi.builddriver.exception.BuildDriverException) Arquillian(org.jboss.arquillian.junit.Arquillian) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) RepositoryManagerFactory(org.jboss.pnc.executor.servicefactories.RepositoryManagerFactory) Inject(javax.inject.Inject) HashSet(java.util.HashSet) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) Logger(org.slf4j.Logger) BuildDriverFactory(org.jboss.pnc.executor.servicefactories.BuildDriverFactory) BuildResult(org.jboss.pnc.spi.BuildResult) Set(java.util.Set) Test(org.junit.Test) Configuration(org.jboss.pnc.common.Configuration) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) Consumer(java.util.function.Consumer) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) EnvironmentDriverFactory(org.jboss.pnc.executor.servicefactories.EnvironmentDriverFactory) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) BuildResult(org.jboss.pnc.spi.BuildResult) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Configuration(org.jboss.pnc.common.Configuration) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) HashSet(java.util.HashSet)

Example 7 with Configuration

use of org.jboss.pnc.common.Configuration in project pnc by project-ncl.

the class BuildDriverFactoryTest method shouldPickProperDriver.

@Test
public void shouldPickProperDriver() throws Exception {
    // given
    ProperDriver testedBuildDriver = new ProperDriver();
    TestInstance<BuildDriver> allDrivers = new TestInstance<>(testedBuildDriver);
    Configuration configuration = mock(Configuration.class);
    BuildDriverFactory factory = new BuildDriverFactory(allDrivers, configuration);
    // when
    BuildDriver buildDriver = factory.getBuildDriver();
    // then
    assertThat(buildDriver).isEqualTo(testedBuildDriver);
}
Also used : BuildDriver(org.jboss.pnc.spi.builddriver.BuildDriver) TestInstance(org.jboss.pnc.test.cdi.TestInstance) Configuration(org.jboss.pnc.common.Configuration) BuildDriverFactory(org.jboss.pnc.executor.servicefactories.BuildDriverFactory) Test(org.junit.Test)

Example 8 with Configuration

use of org.jboss.pnc.common.Configuration in project pnc by project-ncl.

the class GlobalConfigTest method loadGlobalConfigTest.

@Test
public void loadGlobalConfigTest() throws ConfigurationParseException {
    Configuration configuration = new Configuration();
    GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
    assertNotNull(globalConfig);
    assertEquals("http://127.0.0.1:8001", globalConfig.getBpmUrl());
    assertEquals("http://127.0.0.1:8002", globalConfig.getCartographerUrl());
    assertEquals("http://127.0.0.1:8003", globalConfig.getDaUrl());
    assertEquals("http://127.0.0.1:8004", globalConfig.getIndyUrl());
    assertEquals("http://127.0.0.1:8005", globalConfig.getPncUrl());
    assertEquals("http://127.0.0.1:8006", globalConfig.getRepourUrl());
    assertEquals("http://127.0.0.1:8007", globalConfig.getDelAnalUrl());
    assertEquals("http://1.2.3.4", globalConfig.getExternalBifrostUrl());
    assertEquals("http://1.2.3.5", globalConfig.getExternalDaUrl());
    assertEquals("http://1.2.3.6", globalConfig.getExternalCausewayUrl());
    assertEquals("http://1.2.3.7", globalConfig.getExternalIndyUrl());
    assertEquals("http://1.2.3.8", globalConfig.getExternalKafkaStoreUrl());
    assertEquals("http://1.2.3.9", globalConfig.getExternalPncUrl());
    assertEquals("http://1.2.3.10", globalConfig.getExternalRepourUrl());
}
Also used : Configuration(org.jboss.pnc.common.Configuration) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) Test(org.junit.Test)

Example 9 with Configuration

use of org.jboss.pnc.common.Configuration in project pnc by project-ncl.

the class IndyRepoDriverModuleConfigTest method loadIndyRepoDriverConfigTest.

@Test
public void loadIndyRepoDriverConfigTest() throws ConfigurationParseException {
    Configuration configuration = new Configuration();
    IndyRepoDriverModuleConfig indyDriverConfig = configuration.getModuleConfig(new PncConfigProvider<>(IndyRepoDriverModuleConfig.class));
    assertNotNull(indyDriverConfig);
    assertEquals(100, indyDriverConfig.getDefaultRequestTimeout().intValue());
    assertTrue(indyDriverConfig.getBuildRepositoryAllowSnapshots().booleanValue());
    assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getData().getMaven().getPatterns().size());
    assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getData().getNpm().getPatterns().size());
    assertEquals(0, indyDriverConfig.getIgnoredPathPatterns().getPromotion().getNpm().getPatterns().size());
    List<Pattern> ignoredPathPatternsMaven = indyDriverConfig.getIgnoredPathPatterns().getPromotion().getMaven().getPatterns();
    assertNotNull(ignoredPathPatternsMaven);
    assertEquals(2, ignoredPathPatternsMaven.size());
    List<String> strings = ignoredPathPatternsMaven.stream().map(Pattern::pattern).collect(Collectors.toList());
    assertTrue(strings.contains(".*/maven-metadata\\.xml$"));
    assertTrue(strings.contains(".*\\.sha1$"));
}
Also used : Pattern(java.util.regex.Pattern) Configuration(org.jboss.pnc.common.Configuration) Test(org.junit.Test)

Example 10 with Configuration

use of org.jboss.pnc.common.Configuration in project pnc by project-ncl.

the class JenkinsBuildDriverModuleConfigTest method loadJenkinsBuildDriverConfigTest.

@Test
public void loadJenkinsBuildDriverConfigTest() throws ConfigurationParseException {
    Configuration configuration = new Configuration();
    JenkinsBuildDriverModuleConfig jenkinsConfig = configuration.getModuleConfig(new PncConfigProvider<>(JenkinsBuildDriverModuleConfig.class));
    assertNotNull(jenkinsConfig);
    assertEquals("user", jenkinsConfig.getUsername());
    assertEquals("pass", jenkinsConfig.getPassword());
}
Also used : Configuration(org.jboss.pnc.common.Configuration) Test(org.junit.Test)

Aggregations

Configuration (org.jboss.pnc.common.Configuration)12 Test (org.junit.Test)10 BuildDriverFactory (org.jboss.pnc.executor.servicefactories.BuildDriverFactory)5 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 TimeoutException (java.util.concurrent.TimeoutException)3 Consumer (java.util.function.Consumer)3 Inject (javax.inject.Inject)3 Deployment (org.jboss.arquillian.container.test.api.Deployment)3 Arquillian (org.jboss.arquillian.junit.Arquillian)3 ConfigurationParseException (org.jboss.pnc.common.json.ConfigurationParseException)3 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)3 BuildExecutionStatus (org.jboss.pnc.enums.BuildExecutionStatus)3 EnvironmentDriverFactory (org.jboss.pnc.executor.servicefactories.EnvironmentDriverFactory)3 RepositoryManagerFactory (org.jboss.pnc.executor.servicefactories.RepositoryManagerFactory)3 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)3 BuildResult (org.jboss.pnc.spi.BuildResult)3 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)3 ExecutorException (org.jboss.pnc.spi.executor.exceptions.ExecutorException)3