Package org.rhq.core.domain.operation

Examples of org.rhq.core.domain.operation.ResourceOperationHistory


        PageList<ResourceOperationHistory> results2;
        results2 = operationManager.findCompletedResourceOperationHistories(overlord(), newResource.getId(), null,
            null, PageControl.getUnlimitedInstance());
        assert results2.size() == 2 : "Should have had 2 results since it was triggered twice: " + results2;

        ResourceOperationHistory rHistory0 = results2.get(0);
        assert rHistory0.getId() > 0 : rHistory0;
        assert rHistory0.getJobId() != null : rHistory0;
        assert rHistory0.getJobName() != null : rHistory0;
        assert rHistory0.getJobGroup() != null : rHistory0;
        assert rHistory0.getErrorMessage() == null : rHistory0;
        assert rHistory0.getStatus() == OperationRequestStatus.SUCCESS : rHistory0;
        assert rHistory0.getSubjectName().equals(overlord().getName()) : rHistory0;

        ResourceOperationHistory rHistory1 = results2.get(1);
        assert rHistory1.getId() > 0 : rHistory1;
        assert rHistory1.getId() != rHistory0.getId() : rHistory1;
        assert rHistory1.getJobId() != null : rHistory1;
        assert !rHistory1.getJobId().equals(rHistory0.getJobId()) : rHistory1;
        assert rHistory1.getJobId().getJobGroup().equals(rHistory1.getJobGroup()) : rHistory1;
        assert rHistory1.getJobId().getJobName().equals(rHistory1.getJobName()) : rHistory1;
        assert rHistory1.getJobName() != null : rHistory1;
        assert rHistory1.getJobGroup() != null : rHistory1;
        assert rHistory1.getJobGroup().equals(rHistory0.getJobGroup()) : rHistory1;
        assert rHistory1.getErrorMessage() == null : rHistory1;
        assert rHistory1.getStatus() == OperationRequestStatus.SUCCESS : rHistory1;
        assert rHistory1.getSubjectName().equals(overlord().getName()) : rHistory1;

        operationManager.deleteOperationHistory(overlord(), history0.getId(), false);
        operationManager.deleteOperationHistory(overlord(), history1.getId(), false);
        results = operationManager.findCompletedGroupOperationHistories(overlord(), newGroup.getId(),
            PageControl.getUnlimitedInstance());
View Full Code Here


        // get the one resource history from the group
        PageList<ResourceOperationHistory> results2;
        results2 = operationManager.findCompletedResourceOperationHistories(overlord(), newResource.getId(), null,
            null, PageControl.getUnlimitedInstance());
        ResourceOperationHistory rHistory = results2.get(0);
        assert rHistory.getId() > 0 : rHistory;
        assert rHistory.getJobId() != null : rHistory;
        assert rHistory.getJobName() != null : rHistory;
        assert rHistory.getJobGroup() != null : rHistory;
        assert rHistory.getErrorMessage() == null : rHistory;
        assert rHistory.getStatus() == OperationRequestStatus.SUCCESS : rHistory;
        assert rHistory.getSubjectName().equals(overlord().getName()) : rHistory;

        // parameters and results are lazily loaded in the paginated queries, but are eagerly individually
        rHistory = (ResourceOperationHistory) operationManager.getOperationHistoryByHistoryId(overlord(),
            rHistory.getId());
        assert rHistory.getResults() != null;
        assert rHistory.getResults().getSimple("param1echo") != null;
        assert rHistory.getResults().getSimple("param1echo").getStringValue().equals("group-test");
        assert rHistory.getParameters().getId() != scheduleParamId : "params should be copies - not shared";
        assert rHistory.getParameters().getId() != history.getParameters().getId() : "params should be copies - not shared";

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedGroupOperationHistories(overlord(), newGroup.getId(),
            PageControl.getUnlimitedInstance());
        assert results != null;
View Full Code Here

        // get the one resource history from the group
        PageList<ResourceOperationHistory> results2;
        results2 = operationManager.findCompletedResourceOperationHistories(overlord(), newResource.getId(), null,
            null, PageControl.getUnlimitedInstance());
        ResourceOperationHistory rHistory = results2.get(0);
        assert rHistory.getId() > 0 : rHistory;
        assert rHistory.getJobId() != null : rHistory;
        assert rHistory.getJobName() != null : rHistory;
        assert rHistory.getJobGroup() != null : rHistory;
        assert rHistory.getErrorMessage() != null : rHistory;
        assert rHistory.getErrorMessage().indexOf("an error!") > -1 : rHistory;
        assert rHistory.getStatus() == OperationRequestStatus.FAILURE : rHistory;
        assert rHistory.getSubjectName().equals(overlord().getName()) : rHistory;

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedGroupOperationHistories(overlord(), newGroup.getId(),
            PageControl.getUnlimitedInstance());
        assert results != null;
View Full Code Here

        // get the one resource history from the group
        PageList<ResourceOperationHistory> results2;
        results2 = operationManager.findCompletedResourceOperationHistories(overlord(), newResource.getId(), null,
            null, PageControl.getUnlimitedInstance());
        ResourceOperationHistory rHistory = results2.get(0);
        assert rHistory.getId() > 0 : rHistory;
        assert rHistory.getJobId() != null : rHistory;
        assert rHistory.getJobName() != null : rHistory;
        assert rHistory.getJobGroup() != null : rHistory;
        assert rHistory.getErrorMessage() != null : rHistory;
        assert rHistory.getErrorMessage().indexOf("Timed out") > -1 : rHistory;
        assert rHistory.getStatus() == OperationRequestStatus.FAILURE : rHistory;
        assert rHistory.getSubjectName().equals(overlord().getName()) : rHistory;

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedGroupOperationHistories(overlord(), newGroup.getId(),
            PageControl.getUnlimitedInstance());
        assert results != null;
