Search in sources :

Example 31 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class StatusTests method testStatusOnInvalidDate.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36567", "RHEL7-51355" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "run subscription-manager status ondate (invalid)", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusOnInvalidDate() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.9.2-1"))
        throw new SkipException("Installed package '" + clienttasks.installedPackageVersionMap.get("subscription-manager") + "' does not support status --ondate option.  It was introduced in subscription-manager-1.9.2-1.");
    // call status with an invalid ondate
    // lucky month 13
    SSHCommandResult statusResultYesterday = clienttasks.status_("2000-13-01", null, null, null, null);
    DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String today = yyyy_MM_dd_DateFormat.format(Calendar.getInstance().getTime());
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(statusResultYesterday.getStderr().trim(), String.format("Date entered is invalid. Date should be in YYYY-MM-DD format (example: %s )", today), "Stderr from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getStdout().trim(), "", "Stdout from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getExitCode(), Integer.valueOf(65), /*EX_DATAERR*/
        "ExitCode from call to status ondate invalid.");
    } else {
        Assert.assertEquals(statusResultYesterday.getStdout().trim(), String.format("Date entered is invalid. Date should be in YYYY-MM-DD format (example: %s )", today), "Stdout from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getStderr().trim(), "", "Stderr from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getExitCode(), Integer.valueOf(1), "ExitCode from call to status ondate invalid.");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SkipException(org.testng.SkipException) SimpleDateFormat(java.text.SimpleDateFormat) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 32 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class StatusTests method testStatusWithoutBeingRegistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36569", "RHEL7-51357" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "run subscription-manager status without being registered; status should be Unknown", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusWithoutBeingRegistered() {
    SSHCommandResult statusResult;
    clienttasks.unregister(null, null, null, null);
    statusResult = clienttasks.status(null, null, null, null, null);
    // [root@jsefler-5 ~]# subscription-manager status
    // +-------------------------------------------+
    // System Status Details
    // +-------------------------------------------+
    // Overall Status: Unknown
    String expectedStatus = "Overall Status: Unknown";
    Assert.assertTrue(statusResult.getStdout().contains(expectedStatus), "Expecting '" + expectedStatus + "' when not registered.");
    Assert.assertEquals(statusResult.getStdout().replaceFirst("\\+-+\\+\\n\\s*System Status Details\\s*\\n\\+-+\\+", "").trim(), expectedStatus, "Expecting ONLY '" + expectedStatus + "' to be reported when not registered.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 33 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class StorageBandTests method testAutoHealStorageBandSubscription.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21461", "RHEL7-51710" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify if you auto-heal a system using 300TB of storage, installed storage product is fully subscribed from multiple pools that provide 256TB of coverage.", groups = { "Tier3Tests", "AutoHealStorageBandSubscription" }, dataProvider = "getStorageBandSubscriptions", enabled = true)
public void testAutoHealStorageBandSubscription(Object Bugzilla, SubscriptionPool storagebandpool) throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    log.info("To auto-heal this system for '" + bandStorageUsage + "'TB of storage, there must be more than one stackable pool for product SKU '" + storagebandpool.productId + "'.");
    // to troubleshoot the existance of multiple pools
    SSHCommandResult listResult = clienttasks.list(null, true, null, null, null, null, null, null, storagebandpool.productId, null, null, null, null, null);
    List<SubscriptionPool> availableStorageBandPools = SubscriptionPool.parse(listResult.getStdout());
    String expectedStatus = availableStorageBandPools.size() > 1 ? "Subscribed" : "Not Subscribed";
    clienttasks.autoheal(null, true, null, null, null, null, null);
    clienttasks.run_rhsmcertd_worker(true);
    List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, storagebandpool.poolId);
    List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    for (String providedProductId : providedProductIds) {
        InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
        if (installedProduct != null) {
            Assert.assertEquals(installedProduct.status.trim(), expectedStatus, "Status of installed product '" + installedProduct.productName + "' provided for by Storage Band entitlement pools that covers only 256TB on a system using '" + bandStorageUsage + "'TBs (that has been autohealed with '" + availableStorageBandPools.size() + "' available '" + storagebandpool.productId + "' pools)");
        }
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) InstalledProduct(rhsm.data.InstalledProduct) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 34 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscribeTests method testSubscribeToMultipleDuplicateAndBadPools.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36587", "RHEL7-51390" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager-cli: subscribe consumer to multiple/duplicate/bad pools in one call", groups = { "Tier2Tests", "blockedByBug-622851", "blockedByBug-995597" }, enabled = true)
public void testSubscribeToMultipleDuplicateAndBadPools() throws JSONException, Exception {
    // begin the test with a cleanly registered system
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // assemble a list of all the available SubscriptionPool ids with duplicates and bad ids
    List<String> poolIds = new ArrayList<String>();
    Map<String, String> poolNames = new HashMap<String, String>();
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        poolIds.add(pool.poolId);
        // add a duplicate poolid
        poolIds.add(pool.poolId);
        poolNames.put(pool.poolId, pool.subscriptionName);
    }
    String badPoolId1 = "bad123", badPoolId2 = "bad_POOLID";
    // insert a bad poolid
    poolIds.add(0, badPoolId1);
    // append a bad poolid
    poolIds.add(badPoolId2);
    // subscribe to all pool ids
    log.info("Attempting to subscribe to multiple pools with duplicate and bad pool ids...");
    SSHCommandResult subscribeResult = clienttasks.subscribe_(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    /*
		No such entitlement pool: bad123
		Successfully subscribed the system to Pool 8a90f8c63159ce55013159cfd6c40303
		This consumer is already subscribed to the product matching pool with id '8a90f8c63159ce55013159cfd6c40303'.
		Successfully subscribed the system to Pool 8a90f8c63159ce55013159cfea7a06ac
		Successfully subscribed the system to Pool 8a90f8c63159ce55013159cfea7a06ac
		No such entitlement pool: bad_POOLID
		*/
    // assert the results...
    Assert.assertEquals(subscribeResult.getExitCode(), Integer.valueOf(0), "The exit code from the subscribe command indicates a success.");
    for (String poolId : poolIds) {
        String subscribeResultMessage;
        if (poolId.equals(badPoolId1) || poolId.equals(badPoolId2)) {
            subscribeResultMessage = String.format("No such entitlement pool: %s", poolId);
            subscribeResultMessage = String.format("Subscription pool %s does not exist.", poolId);
            subscribeResultMessage = String.format("Pool with id %s could not be found.", poolId);
            Assert.assertTrue(subscribeResult.getStdout().contains(subscribeResultMessage), "The subscribe result for an invalid pool '" + poolId + "' contains: " + subscribeResultMessage);
        } else if (CandlepinTasks.isPoolProductMultiEntitlement(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolId)) {
            // Bug 812410 - Subscription-manager subscribe CLI feedback
            subscribeResultMessage = String.format("Successfully consumed a subscription from the pool with id %s.", poolId);
            // changed by Bug 874804 Subscribe -> Attach
            subscribeResultMessage = String.format("Successfully consumed a subscription for: %s", poolNames.get(poolId));
            subscribeResultMessage = String.format("Successfully attached a subscription for: %s", poolNames.get(poolId));
            subscribeResultMessage += "\n" + subscribeResultMessage;
            Assert.assertTrue(subscribeResult.getStdout().contains(subscribeResultMessage), "The duplicate subscribe result for a multi-entitlement pool '" + poolId + "' contains: " + subscribeResultMessage);
        } else if (false) {
        // TODO case when there are no entitlements remaining for the duplicate subscribe
        } else {
            // Bug 812410 - Subscription-manager subscribe CLI feedback
            subscribeResultMessage = String.format("Successfully consumed a subscription from the pool with id %s.", poolId);
            // changed by Bug 874804 Subscribe -> Attach
            subscribeResultMessage = String.format("Successfully consumed a subscription for: %s", poolNames.get(poolId));
            subscribeResultMessage = String.format("Successfully attached a subscription for: %s", poolNames.get(poolId));
            String subscribeResultSubMessage = String.format("This consumer is already subscribed to the product matching pool with id '%s'.", poolId);
            if (!clienttasks.workaroundForBug876764(sm_serverType))
                subscribeResultSubMessage = String.format("This unit has already had the subscription matching pool ID '%s' attached.", poolId);
            if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
                // commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
                subscribeResultSubMessage = String.format("This unit has already had the subscription matching pool ID \"%s\" attached.", poolId);
            }
            subscribeResultMessage += "\n" + subscribeResultSubMessage;
            Assert.assertTrue(subscribeResult.getStdout().contains(subscribeResultMessage), "The duplicate subscribe result for pool '" + poolId + "' contains: " + subscribeResultMessage);
        }
    }
}
Also used : HashMap(java.util.HashMap) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 35 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class SubscribeTests method testSubscribeToFutureSubscriptionPool.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27122", "RHEL7-51945" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: subscribe to future subscription pool", groups = { "Tier2Tests", "blockedByBug-979492", "blockedByBug-1440180" }, // dataProvider="getAllFutureSystemSubscriptionPoolsData",	// 06/04/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfFutureSystemSubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeToFutureSubscriptionPool(SubscriptionPool pool) throws Exception {
    // if (!pool.productId.equals("awesomeos-virt-unlmtd-phys")) throw new SkipException("debugTesting pool productId="+pool.productId);
    Calendar now = new GregorianCalendar();
    now.setTimeInMillis(System.currentTimeMillis());
    // subscribe to the future subscription pool
    SSHCommandResult subscribeResult = clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
    // Pool is restricted to physical systems: '8a9086d3443c043501443c052aec1298'.
    if (subscribeResult.getStdout().startsWith("Pool is restricted")) {
        throw new SkipException("Subscribing to this future subscription is not applicable to this test: " + pool);
    }
    // assert that the granted entitlement cert begins in the future
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    Assert.assertNotNull(entitlementCert, "Found the newly granted EntitlementCert on the client after subscribing to future subscription pool '" + pool.poolId + "'.");
    Assert.assertTrue(entitlementCert.validityNotBefore.after(now), "The newly granted EntitlementCert is not valid until the future.  EntitlementCert: " + entitlementCert);
    Assert.assertTrue(entitlementCert.orderNamespace.startDate.after(now), "The newly granted EntitlementCert's OrderNamespace starts in the future.  OrderNamespace: " + entitlementCert.orderNamespace);
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)553 Test (org.testng.annotations.Test)416 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)401 SkipException (org.testng.SkipException)219 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)201 ArrayList (java.util.ArrayList)101 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)79 BigInteger (java.math.BigInteger)68 File (java.io.File)58 SubscriptionPool (rhsm.data.SubscriptionPool)53 JSONObject (org.json.JSONObject)47 HashMap (java.util.HashMap)42 ProductSubscription (rhsm.data.ProductSubscription)31 EntitlementCert (rhsm.data.EntitlementCert)30 List (java.util.List)21 YumRepo (rhsm.data.YumRepo)18 ProductCert (rhsm.data.ProductCert)17 Repo (rhsm.data.Repo)16 InstalledProduct (rhsm.data.InstalledProduct)15 Calendar (java.util.Calendar)13