Search in sources :

Example 11 with InstalledProduct

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

the class BugzillaTests method testRHELWorkstationSubscription.

/**
 * @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 }, testCaseID = { "RHEL6-26777" }, 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 = /*TODO */
"please provide a description", groups = { "Tier3Tests", "VerifyRHELWorkstationSubscription", "blockedByBug-739790" }, enabled = true)
public void testRHELWorkstationSubscription() throws JSONException, Exception {
    InstalledProduct workstation = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "71", clienttasks.getCurrentlyInstalledProducts());
    if (workstation == null)
        throw new SkipException("This test is only applicable on a RHEL Workstation where product 71 is installed.");
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, (String) null, null, null, true, false, null, null, null, null);
    /*
		 * too time consuming; replace with
		 * subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively(); for
		 * (SubscriptionPool availList : clienttasks
		 * .getCurrentlyAvailableSubscriptionPools()) {
		 * clienttasks.subscribe_(null, null, availList.poolId, null, null,
		 * null, null, null, null, null, null); }
		 */
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    boolean assertedWorkstationProduct = false;
    for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
        if (installed.productId.contains("Workstation")) {
            Assert.assertEquals(installed.status, "subscribed");
            assertedWorkstationProduct = true;
        }
    }
    if (!assertedWorkstationProduct)
        throw new SkipException("Installed product to be tested is not available");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 12 with InstalledProduct

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

the class BugzillaTests method testStackingFutureSubscriptionWithCurrentSubscription.

