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();
}
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);
}
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();
}
}
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);
}
Aggregations