Examples of BundleDeployment


Examples of org.rhq.core.domain.bundle.BundleDeployment

        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull("Instance of newly created resource group should not be null", platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull("Instance of newly created bundle destination should not be null", dest1);

        BundleDeployment deployment1 = createDeployment("one", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment1);
        getTransactionManager().begin();
        deployment1.setStatus(BundleDeploymentStatus.SUCCESS);
        em.merge(deployment1);
        getTransactionManager().commit();

        BundleDeployment deployment2 = createDeployment("two", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment2);
        getTransactionManager().begin();
        deployment2.setStatus(BundleDeploymentStatus.SUCCESS);
        deployment2.setReplacedBundleDeploymentId(deployment1.getId());
        em.merge(deployment2);
        getTransactionManager().commit();

        BundleDeployment deployment3 = createDeployment("three", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment3);
        getTransactionManager().begin();
        deployment3.setStatus(BundleDeploymentStatus.SUCCESS);
        deployment3.setReplacedBundleDeploymentId(deployment2.getId());
        em.merge(deployment3);
        getTransactionManager().commit();

        BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
        criteria.addFilterBundleId(b1.getId());
        List<BundleDeployment> deployments = bundleManager.findBundleDeploymentsByCriteria(
            subjectManager.getOverlord(), criteria);
        assertNotNull("List of bundle deployments should not be null", deployments);
        assertEquals(3, deployments.size());

        // delete the middle bundle deployment
        bundleManager.deleteBundleDeployment(subjectManager.getOverlord(), deployment2.getId());
        deployments = bundleManager.findBundleDeploymentsByCriteria(subjectManager.getOverlord(), criteria);
        assertNotNull("List of bundle deployments should not be null", deployments);
        assertEquals(2, deployments.size());
        assertTrue("When the middle chain was removed the links should be modified correctly. "
            + "Assume A -> B -> C deployment structure, remove B, this should result in A -> C",
            deployments.get(0).getReplacedBundleDeploymentId() == null ? deployments.get(1)
                .getReplacedBundleDeploymentId() == deployments.get(0).getId() : deployments.get(0)
                .getReplacedBundleDeploymentId() == deployments.get(1).getId());

        bundleManager.deleteBundleDeployment(subjectManager.getOverlord(), deployment1.getId());
        deployments = bundleManager.findBundleDeploymentsByCriteria(subjectManager.getOverlord(), criteria);
        assertNotNull("List of bundle deployments should not be null", deployments);
        assertEquals("1 bundle deployment should be found, 2 were deleted.", 1, deployments.size());
        assertEquals(
            "replacedBundleDeploymentId should be set to null, because all the previous deployments were deleted.",
            deployments.get(0).getReplacedBundleDeploymentId(), null);

        bundleManager.deleteBundleDeployment(subjectManager.getOverlord(), deployment3.getId());
        deployments = bundleManager.findBundleDeploymentsByCriteria(subjectManager.getOverlord(), criteria);
        assertNotNull("List of bundle deployments should not be null", deployments);
        assertEquals("No bundle deployments should be found, all were deleted.", 0, deployments.size());
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
        BundleDeployment bd1 = createDeployment("one", bv1, dest1, config);
        assertNotNull(bd1);
        assertEquals(BundleDeploymentStatus.PENDING, bd1.getStatus());

        BundleDeployment bd1d = bundleManager.scheduleBundleDeployment(overlord, bd1.getId(), false);
        assertNotNull(bd1d);
        assertEquals(bd1.getId(), bd1d.getId());

        BundleDeploymentCriteria bdc = new BundleDeploymentCriteria();
        bdc.addFilterId(bd1d.getId());
        bdc.fetchBundleVersion(true);
        bdc.fetchDestination(true);
        bdc.fetchResourceDeployments(true);
        bdc.fetchTags(true);
        List<BundleDeployment> bds = bundleManager.findBundleDeploymentsByCriteria(overlord, bdc);
        assertEquals(1, bds.size());
        bd1d = bds.get(0);

        assertEquals(platformResourceGroup, bd1d.getDestination().getGroup());
        assertEquals(dest1.getId(), bd1d.getDestination().getId());

        BundleResourceDeploymentCriteria c = new BundleResourceDeploymentCriteria();
        c.addFilterBundleDeploymentId(bd1d.getId());
        c.fetchBundleDeployment(true);
        c.fetchHistories(true);
        c.fetchResource(true);
        List<BundleResourceDeployment> brds = bundleManager.findBundleResourceDeploymentsByCriteria(overlord, c);
        assertEquals(1, brds.size());
        assertEquals(1, bd1d.getResourceDeployments().size());
        assertEquals(bd1d.getResourceDeployments().get(0).getId(), brds.get(0).getId());
        BundleResourceDeployment brd = brds.get(0);

        assertNotNull(brd.getBundleResourceDeploymentHistories());
        int size = brd.getBundleResourceDeploymentHistories().size();
        assertTrue(size > 0);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        addRolePermissions(role, Permission.DEPLOY_BUNDLES);
        BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
        Configuration config = new Configuration();
        config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
        BundleDeployment bd1;
        bd1 = createDeployment(subject, "one", bv1, dest1, config);
        assertNotNull(bd1);

        // allow group
        removeRolePermissions(role, Permission.DEPLOY_BUNDLES);
        addRolePermissions(role, Permission.DEPLOY_BUNDLES_TO_GROUP);
        BundleDestination dest2 = createDestination(subject, b1, "two", "/test2", platformResourceGroup);
        assertNotNull(dest2);
        Configuration config2 = new Configuration();
        config2.put(new PropertySimple("bundletest.property", "bundletest.property value"));
        BundleDeployment bd2;
        bd2 = createDeployment(subject, "two", bv1, dest2, config2);
        assertNotNull(bd1);

        // deny delete deployment
        removeRolePermissions(role, Permission.DEPLOY_BUNDLES_TO_GROUP);
        try {
            bundleManager.deleteBundleDeployment(subject, bd2.getId());
            fail("Should have thrown PermissionException");
        } catch (PermissionException e) {
            // expected
        }

        // allow delete deployment
        addRolePermissions(role, Permission.DEPLOY_BUNDLES);
        bundleManager.deleteBundleDeployment(subject, bd2.getId());

        // deny delete destination
        removeRolePermissions(role, Permission.DEPLOY_BUNDLES);
        try {
            bundleManager.deleteBundleDestination(subject, dest2.getId());
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        addRolePermissions(role, Permission.DEPLOY_BUNDLES);
        BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
        Configuration config = new Configuration();
        config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
        BundleDeployment bd1;
        bd1 = createDeployment(subject, "one", bv1, dest1, config);
        assertNotNull(bd1);

        // deny schedule
        removeRolePermissions(role, Permission.DEPLOY_BUNDLES);
        try {
            BundleDeployment bd1d = bundleManager.scheduleBundleDeployment(subject, bd1.getId(), false);
            fail("Should have thrown PermissionException");
        } catch (PermissionException e) {
            // expected
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

        BundleDestination dest1, ResourceGroup platformResourceGroup, Permission permission) throws Exception {

        // allow
        addRolePermissions(role, permission);

        BundleDeployment bd1d = bundleManager.scheduleBundleDeployment(subject, bd1.getId(), false);
        assertNotNull(bd1d);
        assertEquals(bd1.getId(), bd1d.getId());

        BundleDeploymentCriteria bdc = new BundleDeploymentCriteria();
        bdc.addFilterId(bd1d.getId());
        bdc.fetchBundleVersion(true);
        bdc.fetchDestination(true);
        bdc.fetchResourceDeployments(true);
        bdc.fetchTags(true);
        List<BundleDeployment> bds = bundleManager.findBundleDeploymentsByCriteria(subject, bdc);
        assertEquals(1, bds.size());
        bd1d = bds.get(0);

        assertEquals(platformResourceGroup, bd1d.getDestination().getGroup());
        assertEquals(dest1.getId(), bd1d.getDestination().getId());

        BundleResourceDeploymentCriteria c = new BundleResourceDeploymentCriteria();
        c.addFilterBundleDeploymentId(bd1d.getId());
        c.fetchBundleDeployment(true);
        c.fetchHistories(true);
        c.fetchResource(true);
        List<BundleResourceDeployment> brds = bundleManager.findBundleResourceDeploymentsByCriteria(subject, c);
        assertEquals(1, brds.size());
        assertEquals(1, bd1d.getResourceDeployments().size());
        assertEquals(bd1d.getResourceDeployments().get(0).getId(), brds.get(0).getId());
        BundleResourceDeployment brd = brds.get(0);

        assertNotNull(brd.getBundleResourceDeploymentHistories());
        int size = brd.getBundleResourceDeploymentHistories().size();
        assertTrue(size > 0);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    }

    private BundleDeployment createDeployment(Subject subject, String name, BundleVersion bv, BundleDestination dest,
        Configuration config) throws Exception {
        final String fullName = TEST_PREFIX + "-bundledeployment-" + name;
        BundleDeployment bd = bundleManager.createBundleDeployment(subject, bv.getId(), dest.getId(), fullName, config);

        assert bd.getId() > 0;
        assert bd.getDescription().endsWith(fullName);
        return bd;
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    public BundleDeployment createBundleDeployment(int bundleVersionId, int bundleDestinationId, String description,
        Configuration configuration, boolean enforcePolicy, int enforcementInterval, boolean pinToBundle)
        throws RuntimeException {

        try {
            BundleDeployment result = bundleManager.createBundleDeployment(getSessionSubject(), bundleVersionId,
                bundleDestinationId, description, configuration);
            return SerialUtility.prepare(result, "createBundleDeployment");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    @Override
    public BundleDeployment scheduleBundleDeployment(int bundleDeploymentId, boolean isCleanDeployment)
        throws RuntimeException {
        try {
            BundleDeployment result = bundleManager.scheduleBundleDeployment(getSessionSubject(), bundleDeploymentId,
                isCleanDeployment);
            return SerialUtility.prepare(result, "scheduleBundleDeployment");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    @Override
    public BundleDeployment scheduleRevertBundleDeployment(int bundleDeploymentId, String deploymentDescription,
        boolean isCleanDeployment) throws RuntimeException {
        try {
            BundleDeployment result = bundleManager.scheduleRevertBundleDeployment(getSessionSubject(),
                bundleDeploymentId, deploymentDescription, isCleanDeployment);
            return SerialUtility.prepare(result, "scheduleRevertBundleDeployment");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleDeployment

    public void testUpdateBundleDeploymentTags() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Set<Tag> tags = generateTagSet(7);
                BundleDeployment bundleDeployment = createBundleDeployment();
                bundleDeployment.setTags(emptyTagSet());
                tagManager.updateBundleDeploymentTags(overlord, bundleDeployment.getId(), tags);
                assertEquals(tags, bundleDeployment.getTags());
            }
        });
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.