Search in sources :

Example 6 with ComponentCatalog

use of org.graalvm.component.installer.ComponentCatalog in project graal by oracle.

the class UpgradeTest method testUpgradeWithDependencies.

/**
 * Upgrade an installation with "ruby" to a newer one, where "ruby" has a dependency on an
 * additional component. The other component should be auto-installed.
 */
@Test
public void testUpgradeWithDependencies() throws Exception {
    initVersion("1.0.0.0", "../repo/catalog-19.3.properties");
    ComponentInfo ci = new ComponentInfo("org.graalvm.r", "Installed R", "1.0.0.0");
    storage.installed.add(ci);
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    textParams.add("r");
    ComponentInfo graalInfo = cmd.configureProcess();
    assertNotNull(graalInfo);
    assertEquals(Version.fromString("19.3.0.0"), graalInfo.getVersion());
    boolean installed = cmd.getProcess().installGraalCore(graalInfo);
    assertTrue(installed);
    factory = new CatalogFactory() {

        @Override
        public ComponentCatalog createComponentCatalog(CommandInput in) {
            RemoteCatalogDownloader dnl = new RemoteCatalogDownloader(in, UpgradeTest.this, downloader.getOverrideCatalogSpec());
            // carry over the override spec
            return new CatalogContents(UpgradeTest.this, dnl.getStorage(), in.getLocalRegistry());
        }

        @Override
        public List<GraalEdition> listEditions(ComponentRegistry targetGraalVM) {
            return Collections.emptyList();
        }
    };
    InstallTrampoline targetInstall = new InstallTrampoline();
    cmd.getProcess().configureInstallCommand(targetInstall);
    targetInstall.executionInit();
    targetInstall.prepareInstallation();
    assertTrue(targetInstall.getUnresolvedDependencies().isEmpty());
    List<ComponentParam> deps = targetInstall.getDependencies();
    assertEquals(1, deps.size());
    MetadataLoader ldr = deps.iterator().next().createFileLoader();
    assertEquals("org.graalvm.llvm-toolchain", ldr.getComponentInfo().getId());
}
Also used : ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) CommandInput(org.graalvm.component.installer.CommandInput) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) List(java.util.List) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 7 with ComponentCatalog

use of org.graalvm.component.installer.ComponentCatalog in project graal by oracle.

the class UpgradeTest method testUpgradeRespectsTargetCatalogURLs.

/**
 * The target GraalVM installation may have configured the catalog URLs differently. When
 * installing components or dependencies to the target, the target's URLs / release file
 * settings should be respected.
 *
 * @throws Exception
 */
@Test
public void testUpgradeRespectsTargetCatalogURLs() throws Exception {
    URL u = new URL("test://catalog-19.3.properties");
    Handler.bind(u.toString(), dataFile("../repo/catalog-19.3.properties").toUri().toURL());
    initVersion("1.0.0.0", "../repo/catalog-19.3.properties");
    ComponentInfo ci = new ComponentInfo("org.graalvm.r", "Installed R", "1.0.0.0");
    storage.installed.add(ci);
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    ComponentInfo graalInfo = cmd.configureProcess();
    boolean installed = cmd.getProcess().installGraalCore(graalInfo);
    assertTrue(installed);
    factory = new CatalogFactory() {

        @Override
        public ComponentCatalog createComponentCatalog(CommandInput in) {
            RemoteCatalogDownloader dnl = new RemoteCatalogDownloader(in, UpgradeTest.this, (String) null);
            return new CatalogContents(UpgradeTest.this, dnl.getStorage(), in.getLocalRegistry());
        }

        @Override
        public List<GraalEdition> listEditions(ComponentRegistry targetGraalVM) {
            return Collections.emptyList();
        }
    };
    InstallTrampoline targetInstall = new InstallTrampoline();
    cmd.getProcess().configureInstallCommand(targetInstall);
    targetInstall.executionInit();
    targetInstall.prepareInstallation();
    // verify the URL from the target installation was visited.
    assertTrue(Handler.isVisited(u));
}
Also used : ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) URL(java.net.URL) CommandInput(org.graalvm.component.installer.CommandInput) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) List(java.util.List) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 8 with ComponentCatalog

use of org.graalvm.component.installer.ComponentCatalog in project graal by oracle.

the class CatalogCompatTest method openCatalog.

ComponentCatalog openCatalog(SoftwareChannel ch, Version v) throws IOException {
    ComponentCatalog cc = new CatalogContents(this, ch.getStorage(), getLocalRegistry(), v);
    cc.getComponentIDs();
    return cc;
}
Also used : ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) CatalogContents(org.graalvm.component.installer.model.CatalogContents)

Aggregations

ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)8 CatalogContents (org.graalvm.component.installer.model.CatalogContents)7 List (java.util.List)4 CommandInput (org.graalvm.component.installer.CommandInput)4 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)4 Test (org.junit.Test)4 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)3 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)3 URL (java.net.URL)2 ComponentParam (org.graalvm.component.installer.ComponentParam)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 FailedOperationException (org.graalvm.component.installer.FailedOperationException)1 FileIterable (org.graalvm.component.installer.FileIterable)1 SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)1 GraalChannel (org.graalvm.component.installer.gds.GraalChannel)1 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)1 CatalogIterable (org.graalvm.component.installer.remote.CatalogIterable)1