Search in sources :

Example 51 with InstalledProduct

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

the class BugzillaTests method testInstalledProductMultipliesAfterSubscription.

/**
 * @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-20114", "RHEL7-55206" }, 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 = "Tier1")
@Test(description = "Verify the fix for Bug 709412 - subscription manager cli uses product name comparisons in the list command", groups = { "Tier1Tests", "InstalledProductMultipliesAfterSubscription", "blockedByBug-709412" }, enabled = true)
public void testInstalledProductMultipliesAfterSubscription() throws Exception {
    if (!(sm_serverType.equals(CandlepinType.hosted)))
        throw new SkipException("To be run against Stage only");
    String serverUrl = getServerUrl(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "hostname"), clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "port"), clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "prefix"));
    clienttasks.register(sm_clientUsername, sm_clientPassword, null, null, null, null, null, null, null, null, (String) null, serverUrl, null, null, true, null, null, null, null, null);
    productCertDirBeforeInstalledProductMultipliesAfterSubscription = clienttasks.productCertDir;
    clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", "/usr/share/rhsm/product/RHEL-" + clienttasks.redhatReleaseX);
    List<InstalledProduct> InstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    List<InstalledProduct> InstalledProductsAfterSubscribing = clienttasks.getCurrentlyInstalledProducts();
    Assert.assertEquals(InstalledProducts.size(), InstalledProductsAfterSubscribing.size(), "The number installed products listed by subscription manager should remained unchanged after attaching all available subscriptions.");
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
}
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 52 with InstalledProduct

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

the class BugzillaTests method testAutosubscribe.

/**
 * @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-21977", "RHEL7-51839" }, 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 the status of installed products match when autosubscribed,and when you subscribe all the available products", groups = { "Tier3Tests", "VerifyautosubscribeTest" }, enabled = true)
public void testAutosubscribe() throws JSONException, Exception {
    List<String> ProductIdBeforeAuto = new ArrayList<String>();
    List<String> ProductIdAfterAuto = new ArrayList<String>();
    clienttasks.deleteFactsFileWithOverridingValues();
    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.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    for (InstalledProduct installedProductsBeforeAuto : clienttasks.getCurrentlyInstalledProducts()) {
        if (installedProductsBeforeAuto.status.equals("Subscribed"))
            ProductIdBeforeAuto.add(installedProductsBeforeAuto.productId);
    }
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    clienttasks.subscribe_(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
    for (InstalledProduct installedProductsAfterAuto : clienttasks.getCurrentlyInstalledProducts()) {
        if (installedProductsAfterAuto.status.equals("Subscribed"))
            ProductIdAfterAuto.add(installedProductsAfterAuto.productId);
    }
    Assert.assertEquals(ProductIdBeforeAuto.size(), ProductIdAfterAuto.size());
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 53 with InstalledProduct

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

the class BugzillaTests method testAutosubscribeIgnoresSocketCount.

/**
 * @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-21976", "RHEL7-51838" }, 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 autosubscribe ignores socket count on non multi-entitled subscriptions", groups = { "Tier3Tests", "VerifyautosubscribeIgnoresSocketCount_Test", "blockedByBug-743704" }, enabled = true)
public void testAutosubscribeIgnoresSocketCount() throws Exception {
    // InstalledProduct installedProduct =
    // InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId",
    // "1000000000000023", clienttasks.getCurrentlyInstalledProducts());
    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("cpu.cpu_socket(s)", String.valueOf(4));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
    Boolean Flag = false;
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(1));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
    InstalledProduct installedProductsAfterAuto = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "1000000000000023", clienttasks.getCurrentlyInstalledProducts());
    if (installedProductsAfterAuto.status.equals("Subscribed")) {
        Flag = true;
        Assert.assertTrue(Flag, "Auto-attach doesnot ignore socket count");
    }
}
Also used : HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 54 with InstalledProduct

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

the class BugzillaTests method testEUSRHELProductCertVersionFromEachCDNReleaseVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47933", "RHEL7-63527" }, 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 = "Tier1")
@Test(description = "Verify that the EUS RHEL product certs on the CDN for each release correctly reflect the release version.  For example, this affects users that want use subcription-manager release --set=6.3 to keep yum updates fixed to an older release.", groups = { "Tier1Tests", "VerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_Test" }, dataProvider = "VerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_TestData", enabled = true)
public void testEUSRHELProductCertVersionFromEachCDNReleaseVersion(Object blockedByBug, String release, String rhelRepoUrl, File eusEntitlementCertFile) throws JSONException, Exception {
    if (!(sm_serverType.equals(CandlepinType.hosted)))
        throw new SkipException("To be run against Stage only");
    String rhelProductId = null;
    if ((clienttasks.arch.equals("ppc64")) && (clienttasks.variant.equals("Server")))
        rhelProductId = "74";
    else if ((clienttasks.arch.equals("x86_64")) && (clienttasks.variant.equals("Server")))
        rhelProductId = "69";
    else if ((clienttasks.arch.equals("s390x")) && (clienttasks.variant.equals("Server")))
        rhelProductId = "72";
    else if ((clienttasks.arch.equals("x86_64")) && (clienttasks.variant.equals("ComputeNode")))
        rhelProductId = "76";
    else if (clienttasks.variant.equals("Client"))
        throw new SkipException("Test is not supported for this variant");
    else if (clienttasks.variant.equals("Workstation"))
        throw new SkipException("Test is not supported for this variant");
    File certFile = eusEntitlementCertFile;
    File keyFile = clienttasks.getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(eusEntitlementCertFile);
    // Assert that installed product list features a rhelproduct cert in it
    List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
    InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
    Assert.assertNotNull(rhelInstalledProduct, "Expecting the installed RHEL Server product '" + rhelProductId + "' to be installed.");
    // different arch
    String basearch = clienttasks.arch;
    if (basearch.equals("i686") || basearch.equals("i586") || basearch.equals("i486"))
        basearch = "i386";
    // set the release and baseurl
    String rhelRepoUrlToProductId = rhelRepoUrl.replace("$releasever", release).replace("$basearch", basearch) + "/repodata/productid";
    // using the entitlement certificates to get the productid
    File localProductIdFile = new File("/tmp/productid");
    // curl --stderr /dev/null --insecure --tlsv1 --cert /etc/pki/entitlement/3708865569463790383.pem --key /etc/pki/entitlement/3708865569463790383-key.pem https://cdn.redhat.com/content/eus/rhel/server/6/6.1/x86_64/os/repodata/productid  | tee /tmp/productid
    SSHCommandResult result = RemoteFileTasks.runCommandAndAssert(client, "curl --stderr /dev/null --insecure --tlsv1 --cert " + certFile + " --key " + keyFile + " " + rhelRepoUrlToProductId + " | tee " + localProductIdFile, Integer.valueOf(0));
    String fileNotFound = "File not found.";
    // releases with no EUS support...
    if (release.equals("6.8") || release.equals("6.9") || release.equals("6.10")) {
        log.warning("There is no EUS support scheduled for RHEL '" + release + "'.  See https://pp.engineering.redhat.com/pp/product/rhel/release/rhel-6-9/schedule/overview");
        Assert.assertTrue(result.getStdout().contains(fileNotFound), "Expected attempt to fetch the EUS productid results in '" + fileNotFound + "'");
        throw new SkipException("There is no EUS support for RHEL '" + release + "'.");
    }
    if (result.getStdout().contains(fileNotFound))
        Assert.fail("Failed to find a productid file on the CDN at '" + rhelRepoUrlToProductId + "'.  It is possible that RHEL release '" + release + "' has no EUS support; check the Product Pages for RHEL https://pp.engineering.redhat.com/pp/product/rhel/ to see if EUS is on the Schedule.");
    // create a ProductCert corresponding to the productid file
    ProductCert productIdCert = clienttasks.getProductCertFromProductCertFile(localProductIdFile);
    log.info("Actual product cert from CDN '" + rhelRepoUrlToProductId + "': " + productIdCert);
    // assert the expected productIdCert release version
    Assert.assertEquals(productIdCert.productNamespace.version, release, "Version of the productid on the CDN at '" + rhelRepoUrlToProductId + "' that will be installed by the yum product-id plugin after setting the subscription-manager release to '" + release + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 55 with InstalledProduct

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

the class BugzillaTests method testAddingFutureSubscriptionToActivationKey.

/**
 * @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-21898", "RHEL7-51759" }, 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 Future subscription added to the activation key ", groups = { "Tier3Tests", "AddingFutureSubscriptionToActivationKey", "blockedByBug-1440180" }, enabled = true)
public void testAddingFutureSubscriptionToActivationKey() throws Exception {
    Integer addQuantity = 1;
    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();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    clienttasks.autoheal(null, null, true, null, null, null, null);
    String futurePool = createTestPool(60 * 24 * 365, 60 * 24 * (365 * 2), true);
    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()));
    new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/activation_keys/" + jsonActivationKey.getString("id") + "/pools/" + futurePool + (addQuantity == null ? "" : "?quantity=" + addQuantity), null));
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(null, null, sm_clientOrg, null, null, null, null, null, null, null, name, null, null, null, true, null, null, null, null, null);
    clienttasks.autoheal(null, null, true, null, null, null, null);
    clienttasks.listConsumedProductSubscriptions();
    InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "37060", clienttasks.getCurrentlyInstalledProducts());
    Assert.assertEquals(installedProduct.status, "Future Subscription");
}
Also used : BigInteger(java.math.BigInteger) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) 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