Search in sources :

Example 1 with BuildRecordRepositoryMock

use of org.jboss.pnc.mock.repository.BuildRecordRepositoryMock in project pnc by project-ncl.

the class AbstractDependentBuildTest method initialize.

@Before
@SuppressWarnings("unchecked")
public void initialize() throws DatastoreException, ConfigurationParseException {
    MockitoAnnotations.initMocks(this);
    builtTasks = new ArrayList<>();
    user = new User();
    user.setId(375939);
    user.setUsername("username");
    Configuration config = mock(Configuration.class);
    SystemConfig systemConfig = mock(SystemConfig.class);
    when(systemConfig.getCoordinatorThreadPoolSize()).thenReturn(1);
    when(systemConfig.getCoordinatorMaxConcurrentBuilds()).thenReturn(1);
    when(systemConfig.getTemporaryBuildsLifeSpan()).thenReturn(1);
    when(config.getModuleConfig(any())).thenReturn(systemConfig);
    buildQueue = new BuildQueue(config.getModuleConfig(new PncConfigProvider<>(SystemConfig.class)));
    if (buildConfigurationRepository == null) {
        buildConfigurationRepository = new BuildConfigurationRepositoryMock();
    }
    buildRecordRepository = new BuildRecordRepositoryMock();
    buildConfigurationAuditedRepository = new BuildConfigurationAuditedRepositoryMock();
    TargetRepositoryRepository targetRepositoryRepository = new TargetRepositoryRepositoryMock();
    DefaultDatastore datastore = new DefaultDatastore(new ArtifactRepositoryMock(), buildRecordRepository, buildConfigurationRepository, buildConfigurationAuditedRepository, new BuildConfigSetRecordRepositoryMock(), new UserRepositoryMock(), targetRepositoryRepository);
    DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
    if (buildSchedulerFactory == null) {
        buildSchedulerFactory = new MockBuildSchedulerFactory();
    }
    coordinator = new DefaultBuildCoordinator(datastoreAdapter, mock(Event.class), mock(Event.class), buildSchedulerFactory, buildQueue, systemConfig, mock(GroupBuildMapper.class), mock(BuildMapper.class));
    buildQueue.initSemaphore();
    coordinator.start();
}
Also used : BuildQueue(org.jboss.pnc.coordinator.builder.BuildQueue) SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) User(org.jboss.pnc.model.User) BuildConfigSetRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigSetRecordRepositoryMock) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) Configuration(org.jboss.pnc.common.Configuration) BuildRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordRepositoryMock) TargetRepositoryRepositoryMock(org.jboss.pnc.mock.repository.TargetRepositoryRepositoryMock) BuildConfigurationRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock) BuildConfigurationAuditedRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationAuditedRepositoryMock) TargetRepositoryRepository(org.jboss.pnc.spi.datastore.repositories.TargetRepositoryRepository) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) DefaultBuildCoordinator(org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator) DefaultDatastore(org.jboss.pnc.datastore.DefaultDatastore) ArtifactRepositoryMock(org.jboss.pnc.mock.repository.ArtifactRepositoryMock) UserRepositoryMock(org.jboss.pnc.mock.repository.UserRepositoryMock) Before(org.junit.Before)

Example 2 with BuildRecordRepositoryMock

use of org.jboss.pnc.mock.repository.BuildRecordRepositoryMock in project pnc by project-ncl.

the class BuildResultPushManagerTest method setUp.

