Search in sources :

Example 1 with IndexedStorePath

use of org.commonjava.indy.content.index.IndexedStorePath in project indy by Commonjava.

the class ContentIndexDirLvWithArtifactsTest method test.

@Test
public void test() throws Exception {
    final String remoteName1 = newName();
    RemoteRepository remote1 = new RemoteRepository(MAVEN_PKG_KEY, remoteName1, server.formatUrl(remoteName1));
    remote1 = client.stores().create(remote1, name.getMethodName(), RemoteRepository.class);
    final String remoteName2 = newName();
    RemoteRepository remote2 = new RemoteRepository(MAVEN_PKG_KEY, remoteName2, server.formatUrl(remoteName2));
    remote2 = client.stores().create(remote2, name.getMethodName(), RemoteRepository.class);
    final String groupName = newName();
    Group group = new Group(MAVEN_PKG_KEY, groupName, remote1.getKey(), remote2.getKey());
    group = client.stores().create(group, name.getMethodName(), Group.class);
    server.expect(server.formatUrl(remoteName2, PATH_JAR), 200, PATH_JAR_CONTENT);
    server.expect(server.formatUrl(remoteName2, PATH_POM), 200, PATH_POM_CONTENT);
    final String CHECKSUM_CONTENT = newName();
    for (String checksumPath : PATHS_CHECKSUM) {
        server.expect(server.formatUrl(remoteName2, checksumPath), 200, CHECKSUM_CONTENT);
    }
    try (InputStream s = client.content().get(group.getKey(), PATH_JAR)) {
        assertThat(IOUtils.toString(s), equalTo(PATH_JAR_CONTENT));
    }
    try (InputStream s = client.content().get(group.getKey(), PATH_JAR)) {
        assertThat(IOUtils.toString(s), equalTo(PATH_JAR_CONTENT));
    }
    for (String checksumPath : PATHS_CHECKSUM) {
        try (InputStream s = client.content().get(group.getKey(), checksumPath)) {
            assertThat(IOUtils.toString(s), equalTo(CHECKSUM_CONTENT));
        }
    }
    AdvancedCache<IndexedStorePath, IndexedStorePath> advancedCache = (AdvancedCache) contentIndex.execute(c -> c);
    System.out.println("[Content index DEBUG]: cached isps: " + advancedCache.keySet());
    for (IndexedStorePath value : advancedCache.values()) {
        boolean match = remote2.getKey().equals(value.getOriginStoreKey()) || remote2.getKey().equals(value.getStoreKey());
        assertThat(match, equalTo(true));
    }
    System.out.println("[Content index DEBUG]: cache size:" + advancedCache.size());
    assertTrue(advancedCache.size() <= 2);
    System.out.println("[Content index DEBUG]: cache hit:" + advancedCache.getStats().getHits());
    assertTrue(advancedCache.getStats().getHits() >= 7);
    System.out.println("[Content index DEBUG]: cache misses:" + advancedCache.getStats().getMisses());
}
Also used : ExpectationServer(org.commonjava.test.http.expect.ExpectationServer) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Arrays(java.util.Arrays) IndexedStorePath(org.commonjava.indy.content.index.IndexedStorePath) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ContentIndexCacheProducer(org.commonjava.indy.content.index.ContentIndexCacheProducer) CDI(javax.enterprise.inject.spi.CDI) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) BasicCacheHandle(org.commonjava.indy.subsys.infinispan.BasicCacheHandle) Group(org.commonjava.indy.model.core.Group) Assert.assertThat(org.junit.Assert.assertThat) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) AdvancedCache(org.infinispan.AdvancedCache) Rule(org.junit.Rule) CoreServerFixture(org.commonjava.indy.test.fixture.core.CoreServerFixture) MAVEN_PKG_KEY(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY) Before(org.junit.Before) InputStream(java.io.InputStream) Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) IndexedStorePath(org.commonjava.indy.content.index.IndexedStorePath) AdvancedCache(org.infinispan.AdvancedCache) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 2 with IndexedStorePath

use of org.commonjava.indy.content.index.IndexedStorePath in project indy by Commonjava.

