Search in sources :

Example 81 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ListTests method EnsureOnlyRHELPersonalIsAvailableToRegisteredPerson_Test.

@Test(description = "subscription-manager-cli: RHEL Personal should be the only available subscription to a consumer registered as type person", groups = { "Tier2Tests", "EnsureOnlyRHELPersonalIsAvailableToRegisteredPerson_Test" }, // registered consumers type of "person" was originally intended for entitling people to training.  Red Hat Learning Management systems never made use if it, and candlepin has no active requirements for it.  Disabling the personal tests...  Reference https://bugzilla.redhat.com/show_bug.cgi?id=967160#c1
enabled = false)
public // @ImplementsNitrateTest(caseId=)
void EnsureOnlyRHELPersonalIsAvailableToRegisteredPerson_Test() throws JSONException {
    // String rhelPersonalProductId = getProperty("sm.rhpersonal.productId", "");
    // if (rhelPersonalProductId.equals("")) throw new SkipException("This testcase requires specification of a RHPERSONAL_PRODUCTID.");
    // decide what username and password to test with
    String username = sm_clientUsername;
    String password = sm_clientPassword;
    String owner = sm_clientOrg;
    if (!sm_rhpersonalUsername.equals("")) {
        username = sm_rhpersonalUsername;
        password = sm_rhpersonalPassword;
        owner = sm_rhpersonalOrg;
    }
    // register a person
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(username, password, owner, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // assert that subscriptions with personal productIds are available to this person consumer
    List<SubscriptionPool> subscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    for (String personProductId : getPersonProductIds()) {
        SubscriptionPool rhelPersonalPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId, subscriptionPools);
        Assert.assertNotNull(rhelPersonalPool, "Personal ProductId '" + personProductId + "' is available to this consumer registered as type person");
    }
    // assert that personal subscriptions are the only available pools to this person consumer
    for (SubscriptionPool subscriptionPool : subscriptionPools) {
        Assert.assertTrue(getPersonProductIds().contains(subscriptionPool.productId), "This available ProductId '" + subscriptionPool.productId + "' available to the registered person is among the expected list of personal products that we expect to be consumable by this person.");
    }
}
Also used : SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 82 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ListTests method testInstalledProductsListed.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37700", "RHEL7-51326" }, 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: list installed products", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testInstalledProductsListed() {
    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);
    List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
    Set<String> productCertIds = clienttasks.getCurrentProductIds();
    String installedProductsAsString = clienttasks.listInstalledProducts().getStdout();
    // List <InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    List<InstalledProduct> installedProducts = InstalledProduct.parse(installedProductsAsString);
    // assert some stdout
    if (installedProducts.size() > 0) {
        String bannerTitle = "Installed Product Status";
        Assert.assertTrue(installedProductsAsString.contains(bannerTitle), "The list of installed products is entitled '" + bannerTitle + "'.");
    }
    // assert the number of installed product matches the unique product certs Ids installed
    Assert.assertEquals(installedProducts.size(), productCertIds.size(), "A single product is reported as installed for each unique product cert ID found in " + clienttasks.productCertDir + " and " + clienttasks.productCertDefaultDir);
    // assert that each of the installed ProductCerts are listed as InstalledProducts with status "Not Subscribed"
    for (ProductCert productCert : productCerts) {
        InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToProductCert(productCert, installedProducts);
        Assert.assertNotNull(installedProduct, "The following installed product cert is included by subscription-manager in the list --installed: " + (installedProduct == null ? "null" : installedProduct));
        Assert.assertEquals(installedProduct.status, "Not Subscribed", "The status of installed product when newly registered: " + installedProduct);
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 83 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ListTests method testListAvailableWithPoolOnly.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36562", "RHEL7-51344" }, 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: subcription manager list --available with --pool-only", groups = { "Tier2Tests", "blockedByBug-1159974" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithPoolOnly() throws JSONException, Exception {
    // commit 25cb581cb6ebe13063d0f78a5020715a2854d337 bug 1159974
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.8-1"))
        throw new SkipException("The list --pool-only function was not implemented in this version of subscription-manager.");
    Boolean all = getRandomBoolean();
    Boolean matchInstalled = getRandomBoolean();
    Boolean noOverlap = getRandomBoolean();
    if (clienttasks.getCurrentlyRegisteredOwnerKey() == null) {
        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);
        clienttasks.autoheal(null, null, true, null, null, null, null);
    } else
        clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    // get available subscription pools
    List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, null, null, null, null, null, null).getStdout());
    // make the same call with --pool-only
    SSHCommandResult poolOnlyResult = clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, null, true, null, null, null, null);
    // [root@jsefler-os7 ~]# subscription-manager list --available --pool-only
    // 2c90af8b4976c7ee014976cb29bf0b02
    // 2c90af8b4976c7ee014976cb388c1256
    // 2c90af8b4976c7ee01497bbfec1837da
    // 2c90af8b4976c7ee014976cb1f0d06f8
    // convert the result to a list
    List<String> actualSubscriptionPoolIds = new ArrayList<String>();
    if (!poolOnlyResult.getStdout().trim().isEmpty())
        actualSubscriptionPoolIds = Arrays.asList(poolOnlyResult.getStdout().trim().split("\n"));
    // assert the result
    Assert.assertEquals(poolOnlyResult.getExitCode(), new Integer(0), "Exitcode expected from calling list --available --pool-only");
    for (SubscriptionPool availableSubscriptionPool : availableSubscriptionPools) Assert.assertTrue(actualSubscriptionPoolIds.contains(availableSubscriptionPool.poolId), "The result of list --available with --pool-only contains expected poolId '" + availableSubscriptionPool.poolId + "'.");
    Assert.assertEquals(actualSubscriptionPoolIds.size(), availableSubscriptionPools.size(), "The number of poolIds returned from calling list --pool-only should match the number of available SubscriptionPools listed without --pool-only.");
}
Also used : BigInteger(java.math.BigInteger) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) 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 84 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ListTests method testListAvailableReportsContract.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36550", "RHEL7-51327" }, 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: list of available subscriptions should include contract number", groups = { "Tier2Tests", "blockedByBug-1007580", "blockedByBug-1088507" }, enabled = true)
public // @ImplementsNitrateTest(caseId=, fromPlan=)
void testListAvailableReportsContract() {
    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);
    // assert the contract value in all available pools
    boolean availableSubscriptionPoolsDisplayContract = false;
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        String none = "None";
        if (pool.contract != null) {
            Assert.assertTrue(!pool.contract.equalsIgnoreCase(none), "The contract '" + pool.contract + "' for subscription pool '" + pool.poolId + "' should not be reported as '" + none + "'.");
            availableSubscriptionPoolsDisplayContract = true;
        }
    }
    Assert.assertTrue(availableSubscriptionPoolsDisplayContract, "Successfully encountered contracts reported in the list of available subscription pools.");
}
Also used : SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 85 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ListTests method testRemoveSubscriptionContainingUTF8Character.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37706", "RHEL7-51354" }, 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: subcription manager remove a consumed subscription containing UTF-8 character(s)", groups = { "Tier2Tests", "SubscriptionContainingUTF8CharacterTests", "blockedByBug-889204" }, dependsOnMethods = { "testCatCertContainingUTF8Character" }, priority = 140, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRemoveSubscriptionContainingUTF8Character() {
    // SURPRISED THAT THIS DID NOT WORK List AND THE FOLLOWING DOES <ProductSubscription> consumedProductSubscriptions = ProductSubscription.parse(clienttasks.runCommandWithLang(null, clienttasks.command+" list --consumed").getStdout());
    List<ProductSubscription> consumedProductSubscriptions = ProductSubscription.parse(client.runCommandAndWait(clienttasks.command + " list --consumed").getStdout());
    ProductSubscription consumedProductSubscription = ProductSubscription.findFirstInstanceWithCaseInsensitiveMatchingFieldFromList("productId", productIdForSubscriptionContainingUTF8Character, consumedProductSubscriptions);
    Assert.assertNotNull(consumedProductSubscription, "Found subscription product '" + productIdForSubscriptionContainingUTF8Character + "' from the list of consumed subscriptions whose name contains a UTF8 character.");
    Assert.assertEquals(consumedProductSubscription.productName, subscriptionNameForSubscriptionContainingUTF8Character, "asserting the consumed subscription name.");
    clienttasks.unsubscribeFromSerialNumber(consumedProductSubscription.serialNumber);
}
Also used : ProductSubscription(rhsm.data.ProductSubscription) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)267 Test (org.testng.annotations.Test)267 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)244 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)146 SkipException (org.testng.SkipException)125 SubscriptionPool (rhsm.data.SubscriptionPool)71 ArrayList (java.util.ArrayList)62 BigInteger (java.math.BigInteger)53 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)42 ProductSubscription (rhsm.data.ProductSubscription)42 File (java.io.File)36 JSONObject (org.json.JSONObject)33 EntitlementCert (rhsm.data.EntitlementCert)32 ProductCert (rhsm.data.ProductCert)32 InstalledProduct (rhsm.data.InstalledProduct)15 ConsumerCert (rhsm.data.ConsumerCert)14 HashMap (java.util.HashMap)11 Calendar (java.util.Calendar)10 List (java.util.List)10 JSONArray (org.json.JSONArray)8