@Before
public void setUp() throws CoreException, GerritException {
    when(buildConfigurationAuditedRepository.queryById(any(IdRev.class))).thenReturn(buildConfigurationAudited);
    when(causewayClient.importBuild(any(), any())).thenReturn(true);
    when(gerrit.generateDownloadUrlWithGerritGitweb(any(), any())).thenReturn("https://example.com/foo.tar.gz");
    buildRecordRepository = new BuildRecordRepositoryMock();
    buildRecordPushResultRepository = new BuildRecordPushResultRepositoryMock();
    releaseManager = new BuildResultPushManager(buildConfigurationAuditedRepository, buildRecordPushResultRepository, null, new InProgress(), buildRecordPushResultRestEvent, artifactRepository, gerrit, causewayClient);
}
Also used : BuildRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordRepositoryMock) BuildRecordPushResultRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordPushResultRepositoryMock) BuildResultPushManager(org.jboss.pnc.bpm.causeway.BuildResultPushManager) InProgress(org.jboss.pnc.bpm.causeway.InProgress) IdRev(org.jboss.pnc.model.IdRev) Before(org.junit.Before)

Example 3 with BuildRecordRepositoryMock

use of org.jboss.pnc.mock.repository.BuildRecordRepositoryMock in project pnc by project-ncl.

the class IndyPromotionValidationTest method testIndyPromotionValidation.

@Test
public /**
 * Test whose purpose is to provide a means for more or less easy debugging of indy validation errors. For it to
 * work it needs a standalone Indy server, with a rule-set definition such as this: { "storeKeyPattern":
 * "group:builds-untested", "ruleNames": [ "no-snapshots.groovy", "parsable-pom.groovy" ], "validationParameters":
 * {} } Provide the base URL to this Indy server as a System parameter such as e.g.
 * -DbaseUrl="http://127.0.0.1:8090"
 */
void testIndyPromotionValidation() {
    String baseUrl = System.getProperty("baseUrl");
    if (StringUtils.isBlank(baseUrl)) {
        fail("No base URL has been specified");
    }
    RepositoryManager driver = null;
    try {
        driver = new RepositoryManagerDriver(new TestConfiguration(baseUrl), new BuildRecordRepositoryMock());
        RepositorySession repositorySession = driver.createBuildRepository(new TestBuildExecution("test"), null, null, RepositoryType.MAVEN, Collections.emptyMap(), false);
        CloseableHttpClient client = HttpClientBuilder.create().build();
        String deployUrl = repositorySession.getConnectionInfo().getDeployUrl();
        // Deploy several 'wrong' artifacts to get a composed error message back
        String pathPom1 = "org/foo/invalid/1/invalid-1.pom";
        String snapshotPom = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0-SNAPSHOT</version></dependency></dependencies></project>";
        String url = UrlUtils.buildUrl(deployUrl, pathPom1);
        put(client, url, snapshotPom);
        String pathPom2 = "org/foo/invalid2/1/invalid2-1.pom";
        String snapshotPom2 = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid2</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0-SNAPSHOT</version></dependency></dependencies></project>";
        url = UrlUtils.buildUrl(deployUrl, pathPom2);
        put(client, url, snapshotPom2);
        String pathPom3 = "org/foo/nonparseable/1/nonparseable.pom";
        String nonparseablePom = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>nonparseable</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0</version></dependency></dependencies></project>";
        url = UrlUtils.buildUrl(deployUrl, pathPom3);
        put(client, url, nonparseablePom);
        RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(true);
        // Just a dummy check, the point is really to be able to debug this
        assertSame(CompletionStatus.FAILED, repositoryManagerResult.getCompletionStatus());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BuildRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordRepositoryMock) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) RepositoryManager(org.jboss.pnc.spi.repositorymanager.RepositoryManager) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) IOException(java.io.IOException) DebugTest(org.jboss.pnc.test.category.DebugTest) Test(org.junit.Test)

Example 4 with BuildRecordRepositoryMock

use of org.jboss.pnc.mock.repository.BuildRecordRepositoryMock in project pnc by project-ncl.

the class AbstractRepositoryManagerDriverTest method setup.