/**
 * @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-21927", "RHEL7-51788" }, 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 Stacking of a future subscription and present subsciption make the product compliant ", groups = { "Tier3Tests", "StackingFutureSubscriptionWithCurrentSubscription", "blockedByBug-966069" }, enabled = true)
public void testStackingFutureSubscriptionWithCurrentSubscription() throws 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);
    clienttasks.autoheal(null, null, true, null, null, null, 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);
    int sockets = 9;
    int core = 2;
    int ram = 10;
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
    factsMap.put("cpu.core(s)_per_socket", String.valueOf(core));
    factsMap.put("memory.memtotal", String.valueOf(GBToKBConverter(ram)));
    factsMap.put("virt.is_guest", String.valueOf(Boolean.FALSE));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    Boolean nosubscriptionsFound = true;
    Calendar now = new GregorianCalendar();
    DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
    now.add(Calendar.YEAR, 1);
    now.add(Calendar.DATE, 1);
    String onDateToTest = yyyy_MM_dd_DateFormat.format(now.getTime());
    List<String> providedProductId = new ArrayList<String>();
    List<SubscriptionPool> AvailableStackableSubscription = SubscriptionPool.findAllInstancesWithMatchingFieldFromList("subscriptionType", "Stackable", clienttasks.getAvailableSubscriptionsMatchingInstalledProducts());
    List<SubscriptionPool> futureStackableSubscription = SubscriptionPool.findAllInstancesWithMatchingFieldFromList("subscriptionType", "Stackable", clienttasks.getAvailableFutureSubscriptionsOndate(onDateToTest));
    List<SubscriptionPool> futureSubscription = FindSubscriptionsWithSuggestedQuantityGreaterThanTwo(futureStackableSubscription);
    List<SubscriptionPool> AvailableSubscriptions = FindSubscriptionsWithSuggestedQuantityGreaterThanTwo(AvailableStackableSubscription);
    for (SubscriptionPool AvailableSubscriptionPools : AvailableSubscriptions) {
        int quantity = AvailableSubscriptionPools.suggested;
        for (SubscriptionPool FutureSubscriptionPools : futureSubscription) {
            if ((AvailableSubscriptionPools.subscriptionName).equals(FutureSubscriptionPools.subscriptionName)) {
                providedProductId = AvailableSubscriptionPools.provides;
                clienttasks.subscribe(null, null, AvailableSubscriptionPools.poolId, null, null, Integer.toString(quantity - 1), null, null, null, null, null, null, null);
                nosubscriptionsFound = false;
                InstalledProduct AfterAttachingFutureSubscription = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", providedProductId.get(providedProductId.size() - 1), clienttasks.getCurrentlyInstalledProducts());
                Assert.assertEquals(AfterAttachingFutureSubscription.status, "Partially Subscribed", "Verified that installed product is partially subscribed before attaching a future subscription");
                clienttasks.subscribe(null, null, FutureSubscriptionPools.poolId, null, null, "1", null, null, null, null, null, null, null);
                break;
            }
        }
    }
    if (nosubscriptionsFound)
        throw new SkipException("no subscriptions found");
    InstalledProduct AfterAttaching = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", providedProductId.get(providedProductId.size() - 1), clienttasks.getCurrentlyInstalledProducts());
    Assert.assertEquals(AfterAttaching.status, "Partially Subscribed", "Verified that installed product is partially subscribed even after attaching a future subscription");
}
Also used : HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) InstalledProduct(rhsm.data.InstalledProduct) 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 13 with InstalledProduct

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

the class BugzillaTests method testStatusForPartialSubscription.

/**
 * @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-21972", "RHEL7-51834" }, 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 Subscription manager displays incorrect status for partially subscribed subscription", groups = { "Tier3Tests", "VerifyStatusForPartialSubscription", "blockedByBug-743710" }, enabled = true)
@ImplementsNitrateTest(caseId = 119327)
public void testStatusForPartialSubscription() throws JSONException, Exception {
    String Flag = "false";
    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);
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("virt.is_guest", String.valueOf(Boolean.FALSE));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    for (SubscriptionPool SubscriptionPool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (!CandlepinTasks.isPoolProductMultiEntitlement(sm_clientUsername, sm_clientPassword, sm_serverUrl, SubscriptionPool.poolId)) {
            String poolProductSocketsAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, SubscriptionPool.poolId, "sockets");
            if ((!(poolProductSocketsAttribute == null)) && (poolProductSocketsAttribute.equals("2"))) {
                clienttasks.subscribeToSubscriptionPool_(SubscriptionPool);
                Flag = "true";
            }
        }
    }
    Assert.assertTrue(Boolean.valueOf(Flag), "Found and subscribed to non-multi-entitlement 2 socket subscription pool(s) for this test.");
    Integer moreSockets = 4;
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(moreSockets + Integer.valueOf(clienttasks.sockets)));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    Flag = "false";
    for (InstalledProduct product : clienttasks.getCurrentlyInstalledProducts()) {
        if (!product.status.equals("Not Subscribed") && !product.status.equals("Subscribed") && !product.status.equals("Unknown")) {
            Assert.assertEquals(product.status, "Partially Subscribed", "Installed product '" + product.productName + "' status is Partially Subscribed.");
            Flag = "true";
        }
    }
    Assert.assertEquals(Flag, "true", "Verified Partially Subscribed installed product(s).");
}
Also used : BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) 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)

Example 14 with InstalledProduct

use of rhsm.data.InstalledProduct 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 15 with InstalledProduct

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

the class BugzillaTests method testSystemCompliantFactWhenAllProductsAreExpired.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@Test(description = "verify that system should not be compliant for an expired subscription", groups = { "Tier3Tests", "VerifySystemCompliantFact" }, enabled = false)
public void testSystemCompliantFactWhenAllProductsAreExpired() throws JSONException, Exception {
    List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
    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);
    File expectCertFile = new File(System.getProperty("automation.dir", null) + "/certs/Expiredcert.pem");
    RemoteFileTasks.putFile(client, expectCertFile.toString(), "/root/", "0755");
    clienttasks.importCertificate_("/root/Expiredcert.pem");
    for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
        if ((installed.status.equals("Expired"))) {
            ProductCert productCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", installed.productId, productCerts);
            configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(productCert));
        }
    }
    clienttasks.facts(null, true, null, null, null, null);
    List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    Assert.assertEquals(currentlyInstalledProducts.size(), 1, "Expecting one installed product provided by the expired entitlement just imported.");
    String actual = clienttasks.getFactValue(factname).trim();
    Assert.assertEquals(actual, "invalid", "Value of system fact '" + factname + "'.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) File(java.io.File) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

InstalledProduct (rhsm.data.InstalledProduct)77 Test (org.testng.annotations.Test)71 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)66 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)33 SkipException (org.testng.SkipException)27 SubscriptionPool (rhsm.data.SubscriptionPool)25 ArrayList (java.util.ArrayList)22 ProductCert (rhsm.data.ProductCert)21 ProductSubscription (rhsm.data.ProductSubscription)16 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)15 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)14 HashMap (java.util.HashMap)13 BigInteger (java.math.BigInteger)12 JSONObject (org.json.JSONObject)10 File (java.io.File)9 Calendar (java.util.Calendar)7 HashSet (java.util.HashSet)7 EntitlementCert (rhsm.data.EntitlementCert)6 GregorianCalendar (java.util.GregorianCalendar)5 JSONArray (org.json.JSONArray)5