Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.PackageVersion


        packageType1.setResourceType(resourceType1);
        em.persist(packageType1);
        em.flush();
        Package package1 = new Package("Package1", packageType1);

        package1.addVersion(new PackageVersion(package1, "1.0.0", architecture1));
        package1.addVersion(new PackageVersion(package1, "2.0.0", architecture1));

        em.persist(package1);
        em.flush();
        //AdvisoryPackage ap = new AdvisoryPackage(advobject, package1);
        //em.persist(ap);
View Full Code Here


        Subject overlord = subjectManager.getOverlord();

        Set<ResourcePackageDetails> installUs = new HashSet<ResourcePackageDetails>(2);

        // Package 1, Version 2 with configuration values
        PackageVersion packageVersion1 = package1.getVersions().get(0);
        Configuration deploymentConfiguration1 = new Configuration();
        deploymentConfiguration1.put(new PropertySimple("property1", "value1"));

        PackageDetailsKey key1 = new PackageDetailsKey(package1.getName(), packageVersion1.getVersion(), package1
            .getPackageType().getName(), packageVersion1.getArchitecture().getName());
        ResourcePackageDetails packageDetails1 = new ResourcePackageDetails(key1);
        packageDetails1.setDeploymentTimeConfiguration(deploymentConfiguration1);

        installUs.add(packageDetails1);

        // Make sure the mock is configured to return a success
        this.contentAgentService.setResponseReturnStatus(ContentResponseResult.SUCCESS);
        this.contentAgentService.setThrowError(false);
        this.contentAgentService.setReturnIndividualResponses(true);
        this.contentAgentService.setDeployPackageSteps(stepResults);

        String notes = "Test deploy notes";

        // Test  --------------------------------------------

        // Perform the deploy while locking the agent service. This allows us to check the state after the request
        // is sent to the agent but before the agent has replied.
        synchronized (responseLock) {
            contentManager.deployPackages(overlord, resource1.getId(), installUs, notes);

            // Check to see if the request and installed package were created and have the right status
            getTransactionManager().begin();

            try {
                // Content request
                Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
                query.setParameter("resourceId", resource1.getId());

                List<?> results = query.getResultList();
                assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
                    + results.size();

                ContentServiceRequest request = (ContentServiceRequest) results.get(0);
                assert request.getContentRequestType() == ContentRequestType.DEPLOY : "Request type incorrect. Expected: DEPLOY, Found: "
                    + request.getContentRequestType();
                assert request.getStatus() == ContentRequestStatus.IN_PROGRESS : "Request status incorrect. Expected: IN_PROGRESS, Found: "
                    + request.getStatus();
                assert request.getInstalledPackageHistory().size() == 1 : "Incorrect number of installed packages attached to request. Expected: 1, Found: "
                    + request.getInstalledPackageHistory().size();
                assert request.getNotes() != null : "Null notes found";
                assert request.getNotes().equals(notes) : "Incorrect notes found: " + request.getNotes();

                // Verify a history entry has been added for each package in the request
                Set<InstalledPackageHistory> history = request.getInstalledPackageHistory();

                assert history.size() == 1 : "Incorrect number of history entries on request. Expected: 2, Found: "
                    + history.size();

                for (InstalledPackageHistory historyEntry : history) {
                    assert historyEntry.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect state on history entity. Expected: BEING_INSTALLED, Found: "
                        + historyEntry.getStatus();
                }

            } finally {
                responseLock.notifyAll();

                getTransactionManager().rollback();
            }
        }

        // Verify  --------------------------------------------

        // Give the agent service a second to make sure it finishes out its call
        Thread.sleep(1000);

        getTransactionManager().begin();

        try {
            // Content request
            Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
            query.setParameter("resourceId", resource1.getId());

            List<?> results = query.getResultList();
            assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
                + results.size();

            ContentServiceRequest request = (ContentServiceRequest) results.get(0);
            assert request.getStatus() == ContentRequestStatus.SUCCESS : "Request status incorrect. Expected: SUCCESS, Found: "
                + request.getStatus();

            // Verify a history entry has been added for the completion of the request per package
            Set<InstalledPackageHistory> history = request.getInstalledPackageHistory();

            assert history.size() == 2 : "Incorrect number of history entries on request. Expected: 2, Found: "
                + history.size();

            // Check for Package 1
            query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
            query.setParameter("contentServiceRequestId", request.getId());
            query.setParameter("packageVersionId", packageVersion1.getId());

            results = query.getResultList();

            assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
View Full Code Here

        // Package 1, Version 2 with configuration values
        Configuration deploymentConfiguration1 = new Configuration();
        deploymentConfiguration1.put(new PropertySimple("property1", "value1"));

        PackageVersion packageVersion1 = package1.getVersions().get(1);
        PackageDetailsKey key1 = new PackageDetailsKey(package1.getName(), packageVersion1.getVersion(), package1
            .getPackageType().getName(), packageVersion1.getArchitecture().getName());

        ResourcePackageDetails packageDetails1 = new ResourcePackageDetails(key1);
        packageDetails1.setDeploymentTimeConfiguration(deploymentConfiguration1);

        installUs.add(packageDetails1);

        // Make sure the mock is configured to return a failure
        this.contentAgentService.setResponseReturnStatus(ContentResponseResult.FAILURE);
        this.contentAgentService.setThrowError(false);
        this.contentAgentService.setReturnIndividualResponses(true);

        String notes = "Test deploy notes";

        // Test  --------------------------------------------
        contentManager.deployPackages(overlord, resource1.getId(), installUs, notes);

        // Verify  --------------------------------------------

        // Give the agent service a second to make sure it finishes out its call
        Thread.sleep(1000);

        getTransactionManager().begin();

        try {
            // Content request
            Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
            query.setParameter("resourceId", resource1.getId());

            List<?> results = query.getResultList();
            assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
                + results.size();

            ContentServiceRequest request = (ContentServiceRequest) results.get(0);
            assert request.getStatus() == ContentRequestStatus.FAILURE : "Request status incorrect. Expected: IN_PROGRESS, Found: "
                + request.getStatus();
            assert request.getNotes() != null : "Null notes found";
            assert request.getNotes().equals(notes) : "Incorrect notes found: " + request.getNotes();

            // Check for Package 1
            query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
            query.setParameter("contentServiceRequestId", request.getId());
            query.setParameter("packageVersionId", packageVersion1.getId());

            results = query.getResultList();

            assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
View Full Code Here

        // Package 1, Version 2 with configuration values
        Configuration deploymentConfiguration1 = new Configuration();
        deploymentConfiguration1.put(new PropertySimple("property1", "value1"));

        PackageVersion packageVersion1 = package1.getVersions().get(1);
        PackageDetailsKey key1 = new PackageDetailsKey(package1.getName(), packageVersion1.getVersion(), package1
            .getPackageType().getName(), packageVersion1.getArchitecture().getName());
        ResourcePackageDetails packageDetails1 = new ResourcePackageDetails(key1);
        packageDetails1.setDeploymentTimeConfiguration(deploymentConfiguration1);

        installUs.add(packageDetails1);

        // Make sure the mock is configured to return a failure
        this.contentAgentService.setResponseReturnStatus(ContentResponseResult.FAILURE);
        this.contentAgentService.setThrowError(true);
        this.contentAgentService.setReturnIndividualResponses(false);

        String notes = "Test deploy notes";

        // Test  --------------------------------------------
        try {
            contentManager.deployPackages(overlord, resource1.getId(), installUs, notes);
            assert false : "No exception thrown from deploy call";
        } catch (Exception e) {
            // Expected
        }

        // Verify  --------------------------------------------

        getTransactionManager().begin();

        try {
            // Content request
            Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
            query.setParameter("resourceId", resource1.getId());

            List<?> results = query.getResultList();
            assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
                + results.size();

            ContentServiceRequest request = (ContentServiceRequest) results.get(0);
            assert request.getStatus() == ContentRequestStatus.FAILURE : "Request status incorrect. Expected: IN_PROGRESS, Found: "
                + request.getStatus();
            assert request.getNotes() != null : "Null notes found";
            assert request.getNotes().equals(notes) : "Incorrect notes found: " + request.getNotes();

            // Check for Package 1
            query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
            query.setParameter("contentServiceRequestId", request.getId());
            query.setParameter("packageVersionId", packageVersion1.getId());

            results = query.getResultList();

            assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
View Full Code Here

        // Package 1, Version 2 with configuration values
        Configuration deploymentConfiguration1 = new Configuration();
        deploymentConfiguration1.put(new PropertySimple("property1", "value1"));

        PackageVersion packageVersion1 = package1.getVersions().get(1);
        PackageDetailsKey key1 = new PackageDetailsKey(package1.getName(), packageVersion1.getVersion(), package1
            .getPackageType().getName(), packageVersion1.getArchitecture().getName());
        ResourcePackageDetails packageDetails1 = new ResourcePackageDetails(key1);
        packageDetails1.setDeploymentTimeConfiguration(deploymentConfiguration1);

        installUs.add(packageDetails1);

        // Make sure the mock is configured to return a failure
        this.contentAgentService.setResponseReturnStatus(ContentResponseResult.FAILURE);
        this.contentAgentService.setThrowError(false);
        this.contentAgentService.setReturnIndividualResponses(false);

        String notes = "Test deploy notes";

        // Test  --------------------------------------------
        contentManager.deployPackages(overlord, resource1.getId(), installUs, notes);

        // Give the agent service a second to make sure it finishes out its call
        Thread.sleep(1000);

        // Verify  --------------------------------------------

        getTransactionManager().begin();

        try {
            // Content request
            Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
            query.setParameter("resourceId", resource1.getId());

            List<?> results = query.getResultList();
            assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
                + results.size();

            ContentServiceRequest request = (ContentServiceRequest) results.get(0);
            assert request.getStatus() == ContentRequestStatus.FAILURE : "Request status incorrect. Expected: FAILURE, Found: "
                + request.getStatus();
            assert request.getNotes() != null : "Null notes found";
            assert request.getNotes().equals(notes) : "Incorrect notes found: " + request.getNotes();

            // Check for Package 1
            query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
            query.setParameter("contentServiceRequestId", request.getId());
            query.setParameter("packageVersionId", packageVersion1.getId());

            results = query.getResultList();

            assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
View Full Code Here

    public void testLoadDependencies() throws Exception {
        // Setup  --------------------------------------------
        Set<PackageDetailsKey> loadUs = new HashSet<PackageDetailsKey>(3);

        // Package 1, Version 2
        PackageVersion packageVersion1 = package1.getVersions().get(1);
        PackageDetailsKey packageKey1 = new PackageDetailsKey(package1.getName(), packageVersion1.getVersion(),
            package1.getPackageType().getName(), packageVersion1.getArchitecture().getName());

        loadUs.add(packageKey1);

        // Package 2, Version 2
        PackageVersion packageVersion2 = package2.getVersions().get(1);
        PackageDetailsKey packageKey2 = new PackageDetailsKey(package2.getName(), packageVersion2.getVersion(),
            package2.getPackageType().getName(), packageVersion2.getArchitecture().getName());

        loadUs.add(packageKey2);

        // Package that does not exist in the server
        PackageDetailsKey packageKey3 = new PackageDetailsKey("foo", "1.0.0", "fooType", "fooArch");

        loadUs.add(packageKey3);

        // Need to create a content service request off of which to hang the dependencies as new installed package requests
        getTransactionManager().begin();

        ContentServiceRequest request = null;
        try {
            resource1 = em.find(Resource.class, resource1.getId());
            Subject overlord = subjectManager.getOverlord();
            PackageVersion packageVersion = em.find(PackageVersion.class, package3.getVersions().get(0).getId());

            request = new ContentServiceRequest(resource1, overlord.getName(), ContentRequestType.DEPLOY);

            InstalledPackageHistory originalRequestedPackage = new InstalledPackageHistory();
            originalRequestedPackage.setContentServiceRequest(request);
View Full Code Here

            resourceType1.addPackageType(packageType3);

            // Package 1 - Contains 2 versions
            package1 = new Package("Package1", packageType1);

            package1.addVersion(new PackageVersion(package1, "1.0.0", architecture1));
            package1.addVersion(new PackageVersion(package1, "2.0.0", architecture1));

            em.persist(package1);

            // Package 2 - Contains 2 versions
            package2 = new Package("Package2", packageType2);

            package2.addVersion(new PackageVersion(package2, "1.0.0", architecture1));
            package2.addVersion(new PackageVersion(package2, "2.0.0", architecture1));

            em.persist(package2);

            // Package 3 - Contains 1 version
            package3 = new Package("Package3", packageType3);

            package3.addVersion(new PackageVersion(package3, "1.0.0", architecture1));

            em.persist(package3);

            // Package 4 - Contains 2 versions, the first is installed
            package4 = new Package("Package4", packageType4);

            PackageVersion package4Installed = new PackageVersion(package4, "1.0.0", architecture1);
            package4.addVersion(package4Installed);
            package4.addVersion(new PackageVersion(package4, "2.0.0", architecture1));

            em.persist(package4);

            // Package 5 - Contains 1 version, it is installed
            package5 = new Package("Package5", packageType3);

            PackageVersion package5Installed = new PackageVersion(package5, "1.0.0", architecture1);
            package5.addVersion(package5Installed);

            em.persist(package5);

            // Create resource against which we'll merge the discovery report
View Full Code Here

            renderMetadata(request, response, repo);
            return;
        }

        log.debug("fetch package bits and return them.");
        PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
        if (pv == null) {
            log.info("Unable to find PackageVersion from filename: " + fileName);
            renderErrorPage(request, response);
            return;
        }
View Full Code Here

        // This could be a request for a package.  Package requests will come in as:
        // ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm 

        String possiblePkgName = getLastPiece(request.getRequestURI());
        log.debug("Looking up : " + possiblePkgName + ", it might be a package request");
        PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
        if (pv != null) {
            log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
            //response.setContentType("application/octet-stream");
            writePackageVersionBits(request, response, pv);
            return;
View Full Code Here

            .getOverlord(), criteria);
        for (PackageVersion pkgV : pkgVers) {
            log.debug("PackageVersion found: " + pkgV);
        }
        log.debug("Found " + pkgVers.size() + " entries");
        PackageVersion pv = null;
        if (pkgVers.size() > 0) {
            pv = pkgVers.get(0);
        } else {
            log.info("Couldn't find " + fileName + " in " + repo.getName());
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.PackageVersion

Copyright © 2018 www.massapicom. 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.