the class ContentIndexDirLvWithMetadataTest method test.

@Test
public void test() throws Exception {
    final String remoteName1 = newName();
    RemoteRepository remote1 = new RemoteRepository(MAVEN_PKG_KEY, remoteName1, server.formatUrl(remoteName1));
    remote1 = client.stores().create(remote1, name.getMethodName(), RemoteRepository.class);
    final String remoteName2 = newName();
    RemoteRepository remote2 = new RemoteRepository(MAVEN_PKG_KEY, remoteName2, server.formatUrl(remoteName2));
    remote2 = client.stores().create(remote2, name.getMethodName(), RemoteRepository.class);
    final String groupName = newName();
    Group group = new Group(MAVEN_PKG_KEY, groupName, remote1.getKey(), remote2.getKey());
    group = client.stores().create(group, name.getMethodName(), Group.class);
    server.expect(server.formatUrl(remoteName2, PATH_META), 200, PATH_META_CONTENT);
    try (InputStream s = client.content().get(group.getKey(), PATH_META)) {
        assertThat(IOUtils.toString(s), equalTo(PATH_META_CONTENT));
    }
    AdvancedCache<IndexedStorePath, IndexedStorePath> advancedCache = (AdvancedCache) contentIndex.execute(c -> c);
    System.out.println("[Content index DEBUG]: cached isps: " + advancedCache.keySet());
    for (IndexedStorePath value : advancedCache.values()) {
        assertThat(value.getOriginStoreKey(), equalTo(remote2.getKey()));
    }
    System.out.println("[Content index DEBUG]: cache size:" + advancedCache.size());
    System.out.println("[Content index DEBUG]: cache hit:" + advancedCache.getStats().getHits());
    System.out.println("[Content index DEBUG]: cache misses:" + advancedCache.getStats().getMisses());
}
Also used : ExpectationServer(org.commonjava.test.http.expect.ExpectationServer) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Arrays(java.util.Arrays) IndexedStorePath(org.commonjava.indy.content.index.IndexedStorePath) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ContentIndexCacheProducer(org.commonjava.indy.content.index.ContentIndexCacheProducer) CDI(javax.enterprise.inject.spi.CDI) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) BasicCacheHandle(org.commonjava.indy.subsys.infinispan.BasicCacheHandle) CacheHandle(org.commonjava.indy.subsys.infinispan.CacheHandle) Group(org.commonjava.indy.model.core.Group) Assert.assertThat(org.junit.Assert.assertThat) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) AdvancedCache(org.infinispan.AdvancedCache) Rule(org.junit.Rule) CoreServerFixture(org.commonjava.indy.test.fixture.core.CoreServerFixture) StoreKey(org.commonjava.indy.model.core.StoreKey) MAVEN_PKG_KEY(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY) Before(org.junit.Before) InputStream(java.io.InputStream) Group(org.commonjava.indy.model.core.Group) InputStream(java.io.InputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) IndexedStorePath(org.commonjava.indy.content.index.IndexedStorePath) AdvancedCache(org.infinispan.AdvancedCache) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Arrays (java.util.Arrays)2 List (java.util.List)2 CDI (javax.enterprise.inject.spi.CDI)2 IOUtils (org.apache.commons.io.IOUtils)2 ContentIndexCacheProducer (org.commonjava.indy.content.index.ContentIndexCacheProducer)2 IndexedStorePath (org.commonjava.indy.content.index.IndexedStorePath)2 AbstractIndyFunctionalTest (org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest)2 Group (org.commonjava.indy.model.core.Group)2 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)2 MAVEN_PKG_KEY (org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY)2 BasicCacheHandle (org.commonjava.indy.subsys.infinispan.BasicCacheHandle)2 CoreServerFixture (org.commonjava.indy.test.fixture.core.CoreServerFixture)2 ExpectationServer (org.commonjava.test.http.expect.ExpectationServer)2 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)2 AdvancedCache (org.infinispan.AdvancedCache)2 Assert.assertThat (org.junit.Assert.assertThat)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2