@Before
public void setup() throws Exception {
    // workaround for NPE in Indy 1.6.2 client
    MDC.put("dummy", "non");
    fixture = newServerFixture();
    Properties sysprops = System.getProperties();
    oldIni = sysprops.getProperty(CONFIG_SYSPROP);
    url = fixture.getUrl();
    File configFile = temp.newFile("pnc-config.json");
    ModuleConfigJson moduleConfigJson = new ModuleConfigJson("pnc-config");
    IndyRepoDriverModuleConfig mavenRepoDriverModuleConfig = new IndyRepoDriverModuleConfig();
    mavenRepoDriverModuleConfig.setIgnoredRepoPatterns(getIgnoredRepoPatterns());
    mavenRepoDriverModuleConfig.setBrewPullActiveMetadataKey(BREW_PULL_ACTIVE_METADATA_KEY);
    preConfigureMavenRepositoryDriver(mavenRepoDriverModuleConfig);
    SystemConfig systemConfig = new SystemConfig("", "", "JAAS", "4", "4", "4", "", "5", null, null, "14", "", "10");
    GlobalModuleGroup globalConfig = new GlobalModuleGroup();
    globalConfig.setIndyUrl(fixture.getUrl());
    PNCModuleGroup pncGroup = new PNCModuleGroup();
    pncGroup.addConfig(mavenRepoDriverModuleConfig);
    pncGroup.addConfig(systemConfig);
    moduleConfigJson.addConfig(globalConfig);
    moduleConfigJson.addConfig(pncGroup);
    ObjectMapper mapper = new ObjectMapper();
    PncConfigProvider<IndyRepoDriverModuleConfig> pncProvider = new PncConfigProvider<>(IndyRepoDriverModuleConfig.class);
    pncProvider.registerProvider(mapper);
    mapper.writeValue(configFile, moduleConfigJson);
    sysprops.setProperty(CONFIG_SYSPROP, configFile.getAbsolutePath());
    System.setProperties(sysprops);
    fixture.start();
    if (!fixture.isStarted()) {
        final BootStatus status = fixture.getBootStatus();
        throw new IllegalStateException("server fixture failed to boot.", status.getError());
    }
    Properties props = new Properties();
    props.setProperty("base.url", url);
    System.out.println("Using base URL: " + url);
    Configuration config = new Configuration();
    BuildRecordRepositoryMock bcRepository = new BuildRecordRepositoryMock();
    driver = new RepositoryManagerDriver(config, bcRepository);
}
Also used : SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) IndyRepoDriverModuleConfig(org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig) Configuration(org.jboss.pnc.common.Configuration) BuildRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordRepositoryMock) ModuleConfigJson(org.jboss.pnc.common.json.ModuleConfigJson) BootStatus(org.commonjava.propulsor.boot.BootStatus) PncConfigProvider(org.jboss.pnc.common.json.moduleprovider.PncConfigProvider) Properties(java.util.Properties) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) PNCModuleGroup(org.jboss.pnc.common.json.PNCModuleGroup) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

BuildRecordRepositoryMock (org.jboss.pnc.mock.repository.BuildRecordRepositoryMock)4 Before (org.junit.Before)3 Configuration (org.jboss.pnc.common.Configuration)2 SystemConfig (org.jboss.pnc.common.json.moduleconfig.SystemConfig)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 BootStatus (org.commonjava.propulsor.boot.BootStatus)1 BuildResultPushManager (org.jboss.pnc.bpm.causeway.BuildResultPushManager)1 InProgress (org.jboss.pnc.bpm.causeway.InProgress)1 ConfigurationParseException (org.jboss.pnc.common.json.ConfigurationParseException)1 GlobalModuleGroup (org.jboss.pnc.common.json.GlobalModuleGroup)1 ModuleConfigJson (org.jboss.pnc.common.json.ModuleConfigJson)1 PNCModuleGroup (org.jboss.pnc.common.json.PNCModuleGroup)1 IndyRepoDriverModuleConfig (org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig)1 PncConfigProvider (org.jboss.pnc.common.json.moduleprovider.PncConfigProvider)1 BuildQueue (org.jboss.pnc.coordinator.builder.BuildQueue)1 DefaultBuildCoordinator (org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator)1