Search in sources :

Example 36 with SubscriptionPool

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

the class BugzillaTests method listFutureSubscription_OnDate.

protected List<String> listFutureSubscription_OnDate(Boolean available, String ondate) {
    List<String> PoolId = new ArrayList<String>();
    SSHCommandResult result = clienttasks.list_(true, true, null, null, null, ondate, null, null, null, null, null, null, null, null);
    List<SubscriptionPool> Pool = SubscriptionPool.parse(result.getStdout());
    for (SubscriptionPool availablePool : Pool) {
        if (availablePool.multiEntitlement) {
            PoolId.add(availablePool.poolId);
        }
    }
    return PoolId;
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool)

Example 37 with SubscriptionPool

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

the class BugzillaTests method testEntitlementStartDate.

/**
 * @author skallesh
 * @throws Exception
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21946", "RHEL7-51808" }, 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 Entitlement Start Dates is the Subscription Start Date", groups = { "Tier3Tests", "VerifyEntitlementStartDate_Test", "blockedByBug-670831" }, enabled = true)
public void testEntitlementStartDate() throws JSONException, Exception {
    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);
    for (SubscriptionPool pool : getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 5)) {
        JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/pools/" + pool.poolId));
        Calendar subStartDate = parseISO8601DateString(jsonPool.getString("startDate"), "GMT");
        EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(clienttasks.subscribeToSubscriptionPool_(pool));
        Calendar entStartDate = entitlementCert.validityNotBefore;
        Assert.assertTrue(entStartDate.compareTo(subStartDate) == 0, "" + "The entitlement start date granted from pool '" + pool.poolId + "' (" + pool.productId + ") in '" + entitlementCert.file + "', '" + OrderNamespace.formatDateString(entStartDate) + "', " + "should match json start date '" + jsonPool.getString("startDate") + "' of the subscription pool it came from.");
    }
}
Also used : JSONObject(org.json.JSONObject) EntitlementCert(rhsm.data.EntitlementCert) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 38 with SubscriptionPool

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

the class BugzillaTests method testAutohealForPartialSubscription.

/**
 * @author skallesh
 * @throws JSONException
 * @throws Exception
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21936", "RHEL7-51798" }, 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 = "Auto-heal for partial subscription", groups = { "Tier3Tests", "autohealPartial", "blockedByBug-746218", "blockedByBug-907638", "blockedByBug-907400" }, enabled = true)
public void testAutohealForPartialSubscription() throws Exception {
    Integer moreSockets = 0;
    List<String> productIds = new ArrayList<String>();
    List<String> poolId = new ArrayList<String>();
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("virt.is_guest", Boolean.FALSE.toString());
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    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);
    // disable
    clienttasks.autoheal(null, null, true, null, null, null, null);
    // autoheal
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        if (CandlepinTasks.isPoolProductMultiEntitlement(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
            String poolProductSocketsAttribute = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "stacking_id");
            if ((!(poolProductSocketsAttribute == null)) && (poolProductSocketsAttribute.equals("1"))) {
                String SocketsCount = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "sockets");
                poolId.add(pool.poolId);
                moreSockets += Integer.valueOf(SocketsCount);
                productIds.addAll(CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId));
            }
        }
    }
    if (moreSockets == 0)
        throw new SkipException("Expected to find a sockets based multi-entitlement pool with stacking_id 1 for this test.");
    factsMap.put("cpu.cpu_socket(s)", String.valueOf((++moreSockets) + Integer.valueOf(clienttasks.sockets)));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    for (InstalledProduct installedProduct : clienttasks.getCurrentlyInstalledProducts()) {
        if (productIds.contains(installedProduct.productId)) {
            Assert.assertEquals(installedProduct.status, "Partially Subscribed");
        }
    }
    Assert.assertTrue(!productIds.isEmpty(), "Found installed products that are partially subscribed after adding " + moreSockets + " more cpu.cpu_socket(s).");
    // enable
    clienttasks.autoheal(null, true, null, null, null, null, null);
    // autoheal
    // trigger autoheal
    clienttasks.run_rhsmcertd_worker(true);
    for (InstalledProduct installedProduct : clienttasks.getCurrentlyInstalledProducts()) {
        for (String productId : productIds) {
            if (productId.equals(installedProduct.productId))
                Assert.assertEquals(installedProduct.status, "Subscribed", "Status of installed product '" + installedProduct.productName + "' after auto-healing.");
        }
    }
}
Also used : BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) 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 39 with SubscriptionPool

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

the class BugzillaTests method getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists.

protected List<List<Object>> getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    if (sm_clientUsername == null)
        return ll;
    if (sm_clientPassword == null)
        return ll;
    // get the currently installed product certs to be used when checking
    // for conditional content tagging
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    // assure we are freshly registered and process all available
    // subscription pools
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
        Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
        EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (!contentNamespace.type.equalsIgnoreCase("yum"))
                continue;
            if (contentNamespace.enabled && clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
                String repoLabel = contentNamespace.label;
                // find an available package that is uniquely provided by
                // repo
                String pkg = clienttasks.findUniqueAvailablePackageFromRepo(repoLabel);
                if (pkg == null) {
                    log.warning("Could NOT find a unique available package from repo '" + repoLabel + "' after subscribing to SubscriptionPool: " + pool);
                }
                ll.add(Arrays.asList(new Object[] { pkg, repoLabel, pool }));
            }
        }
        clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
        // testcase development)
        if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
            break;
    }
    return ll;
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File)

Example 40 with SubscriptionPool

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

the class BugzillaTests method testSubscribingToBogusPoolID.

/**
 * @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-21973", "RHEL7-51835" }, 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 = "Tier3")
@Test(description = "verify if entitlement certs are downloaded if subscribed using bogus poolid", groups = { "Tier3Tests", "VerifySubscribingTobogusPoolID" }, enabled = true)
@ImplementsNitrateTest(caseId = 50223)
public void testSubscribingToBogusPoolID() throws JSONException, Exception {
    String poolId = 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);
    List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
    listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
    clienttasks.config(null, null, true, listOfSectionNameValues);
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    for (SubscriptionPool availList : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        poolId = availList.poolId;
    }
    String pool = randomizeCaseOfCharactersInString(poolId);
    clienttasks.subscribe_(null, null, pool, null, null, null, null, null, null, null, null, null, null);
    List<File> Cert = clienttasks.getCurrentEntitlementCertFiles();
    Assert.assertEquals(Cert.size(), 0);
}
Also used : ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) 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