Search in sources :

Example 26 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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 27 with SubscriptionPool

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

the class BugzillaTests method testOwnerInfoForActivePools.

/**
 * @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-21917", "RHEL7-51778" }, 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 OwnerInfo is displayed only for pools that are active right now, for all the stats", groups = { "Tier3Tests", "OwnerInfoForActivePools", "blockedByBug-710141" }, enabled = true)
public void testOwnerInfoForActivePools() throws JSONException, Exception {
    DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, (String) null, null, null, true, null, null, null, null, null);
    Calendar now = new GregorianCalendar();
    Calendar futureCalendar = new GregorianCalendar();
    futureCalendar.set(Calendar.HOUR_OF_DAY, 0);
    futureCalendar.set(Calendar.MINUTE, 0);
    // avoid times in the middle of
    futureCalendar.set(Calendar.SECOND, 0);
    // the day
    futureCalendar.add(Calendar.YEAR, 1);
    String futurceDate = yyyy_MM_dd_DateFormat.format(futureCalendar.getTime());
    List<SubscriptionPool> availOnDate = getAvailableFutureSubscriptionsOndate(futurceDate);
    if (availOnDate.size() == 0)
        throw new SkipException("Sufficient future pools are not available");
    JSONArray jsonPools = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/owners/" + sm_clientOrg + "/pools"));
    Assert.assertTrue(jsonPools.length() > 0, "Successfully got a positive number of /owners/" + sm_clientOrg + "/pools");
    for (int i = 0; i < jsonPools.length(); i++) {
        JSONObject jsonPool = (JSONObject) jsonPools.get(i);
        String subscriptionName = jsonPool.getString("productName");
        String startDate = jsonPool.getString("startDate");
        String endDate = jsonPool.getString("endDate");
        // "startDate":"2014-01-06T00:00:00.000+0000"
        Calendar startCalendar = parseISO8601DateString(startDate, "GMT");
        // "endDate":"2015-01-06T00:00:00.000+0000"
        Calendar endCalendar = parseISO8601DateString(endDate, "GMT");
        Assert.assertTrue(startCalendar.before(now), "Available pool '" + subscriptionName + "' startsDate='" + startDate + "' starts before now.");
        Assert.assertTrue(endCalendar.after(now), "Available pool '" + subscriptionName + "' endDate='" + endDate + "' ends after now.");
    }
    jsonPools = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/owners/" + sm_clientOrg + "/pools?activeon=" + futurceDate));
    Assert.assertTrue(jsonPools.length() > 0, "Successfully got a positive number of /owners/" + sm_clientOrg + "/pools?activeon=" + futurceDate);
    for (int i = 0; i < jsonPools.length(); i++) {
        JSONObject jsonPool = (JSONObject) jsonPools.get(i);
        String subscriptionName = jsonPool.getString("productName");
        String startDate = jsonPool.getString("startDate");
        String endDate = jsonPool.getString("endDate");
        // "startDate":"2014-01-06T00:00:00.000+0000"
        Calendar startCalendar = parseISO8601DateString(startDate, "GMT");
        // "endDate":"2015-01-06T00:00:00.000+0000"
        Calendar endCalendar = parseISO8601DateString(endDate, "GMT");
        Assert.assertTrue(startCalendar.before(futureCalendar), "Future available pool '" + subscriptionName + "' startsDate='" + startDate + "' starts before " + futurceDate + ".");
        Assert.assertTrue(endCalendar.equals(futureCalendar) || endCalendar.after(futureCalendar), "Future available pool '" + subscriptionName + "' endDate='" + endDate + "' ends on or after " + futurceDate + ".");
    }
}
Also used : JSONObject(org.json.JSONObject) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) JSONArray(org.json.JSONArray) SkipException(org.testng.SkipException) SimpleDateFormat(java.text.SimpleDateFormat) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 28 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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 29 with SubscriptionPool

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

the class BugzillaTests method testDeletionOfSubscribedProduct_Test.

/**
 * @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-21943", "RHEL7-51805" }, 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 Product with UUID '%s' cannot be deleted while subscriptions exist.", groups = { "Tier3Tests", "DeleteProductTest", "blockedByBug-684941" }, enabled = true)
public void testDeletionOfSubscribedProduct_Test() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    clienttasks.subscribe_(true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    if (clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty()) {
        throw new SkipException("no installed products are installed");
    } else {
        for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
            if (installed.status.equals("Subscribed")) {
                for (SubscriptionPool AvailSub : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
                    if (installed.productName.contains(AvailSub.subscriptionName)) {
                        String resourcePath = "/products/" + AvailSub.productId;
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
                            resourcePath = "/owners/" + sm_clientOrg + resourcePath;
                        JSONObject jsonConsumer = new JSONObject(CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath));
                        String expectedDisplayMessage = "Product with UUID '" + AvailSub.productId + "' cannot be deleted while subscriptions exist.";
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
                            expectedDisplayMessage = "Product with ID '" + AvailSub.productId + "' cannot be deleted while subscriptions exist.";
                        if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
                            // commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
                            expectedDisplayMessage = String.format("Product with ID \"%s\" cannot be deleted while subscriptions exist.", AvailSub.productId);
                        }
                        Assert.assertEquals(jsonConsumer.getString("displayMessage"), expectedDisplayMessage);
                    }
                }
            }
        }
    }
}
Also used : JSONObject(org.json.JSONObject) InstalledProduct(rhsm.data.InstalledProduct) 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 30 with SubscriptionPool

use of rhsm.data.SubscriptionPool 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

SubscriptionPool (rhsm.data.SubscriptionPool)195 Test (org.testng.annotations.Test)155 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)137 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)112 SkipException (org.testng.SkipException)90 ArrayList (java.util.ArrayList)87 JSONObject (org.json.JSONObject)66 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)53 ProductSubscription (rhsm.data.ProductSubscription)38 BigInteger (java.math.BigInteger)37 File (java.io.File)34 List (java.util.List)33 EntitlementCert (rhsm.data.EntitlementCert)33 HashMap (java.util.HashMap)32 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)28 InstalledProduct (rhsm.data.InstalledProduct)25 ProductCert (rhsm.data.ProductCert)24 JSONArray (org.json.JSONArray)22 Calendar (java.util.Calendar)12 GregorianCalendar (java.util.GregorianCalendar)11