Search in sources :

Example 16 with ProductSubscription

use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.

the class BugzillaTests method testStartEndDateOfSubscription.

/**
 * @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-21970", "RHEL7-51832" }, 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 End date and start date of the subscription is appropriate one when you attach a future subscription and then  heal after 1 min", groups = { "Tier3Tests", "VerifyStartEndDateOfSubscription", "blockedByBug-994853", "blockedByBug-1440934" }, enabled = true)
public void testStartEndDateOfSubscription() throws Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(4));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    // [jsefler] I believe
    clienttasks.facts(null, true, null, null, null, null);
    // facts --update
    // should be called
    // after overriding
    // facts
    clienttasks.autoheal(null, null, true, null, null, null, null);
    for (SubscriptionPool AvailablePools : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        if (AvailablePools.productId.equals("awesomeos-x86_64")) {
            clienttasks.subscribe(null, null, AvailablePools.poolId, null, null, "1", null, null, null, null, null, null, null);
        }
    }
    InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "100000000000002", clienttasks.getCurrentlyInstalledProducts());
    for (ProductSubscription consumedProductSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        if (consumedProductSubscription.provides.contains(installedProduct.productName)) {
            Assert.assertTrue(!installedProduct.startDate.after(consumedProductSubscription.startDate), "Comparing Start Date '" + InstalledProduct.formatDateString(installedProduct.startDate) + "' of Installed Product '" + installedProduct.productName + "' to Start Date '" + InstalledProduct.formatDateString(consumedProductSubscription.startDate) + "' of Consumed Subscription '" + consumedProductSubscription.productName + "'.  (Installed Product startDate should be <= Consumed Subscription startDate)");
        }
    }
    clienttasks.autoheal(null, true, null, null, null, null, null);
    clienttasks.restart_rhsmcertd(null, null, true);
    InstalledProduct installedProductAfterRHSM = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "100000000000002", clienttasks.getCurrentlyInstalledProducts());
    for (ProductSubscription consumedProductSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        if (consumedProductSubscription.provides.contains(installedProductAfterRHSM.productName)) {
            Assert.assertTrue(!installedProductAfterRHSM.startDate.after(consumedProductSubscription.startDate), "Comparing Start Date '" + InstalledProduct.formatDateString(installedProductAfterRHSM.startDate) + "' of Installed Product '" + installedProductAfterRHSM.productName + "' to Start Date '" + InstalledProduct.formatDateString(consumedProductSubscription.startDate) + "' of Consumed Subscription '" + consumedProductSubscription.productName + "'.  (Installed Product startDate should be <= Consumed Subscription startDate)");
            if (!consumedProductSubscription.isActive) {
                Assert.assertEquals(installedProductAfterRHSM.endDate, consumedProductSubscription.endDate);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) ProductSubscription(rhsm.data.ProductSubscription) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 17 with ProductSubscription

use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.

the class BugzillaTests method testRegisterWithConsumerId.

/**
 * @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-21989", "RHEL7-51851" }, 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 = "subscription-manager: register --consumerid  using a different user and valid consumerId", groups = { "Tier3Tests", "reregister", "blockedByBug-627665" }, enabled = true)
public void testRegisterWithConsumerId() 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);
    String consumerId = clienttasks.getCurrentConsumerId();
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    if (pools.isEmpty())
        throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
    SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
    clienttasks.subscribeToSubscriptionPool(pool);
    List<ProductSubscription> consumedSubscriptionsBeforeregister = clienttasks.getCurrentlyConsumedProductSubscriptions();
    clienttasks.clean_();
    if (sm_client2Username == null)
        throw new SkipException("This test requires valid credentials for a second user.");
    clienttasks.register_(sm_client2Username, sm_client2Password, sm_client2Org, null, null, null, consumerId, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    String consumerIdAfter = clienttasks.getCurrentConsumerId();
    Assert.assertEquals(consumerId, consumerIdAfter, "The consumer identity  has not changed after registering with consumerid.");
    List<ProductSubscription> consumedscriptionsAfterregister = clienttasks.getCurrentlyConsumedProductSubscriptions();
    Assert.assertTrue(consumedscriptionsAfterregister.containsAll(consumedSubscriptionsBeforeregister) && consumedSubscriptionsBeforeregister.size() == consumedscriptionsAfterregister.size(), "The list of consumed products after reregistering is identical.");
}
Also used : ProductSubscription(rhsm.data.ProductSubscription) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 18 with ProductSubscription

use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.

the class BugzillaTests method testAddingVirtualPoolToActivationKey.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@SuppressWarnings("deprecation")
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21899", "RHEL7-51760" }, 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 fix for Bug 755677 - failing to add a virt unlimited pool to an activation key", groups = { "Tier3Tests", "AddingVirtualPoolToActivationKey", "blockedByBug-755677", "blockedByBug-1555582" }, enabled = true)
public void testAddingVirtualPoolToActivationKey() throws JSONException, Exception {
    Integer addQuantity = 1;
    String consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null));
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    String Productname, productId;
    List<String> providedProductIds = new ArrayList<String>();
    Productname = "virt-only-product to be added to activation key";
    productId = "virt-only-test-product";
    String poolId = null;
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("version", "1.0");
    attributes.put("variant", "server");
    attributes.put("arch", "ALL");
    attributes.put("warning_period", "30");
    attributes.put("type", "MKT");
    attributes.put("type", "SVC");
    attributes.put("virt_limit", "unlimited");
    CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, productId);
    String resourcePath = "/products/" + productId;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, Productname, productId, 1, attributes, null);
    CandlepinTasks.createSubscriptionAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey, 20, -1 * 24 * 60, /* 1 day ago */
    15 * 24 * 60, /* 15 days from now */
    getRandInt(), getRandInt(), productId, providedProductIds, null);
    JSONObject jobDetail = CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
    jobDetail = CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 5 * 1000, 1);
    String name = String.format("%s_%s-ActivationKey%s", sm_clientUsername, sm_clientOrg, System.currentTimeMillis());
    Map<String, String> mapActivationKeyRequest = new HashMap<String, String>();
    mapActivationKeyRequest.put("name", name);
    JSONObject jsonActivationKeyRequest = new JSONObject(mapActivationKeyRequest);
    JSONObject jsonActivationKey = new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + sm_clientOrg + "/activation_keys", jsonActivationKeyRequest.toString()));
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    for (SubscriptionPool availList : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (availList.subscriptionName.equals(Productname)) {
            poolId = availList.poolId;
        }
    }
    new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/activation_keys/" + jsonActivationKey.getString("id") + "/pools/" + poolId + (addQuantity == null ? "" : "?quantity=" + addQuantity), null));
    clienttasks.register(null, null, sm_clientOrg, null, null, null, null, null, null, null, name, null, null, null, true, false, null, null, null, null);
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    Assert.assertTrue(consumedProductSubscriptions.size() == 1 && consumedProductSubscriptions.get(0).poolId.equals(poolId), "Registering with an activationKey named '" + name + "' should grant a single entitlement from subscription pool id '" + poolId + "'.");
    new JSONObject(CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/activation_keys/" + name));
}
Also used : BigInteger(java.math.BigInteger) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 19 with ProductSubscription