View Full Code Here

            results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null,
                null, PageControl.getUnlimitedInstance());
        }
        assert results.size() == 1 : "Did not get 1 result, but " + results.size();

        final ResourceOperationHistory history = results.get(0);
        assert history.getErrorMessage() != null : history;
        assert history.getErrorMessage().indexOf("some error") > -1 : history;
        assert history.getStatus() == OperationRequestStatus.FAILURE : history;

        // We'll throw in a time based purge test here. We can't purge before current time because we could wipe out
        // stuff generated by other tests.  To try and limit what we wipe out, set the ctime of the res history to
        // be very old...
        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Query q = em.createQuery("update ResourceOperationHistory h set h.createdTime = 900 where h.id = "
                    + history.getId());
                int numUpdated = q.executeUpdate();
                assertEquals(1, numUpdated);
            }
        });
        assertEquals(1, operationManager.purgeOperationHistory(new Date(1000)));
View Full Code Here

            results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null,
                null, PageControl.getUnlimitedInstance());
        }
        assert results.size() == 1 : "Did not get 1 result but " + results.size();

        ResourceOperationHistory history = results.get(0);
        assert history.getErrorMessage() != null : history;
        assert history.getErrorMessage().indexOf("Timed out") > -1 : history;
        assert history.getStatus() == OperationRequestStatus.FAILURE : history;

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);

        // make sure it was purged
        results = operationManager.findCompletedResourceOperationHistories(overlord(), newResource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
View Full Code Here

            }
        }

        assert results != null;
        assert results.size() == 1;
        ResourceOperationHistory history = results.get(0);
        assert history.getStatus() == OperationRequestStatus.INPROGRESS : history;

        operationManager.cancelOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 1;
        history = results.get(0);
        assert history.getStatus() == OperationRequestStatus.CANCELED : history;
        System.out.println("test: Canceled resource history: " + history);

        // try to cancel it again, just to make sure it blows up appropriately
        try {
            operationManager.cancelOperationHistory(overlord(), history.getId(), false);
            assert false : "Should not have been able to cancel an operation that is not INPROGRESS";
        } catch (EJBException expected) {
            // expected
        }

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 0;
    }
View Full Code Here

            }
        }

        assert results != null;
        assert results.size() == 1;
        ResourceOperationHistory history = results.get(0);
        assert history.getStatus() == OperationRequestStatus.INPROGRESS : history;

        operationManager.cancelOperationHistory(overlord(), history.getId(), false);

        // show that there are still no completed operations yet
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 0;

        // still pending - our operation wasn't really canceled - waiting for the agent to tell us its finished
        results = operationManager.findPendingResourceOperationHistories(overlord(), resource.getId(),
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 1;
        history = results.get(0);

        // we should have been told it finished on the agent - so we didn't cancel it
        // server-side still will say inprogress - we are waiting for the agent to tell us
        // the results of the finished operation, which should be imminent
        assert history.getStatus() == OperationRequestStatus.INPROGRESS : history;
        System.out.println("test: Uncancelable resource history: " + history);

        operationManager.deleteOperationHistory(overlord(), history.getId(), true);
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 0;
    }
View Full Code Here

        PageList<ResourceOperationHistory> results;
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 1;
        ResourceOperationHistory history = results.get(0);
        assert history.getId() > 0 : history;
        assert history.getJobId() != null : history;
        assert history.getJobName() != null : history;
        assert history.getJobGroup() != null : history;
        assert history.getErrorMessage() == null : history;
        assert history.getStatus() == OperationRequestStatus.SUCCESS : history;
        assert history.getSubjectName().equals(overlord().getName()) : history;

        PageList<ResourceOperationLastCompletedComposite> list;
        list = operationManager.findRecentlyCompletedResourceOperations(overlord(), null,
            PageControl.getUnlimitedInstance());
        assert list.size() == 1;
        assert list.get(0).getOperationHistoryId() == history.getId();
        assert list.get(0).getResourceId() == resource.getId();
        assert list.get(0).getResourceName().equals(resource.getName());
        assert list.get(0).getOperationName().equals("Test Operation");

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 0;
View Full Code Here

        PageList<ResourceOperationHistory> results;
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 1;
        ResourceOperationHistory history = results.get(0);
        assert history.getId() > 0 : history;
        assert history.getJobId() != null : history;
        assert history.getJobName() != null : history;
        assert history.getJobGroup() != null : history;
        assert history.getErrorMessage() == null : history;
        assert history.getStatus() == OperationRequestStatus.SUCCESS : history;
        assert history.getSubjectName().equals(overlord().getName()) : history;

        PageList<ResourceOperationLastCompletedComposite> list;
        list = operationManager.findRecentlyCompletedResourceOperations(overlord(), null,
            PageControl.getUnlimitedInstance());
        assert list.size() == 1;
        assert list.get(0).getOperationHistoryId() == history.getId();
        assert list.get(0).getResourceId() == resource.getId();
        assert list.get(0).getResourceName().equals(resource.getName());
        assert list.get(0).getOperationName().equals("Test Operation");

        operationManager.deleteOperationHistory(overlord(), history.getId(), false);
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
            PageControl.getUnlimitedInstance());
        assert results != null;
        assert results.size() == 0;
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.operation.ResourceOperationHistory

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.