Search in sources :

Example 41 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class InstallUpdateTestCase method test.

@Test
public void test() throws Exception {
    Assert.assertEquals(cli.getMvnRepo().toString(), cli.getMvnRepo(), cli.getSession().getPmConfiguration().getMavenConfig().getLocalRepository());
    // Check resolved feature-packs
    cli.execute("find * --resolved-only --universe=" + universeSpec);
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    assertFalse(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    // Add an alpha1 snapshot release.
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1-SNAPSHOT");
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Alpha1-SNAPSHOT");
    cli.execute("find * --resolved-only --universe=" + universeSpec);
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    assertTrue(cli.getOutput(), cli.getOutput().contains(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT").toString()));
    FeaturePackLocation finalLoc = CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "final", null);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null), finalLoc);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null));
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null));
    // snapshot implies latest snapshot
    Path install1 = CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // no update available
    cli.execute("check-updates --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // Add an alpha1 release.
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null), finalLoc);
    CliTestUtils.checkNoVersionAvailable(cli, CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "beta", null));
    Path install2 = CliTestUtils.installAndCheck(cli, "install2", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "alpha", "1.0.0.Alpha1"));
    // no update available
    cli.execute("check-updates --dir=" + install2);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // Install an alpha-SNAPSHOT for producer2 in same directory
    CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // update available for the first installation, only producer1 has update.
    cli.execute("check-updates --dir=" + install1);
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(universeSpec.toString()));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    cli.execute("check-updates --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, null, null, null));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    cli.execute("check-updates --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER2, null, null, null));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(CheckUpdatesCommand.UP_TO_DATE));
    // upgrade to Alpha1, only producer1 upgraded.
    cli.execute("update --yes --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    ProvisioningConfig config = CliTestUtils.getConfig(install1);
    FeaturePackConfig cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    FeaturePackConfig cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
    // Add an alpha1 release.
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Alpha1");
    // Then upgrade producer2
    cli.execute("update --yes --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER2, null, null, null));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1"));
    try {
        cli.execute("update --yes --dir=" + install1 + " --include-all-dependencies " + "--feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null) + "," + CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", "snapshot", "1.0.0.Alpha1-SNAPSHOT"));
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // ok expected.
    }
    // Downgrade P2 to 1.0.0.Alpha1-SNAPSHOT, P1 shouldn't be impacted.
    cli.execute("update --yes --dir=" + install1 + " --feature-packs=" + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null) + "," + CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT"));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1-SNAPSHOT"));
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertEquals(cf1.getLocation().toString(), cf1.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    cf2 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, null).getProducer());
    Assert.assertEquals(cf2.getLocation().toString(), cf2.getLocation(), CliTestUtils.buildFPL(universeSpec, PRODUCER2, "1", null, "1.0.0.Alpha1-SNAPSHOT"));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 42 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class LayersTestCase method test.

