Search in sources :

Example 86 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 87 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class BugzillaTests method testServiceLevelWithOrgWithoutList.

/**
 * @author skallesh
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21926", "RHEL7-51787" }, 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: service-level --org (without --list option)", groups = { "Tier3Tests", "ServicelevelTest", "blockedByBug-826856" }, enabled = true)
public void testServiceLevelWithOrgWithoutList() {
    SSHCommandResult result;
    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);
    result = clienttasks.service_level_(null, false, null, null, sm_clientUsername, sm_clientPassword, "MyOrg", null, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
        // post
        // commit
        // a695ef2d1da882c5f851fde90a24f957b70a63ad
        Assert.assertEquals(result.getStderr().trim(), "Error: --org is only supported with the --list option", "stderr");
    } else {
        Assert.assertEquals(result.getStdout().trim(), "Error: --org is only supported with the --list option", "stdout");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 88 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 89 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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 90 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition 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)

Aggregations

TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)687 Test (org.testng.annotations.Test)687 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)401 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)366 SkipException (org.testng.SkipException)328 ArrayList (java.util.ArrayList)144 SubscriptionPool (rhsm.data.SubscriptionPool)137 JSONObject (org.json.JSONObject)95 BigInteger (java.math.BigInteger)90 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)88 HashMap (java.util.HashMap)78 File (java.io.File)74 ProductSubscription (rhsm.data.ProductSubscription)72 InstalledProduct (rhsm.data.InstalledProduct)66 EntitlementCert (rhsm.data.EntitlementCert)58 ProductCert (rhsm.data.ProductCert)54 YumRepo (rhsm.data.YumRepo)34 Repo (rhsm.data.Repo)26 Calendar (java.util.Calendar)25 List (java.util.List)24