use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.

the class BugzillaTests method testUnsubscribeAllForExpiredSubscription.

/**
 * @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-21974", "RHEL7-51836" }, 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 = "subscription-manager unsubscribe --all on expired subscriptions removes certs from entitlement folder", groups = { "Tier3Tests", "VerifyUnsubscribeAllForExpiredSubscription", "blockedByBug-852630", "blockedByBug-906550", "blockedByBug-1555582" }, enabled = true)
public void testUnsubscribeAllForExpiredSubscription() throws JSONException, Exception {
    clienttasks.clean();
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    String expiringPoolId = createTestPool(-60 * 24, 1, false);
    Calendar c1 = new GregorianCalendar();
    clienttasks.subscribe(null, null, expiringPoolId, null, null, null, null, null, null, null, null, null, null);
    Calendar c2 = new GregorianCalendar();
    // wait for the pool to expire
    // sleep(endingMinutesFromNow*60*1000);
    // trying to reduce the wait time for the expiration by subtracting off
    // some expensive test time
    sleep(1 * 60 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    List<ProductSubscription> activeProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.TRUE, consumedProductSubscriptions);
    Set<BigInteger> activeProductSubscriptionSerials = new HashSet<BigInteger>();
    for (ProductSubscription activeProductSubscription : activeProductSubscriptions) activeProductSubscriptionSerials.add(activeProductSubscription.serialNumber);
    List<ProductSubscription> expiredProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.FALSE, consumedProductSubscriptions);
    Assert.assertEquals(expiredProductSubscriptions.size(), 1, "Found one expired entitlement (indicated by Active:False) among the list of consumed subscriptions.");
    SSHCommandResult result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    String expected = String.format("%d subscriptions removed at the server.\n%d local certificates have been deleted.", activeProductSubscriptionSerials.size(), activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size());
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
        expected = String.format("%d local certificates have been deleted." + "\n" + "%d subscriptions removed at the server.", activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size(), activeProductSubscriptionSerials.size());
    }
    if (activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size() == 1)
        expected = expected.replace("local certificates have been", "local certificate has been");
    Assert.assertEquals(result.getStdout().trim(), expected);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 20 with ProductSubscription

use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.

the class BugzillaTests method testBindAndUnbindInSyslog.

/**
 * @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-21940", "RHEL7-51802" }, 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 that bind and unbind event is recorded in syslog", groups = { "Tier3Tests", "VerifyBindAndUnbindInSyslog", "blockedByBug-919700" }, enabled = true)
@ImplementsNitrateTest(caseId = 68740)
public void testBindAndUnbindInSyslog() throws JSONException, Exception {
    clienttasks.clean();
    // clienttasks.unregister(null, null, null, null);
    String logMarker, expectedSyslogMessage, tailFromSyslogFile;
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    logMarker = System.currentTimeMillis() + " Testing Subscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool pool : pools) poolIds.add(pool.poolId);
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (SubscriptionPool pool : pools) {
        expectedSyslogMessage = String.format("%s: Added subscription for '%s' contract '%s'", clienttasks.command, pool.subscriptionName, pool.contract.isEmpty() ? "None" : pool.contract);
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : pool.provides) {
            // https://bugzilla.redhat.com/show_bug.cgi?id=1016300
            if (providedProduct.equals("Awesome OS Server Bundled")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                String bugId = "1016300";
                try {
                    if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                        log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                        SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                    } else {
                        invokeWorkaroundWhileBugIsOpen = false;
                    }
                } catch (BugzillaAPIException be) {
                /* ignore exception */
                } catch (RuntimeException re) {
                /* ignore exception */
                }
                if (invokeWorkaroundWhileBugIsOpen) {
                    log.warning("Ignoring the provided MKT product '" + providedProduct + "'.  No syslog assertion for this product will be made.");
                    continue;
                }
            }
            // END OF WORKAROUND
            expectedSyslogMessage = String.format("%s: Added subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After subscribing to '" + pool.subscriptionName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
    logMarker = System.currentTimeMillis() + " Testing Unsubscribe **********************";
    RemoteFileTasks.markFile(client, clienttasks.messagesLogFile, logMarker);
    List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    tailFromSyslogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.messagesLogFile, logMarker, null);
    for (ProductSubscription productSubscription : productSubscriptions) {
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for 'Awesome OS Server Bundled (2 Sockets, Standard
        // Support)' contract '3'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Clustering Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Awesome OS Server Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Load Balancing Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Large File Support Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Shared Storage Bits'
        // Feb 3 13:32:34 jsefler-7 subscription-manager: Removed
        // subscription for product 'Management Bits'
        expectedSyslogMessage = String.format("%s: Removed subscription for '%s' contract '%s'", clienttasks.command, productSubscription.productName, // Note
        productSubscription.contractNumber == null ? "None" : productSubscription.contractNumber);
        // that
        // a
        // null/missing
        // contract
        // will
        // be
        // reported
        // as
        // None.
        // Seems
        // reasonable.
        Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        for (String providedProduct : productSubscription.provides) {
            expectedSyslogMessage = String.format("%s: Removed subscription for product '%s'", clienttasks.command, providedProduct);
            Assert.assertTrue(tailFromSyslogFile.contains(expectedSyslogMessage), "After unsubscribing from '" + productSubscription.productName + "', syslog '" + clienttasks.messagesLogFile + "' contains expected message '" + expectedSyslogMessage + "'.");
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ProductSubscription (rhsm.data.ProductSubscription)90 Test (org.testng.annotations.Test)82 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)72 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)56 SkipException (org.testng.SkipException)46 ArrayList (java.util.ArrayList)41 SubscriptionPool (rhsm.data.SubscriptionPool)38 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)31 JSONObject (org.json.JSONObject)31 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)23 HashMap (java.util.HashMap)22 BigInteger (java.math.BigInteger)20 EntitlementCert (rhsm.data.EntitlementCert)17 InstalledProduct (rhsm.data.InstalledProduct)16 Calendar (java.util.Calendar)15 JSONArray (org.json.JSONArray)13 File (java.io.File)10 GregorianCalendar (java.util.GregorianCalendar)10 HashSet (java.util.HashSet)6 ConsumerCert (rhsm.data.ConsumerCert)6