@Test
public void test() throws Exception {
    FeaturePackLocation prod1 = newFpl(PRODUCER1, "1", "1.0.0.Final");
    FeaturePackLocation prod2 = newFpl(PRODUCER2, "1", "1.0.0.Final");
    CliTestUtils.installWithLayers(cli, universeSpec, PRODUCER1, "1.0.0.Final");
    CliTestUtils.install(cli, universeSpec, PRODUCER2, "1.0.0.Final");
    cli.execute("find * --layers=layerZ --universe=" + universeSpec);
    assertFalse(cli.getOutput(), cli.getOutput().contains(prod1.toString()));
    cli.execute("find * --layers=layerB --universe=" + universeSpec);
    assertTrue(cli.getOutput(), cli.getOutput().contains(prod1.toString()));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    cli.execute("feature-pack get-info " + prod1 + " --type=layers");
    assertTrue(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    cli.execute("feature-pack get-info " + prod1 + " --type=configs");
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    Path path = cli.newDir("prod1", false);
    try {
        cli.execute("install " + prod1 + " --dir=" + path + " --layers=foo");
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK, expected
    }
    cli.execute("install " + prod1 + " --dir=" + path + " --layers=" + "layerA-" + PRODUCER1 + ",layerC-" + PRODUCER1);
    ProvisioningConfig config = ProvisioningManager.builder().setInstallationHome(path).build().getProvisioningConfig();
    ConfigModel conf = config.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf);
    assertTrue(conf.getIncludedLayers().size() == 2);
    assertTrue(conf.getIncludedLayers().contains("layerA-" + PRODUCER1));
    assertTrue(conf.getIncludedLayers().contains("layerC-" + PRODUCER1));
    String opt = config.getOption(Constants.OPTIONAL_PACKAGES);
    assertNotNull(opt);
    assertEquals(Constants.PASSIVE_PLUS, opt);
    cli.execute("get-info --dir=" + path + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    // Multiple configurations are invalid with layers
    try {
        cli.execute("install " + prod1 + " --dir=" + path + " --config=testmodel/foobar.xml,testmodel/foobar2.xml, --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("should have failed");
    } catch (CommandException ex) {
    // XXX OK expected
    }
    Path path2 = cli.newDir("prod2", false);
    try {
        cli.execute("install " + prod1 + " --dir=" + path2 + " --config=moo/foobar.xml --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("should have failed");
    } catch (CommandException ex) {
    // XXX OK expected
    }
    cli.execute("install " + prod1 + " --dir=" + path2 + " --config=testmodel/foobar.xml --layers=" + "layerB-" + PRODUCER1);
    ProvisioningConfig config2 = ProvisioningManager.builder().setInstallationHome(path2).build().getProvisioningConfig();
    ConfigModel conf2 = config2.getDefinedConfig(new ConfigId("testmodel", "foobar.xml"));
    assertNotNull(conf2);
    assertTrue(conf2.getIncludedLayers().size() == 1);
    assertTrue(conf2.getIncludedLayers().contains("layerB-" + PRODUCER1));
    cli.execute("get-info --dir=" + path2 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("foobar.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("layerB-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("layerC-" + PRODUCER1));
    assertFalse(cli.getOutput(), cli.getOutput().contains("base-" + PRODUCER1));
    // Default model and config names
    Path path3 = cli.newDir("prod3", false);
    cli.execute("install " + prod1 + " --dir=" + path3 + " --config=foobar.xml --layers=" + "layerB-" + PRODUCER1);
    cli.execute("get-info --dir=" + path3 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("foobar.xml"));
    config = ProvisioningManager.builder().setInstallationHome(path3).build().getProvisioningConfig();
    assertTrue(config.getDefinedConfigs().size() == 1);
    conf = config.getDefinedConfig(new ConfigId("testmodel", "foobar.xml"));
    assertNotNull(conf);
    try {
        cli.execute("install " + prod1 + " --dir=" + path3 + " --config=foomodel/ --layers=" + "layerB-" + PRODUCER1);
        throw new Exception("Should have failed");
    } catch (CommandException ex) {
    // XXX OK, expected
    }
    Path path4 = cli.newDir("prod4", false);
    cli.execute("install " + prod1 + " --dir=" + path4 + " --config=testmodel/ --layers=" + "layerB-" + PRODUCER1);
    cli.execute("get-info --dir=" + path4 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("testmodel.xml"));
    config = ProvisioningManager.builder().setInstallationHome(path4).build().getProvisioningConfig();
    assertTrue(config.getDefinedConfigs().size() == 1);
    conf = config.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf);
    // Install a specified config without layers
    Path path5 = cli.newDir("prod5", false);
    cli.execute("install " + prod1 + " --dir=" + path5);
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    cli.execute("install " + prod1 + " --dir=" + path5 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertFalse(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    cli.execute("install " + prod1 + " --dir=" + path5 + " --default-configs=testmodel/config1.xml,testmodel/config2.xml");
    cli.execute("get-info --dir=" + path5 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config2.xml"));
    // Install multiple producers, installing default-config should not erase existing producer.
    Path path6 = cli.newDir("prod6", false);
    cli.execute("install " + prod2 + " --dir=" + path6);
    cli.execute("install " + prod1 + " --dir=" + path6 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path6);
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER2));
    // Install a default-config into empty directory
    Path path7 = cli.newDir("prod7", false);
    cli.execute("install " + prod1 + " --dir=" + path7 + " --default-configs=testmodel/config1.xml");
    cli.execute("get-info --dir=" + path7 + " --type=configs");
    assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER1));
    assertTrue(cli.getOutput(), cli.getOutput().contains("config1.xml"));
    // Install layers in multiple steps
    Path path8 = cli.newDir("prod8", false);
    cli.execute("install " + prod1 + " --dir=" + path8 + " --layers=" + "layerA-" + PRODUCER1);
    cli.execute("install " + prod1 + " --dir=" + path8 + " --layers=" + "layerC-" + PRODUCER1);
    ProvisioningConfig config3 = ProvisioningManager.builder().setInstallationHome(path8).build().getProvisioningConfig();
    ConfigModel conf3 = config3.getDefinedConfig(new ConfigId("testmodel", "testmodel.xml"));
    assertNotNull(conf3);
    assertTrue(conf3.getIncludedLayers().size() == 2);
    assertTrue(conf3.getIncludedLayers().contains("layerA-" + PRODUCER1));
    assertTrue(conf3.getIncludedLayers().contains("layerC-" + PRODUCER1));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ConfigModel(org.jboss.galleon.config.ConfigModel) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) CommandException(org.aesh.command.CommandException) ConfigId(org.jboss.galleon.config.ConfigId) CommandException(org.aesh.command.CommandException) Test(org.junit.Test)

Example 43 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class PatchTestCase method test.

@Test
public void test() throws Exception {
    CliTestUtils.install(cli, universeSpec, PRODUCER1, "1.0.0.Alpha1");
    Path install1 = CliTestUtils.installAndCheck(cli, "install1", CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", null), CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", "snapshot", "1.0.0.Alpha1"));
    // No patches information
    Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
    Path patchDir = cli.newDir("patches", true);
    FPID patchID = CliTestUtils.installPatch(cli, universeSpec, PRODUCER1, "1.0.0", "Alpha1", patchDir);
    Path patchFile = patchDir.toFile().listFiles()[0].toPath();
    // try to install from the FPID, should fail.
    try {
        cli.execute("install " + patchID + " --dir=" + install1);
        throw new Exception("Install should have failed");
    } catch (CommandException ex) {
    // XXX OK.
    }
    // import the patch into universe
    cli.execute("feature-pack import " + patchFile + " --install-in-universe=true");
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.toString()));
    // Now we can use it.
    cli.execute("install " + patchID + " --dir=" + install1);
    ProvisioningConfig config = CliTestUtils.getConfig(install1);
    FeaturePackConfig cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertTrue(cf1.hasPatches());
    Assert.assertTrue(cf1.getPatches().contains(patchID));
    // Get info from the patch
    cli.execute("feature-pack get-info --file=" + patchFile);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(GetInfoCommand.PATCH_FOR + CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, "1.0.0.Alpha1")));
    // Check that output contains the patch.
    cli.execute("get-info --dir=" + install1);
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCHES));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
    // Check that output contains the patch.
    cli.execute("get-info --dir=" + install1 + " --type=patches");
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH_FOR));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(Headers.PATCH));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(patchID.getBuild()));
    Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("1.0.0.Alpha1"));
    // uninstall the patch
    cli.execute("uninstall --dir=" + install1 + " " + patchID);
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertFalse(cf1.hasPatches());
    // install the patch using the file
    cli.execute("install --dir=" + install1 + " --file=" + patchFile);
    config = CliTestUtils.getConfig(install1);
    cf1 = config.getFeaturePackDep(CliTestUtils.buildFPL(universeSpec, PRODUCER1, "1", null, null).getProducer());
    Assert.assertTrue(cf1.hasPatches());
    Assert.assertTrue(cf1.getPatches().contains(patchID));
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) CommandException(org.aesh.command.CommandException) CommandException(org.aesh.command.CommandException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 44 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class StateTestCase method testTransitiveWithExistingPackages.

@Test
public void testTransitiveWithExistingPackages() throws Exception {
    FeaturePackConfig transitiveConfig = FeaturePackConfig.transitiveBuilder(transitive).excludePackage("p1").includePackage("p2").build();
    FeaturePackConfig topLevelConfig = FeaturePackConfig.builder(locWithTransitive).setInheritPackages(false).build();
    ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(topLevelConfig).addFeaturePackDep(transitiveConfig).build();
    Path p = cli.newDir("transitive_packages", false);
    // Provision a config with a transitive with already excluded package
    ProvisioningManager mgr1 = cli.getSession().newProvisioningManager(p, true);
    mgr1.provision(config);
    cli.execute("state edit " + p.toFile().getAbsolutePath());
    try {
        cli.execute("get-info --type=optional-packages");
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("remove-excluded-package p1");
        cli.execute("get-info --type=optional-packages");
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("undo");
        cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
        cli.execute("remove-included-package p2");
        boolean failed = false;
        try {
            cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
        } catch (Exception ex) {
            // expected.
            failed = true;
        }
        if (!failed) {
            throw new Exception("Package p2 shouldn't be present");
        }
        cli.execute("undo");
        Path p2 = cli.newDir("transitive_packages_reprovisioned", false);
        cli.execute("provision --dir=" + p2.toFile().getAbsolutePath());
        // Check that we still have the transitive dep and its original content.
        ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p2).build();
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().size() == 1);
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().contains("p1"));
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getIncludedPackages().contains("p2"));
    } finally {
        cli.execute("leave-state");
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) CommandException(org.aesh.command.CommandException) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 45 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class ProvisioningManager method getFsDiff.

