use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class MetadataPassthroughTimeoutWorkingTest method createRemoteRepository.
@Override
protected RemoteRepository createRemoteRepository() {
final RemoteRepository repository = new RemoteRepository(repoId, server.formatUrl(repoId));
repository.setPassthrough(true);
repository.setCacheTimeoutSeconds(CACHE_TIMEOUT_SECONDS);
repository.setMetadataTimeoutSeconds(METADATA_TIMEOUT_SECONDS);
return repository;
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class MetadataRescheduleTimeoutTest method timeout.
@Test
@Category(TimingDependent.class)
public void timeout() throws Exception {
final int METADATA_TIMEOUT_SECONDS = 4;
final int METADATA_TIMEOUT_WAITING_MILLISECONDS = 2500;
final String repoId = "test-repo";
final String metadataPath = "org/foo/bar/maven-metadata.xml";
final String metadataUrl = server.formatUrl(repoId, metadataPath);
// mocking up a http server that expects access to metadata
final String datetime = (new Date()).toString();
server.expect(metadataUrl, 200, String.format("metadata %s", datetime));
// set up remote repository pointing to the test http server, and timeout little later
final String changelog = "Timeout Testing: " + name.getMethodName();
final RemoteRepository repository = new RemoteRepository(repoId, server.formatUrl(repoId));
repository.setMetadataTimeoutSeconds(METADATA_TIMEOUT_SECONDS);
client.stores().create(repository, changelog, RemoteRepository.class);
// first time trigger normal content storage with timeout, should be 4s
PathInfo pomResult = client.content().getInfo(remote, repoId, metadataPath);
// force storage
client.content().get(remote, repoId, metadataPath).close();
assertThat("no metadata result", pomResult, notNullValue());
assertThat("metadata doesn't exist", pomResult.exists(), equalTo(true));
File metadataFile = Paths.get(fixture.getBootOptions().getIndyHome(), "var/lib/indy/storage", MAVEN_PKG_KEY, remote.singularEndpointName() + "-" + repoId, metadataPath).toFile();
assertThat("metadata doesn't exist", metadataFile.exists(), equalTo(true));
// wait for first 2.5s
Thread.sleep(METADATA_TIMEOUT_WAITING_MILLISECONDS);
// as the metadata content re-request, the metadata timeout interval should NOT be re-scheduled
client.content().get(remote, repoId, metadataPath).close();
// will wait another 4s
Thread.sleep(METADATA_TIMEOUT_WAITING_MILLISECONDS + 1500);
// as rescheduled, the artifact should not be deleted
assertThat("artifact should be removed as the rescheduled of metadata should not succeed", metadataFile.exists(), equalTo(false));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RoutedCacheProviderForRemoteTest method proxyRemoteAndNFSNotSetup.
@Test
public void proxyRemoteAndNFSNotSetup() throws Exception {
final String repo1 = "repo1";
final String pomPath = "org/foo/bar/1.0/bar-1.0.pom";
final String pomUrl = server.formatUrl(repo1, pomPath);
final String datetime = (new Date()).toString();
server.expect(pomUrl, 200, String.format("pom %s", datetime));
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
client.stores().create(remote1, "adding remote", RemoteRepository.class);
final PathInfo result = client.content().getInfo(remote, repo1, pomPath);
assertThat("no result", result, notNullValue());
assertThat("doesn't exist", result.exists(), equalTo(true));
final File nfsStorage = Paths.get(fixture.getBootOptions().getIndyHome(), NFS_BASE).toFile();
assertThat(nfsStorage.exists(), equalTo(true));
assertThat(nfsStorage.list().length, equalTo(0));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class NestedStoreInGroupWithErrorTest method run.
@Test
public void run() throws Exception {
final String path = "org/foo/bar/pom.xml";
final String repo1 = "repo1";
final String content = "This is a test: " + System.nanoTime();
final InputStream stream = new ByteArrayInputStream(content.getBytes());
server.expect(server.formatUrl(repo1, path), 200, stream);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote2", RemoteRepository.class);
final String repo2 = "repo2";
server.registerException(server.formatUrl(repo2, path), "upstream error", HttpStatus.SC_UNAUTHORIZED);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));
remote2 = client.stores().create(remote2, "adding remote2", RemoteRepository.class);
final String gName = "test";
Group tgroup = new Group(gName, Arrays.asList(remote2.getKey(), remote1.getKey()));
client.stores().create(tgroup, "new group with remote2", Group.class);
try (InputStream is = client.content().get(group, gName, path)) {
assertThat(IOUtils.toString(is), equalTo(content));
}
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RemoteRepoGetTimeoutTest method run.
@Test
public void run() throws Exception {
final String repo1 = "repo1";
final String path = "org/foo/bar/maven-metadata.xml";
server.expect(server.formatUrl(repo1, path), 200, new DelayInputStream());
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
try (InputStream is = client.content().get(remote, repo1, path)) {
} catch (final IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(HttpStatus.SC_BAD_GATEWAY));
}
}
Aggregations