/**
 * Returns the status of the filesystem describing which files have been
 * added, removed and modified since the last provisioning state transition.
 *
 * @return current status of the filesystem
 * @throws ProvisioningException  in case of an error during the status check
 */
public FsDiff getFsDiff() throws ProvisioningException {
    final ProvisioningConfig config = getProvisioningConfig();
    if (config == null || !config.hasFeaturePackDeps()) {
        return null;
    }
    log.verbose("Detecting user changes");
    final Path hashesDir = LayoutUtils.getHashesDir(getInstallationHome());
    if (Files.exists(hashesDir)) {
        final FsEntry originalState = new FsEntry(null, hashesDir);
        readHashes(originalState, new ArrayList<>());
        final FsEntry currentState = getDefaultFsEntryFactory().forPath(getInstallationHome());
        return FsDiff.diff(originalState, currentState);
    }
    try (ProvisioningRuntime rt = getRuntime(config)) {
        rt.provision();
        final FsEntryFactory fsFactory = getDefaultFsEntryFactory();
        final FsEntry originalState = fsFactory.forPath(rt.getStagedDir());
        final FsEntry currentState = fsFactory.forPath(getInstallationHome());
        final long startTime = log.isVerboseEnabled() ? System.nanoTime() : -1;
        final FsDiff fsDiff = FsDiff.diff(originalState, currentState);
        if (startTime != -1) {
            log.verbose(Errors.tookTime("  filesystem diff", startTime));
        }
        return fsDiff;
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) FsEntry(org.jboss.galleon.diff.FsEntry) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FsDiff(org.jboss.galleon.diff.FsDiff) FsEntryFactory(org.jboss.galleon.diff.FsEntryFactory)

Aggregations

ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)47 Test (org.junit.Test)16 Path (java.nio.file.Path)15 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)12 ProvisioningException (org.jboss.galleon.ProvisioningException)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)6 ProvisioningManager (org.jboss.galleon.ProvisioningManager)6 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)6 ConfigId (org.jboss.galleon.config.ConfigId)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 CommandException (org.aesh.command.CommandException)5 ConfigModel (org.jboss.galleon.config.ConfigModel)5 HashMap (java.util.HashMap)4 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)4 FeaturePackRuntimeBuilder (org.jboss.galleon.runtime.FeaturePackRuntimeBuilder)4 ProvisioningRuntime (org.jboss.galleon.runtime.ProvisioningRuntime)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)4 HashSet (java.util.HashSet)3