Search in sources :

Example 61 with ProductCert

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

the class ComplianceTests method testSystemCompliantFactWhenAllProductsAreSubscribableInTheFuture.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21725", "RHEL7-33103" }, 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 = "subscription-manager: verify the system.compliant fact remains False when all installed products are subscribable in the future", groups = { "Tier1Tests", "configureProductCertDirForAllProductsSubscribableInTheFuture", "cli.tests", "blockedbyBug-737553", "blockedbyBug-649068", "blockedbyBug-1183175", "blockedbyBug-1440180" }, priority = 800, enabled = true)
public // @ImplementsTCMS(id="")
void testSystemCompliantFactWhenAllProductsAreSubscribableInTheFuture() throws JSONException, Exception {
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
    // to avoid unmapped_guests_only pools
    if (Boolean.valueOf(clienttasks.getFactValue("virt.is_guest")))
        clienttasks.mapSystemAsAGuestOfItself();
    // initial assertions
    Assert.assertFalse(clienttasks.getCurrentlyInstalledProducts().isEmpty(), "Products are currently installed for which the compliance of ALL are covered by future available subscription pools.");
    Assert.assertEquals(clienttasks.getFactValue(factNameForSystemCompliance), factValueForSystemNonCompliance, "Before attempting to subscribe to any future subscription, the system should be non-compliant (see value for fact '" + factNameForSystemCompliance + "').");
    // incrementally subscribe to each future subscription pool and assert the corresponding installed product's status
    Set<String> productIdsProvidedByFutureSubscriptionsThatFailedToAttach = new HashSet<String>();
    for (SubscriptionPool futureSystemSubscriptionPool : futureSystemSubscriptionPools) {
        // subscribe without asserting results (not necessary)
        File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(futureSystemSubscriptionPool);
        // WARNING: Pool is restricted to unmapped virtual guests: '2c90af964cba07a6014cba0b1ab80e24'
        if (entitlementCertFile == null) {
            log.warning("Encountered a problem trying to attach future subscription '" + futureSystemSubscriptionPool.subscriptionName + "'.  Look for two preceeding WARNING messages.  Skipping assertion of installed product status.");
            // FIXME need to account for this problem in the assertions that follow this block especially if this failed futureSystemSubscriptionPool is the only one that provides one of the installed products.
            // 8/26/2015 ATTEMPTING TO FIXME WITH productIdsProvidedByFutureSubscriptionsThatFailedToAttach
            productIdsProvidedByFutureSubscriptionsThatFailedToAttach.addAll(CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, futureSystemSubscriptionPool.poolId));
            continue;
        }
        // assert that the Status of the installed product is "Future Subscription"
        List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
        // for (ProductCert productCert : clienttasks.getCurrentProductCertsProvidedBySubscriptionPool(futureSystemSubscriptionPool)) {	// TODO not efficient; testing fix on next line
        for (ProductCert productCert : clienttasks.getProductCertsProvidedBySubscriptionPool(currentProductCerts, futureSystemSubscriptionPool)) {
            InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToProductCert(productCert, installedProducts);
            Assert.assertEquals(installedProduct.status, "Future Subscription", "Status of the installed product '" + productCert.productName + "' after subscribing to future subscription pool: " + futureSystemSubscriptionPool);
        // TODO assert the installedProduct start/end dates
        }
    }
    // simply assert that we actually did subscribe every installed product to a future subscription pool
    for (InstalledProduct installedProduct : clienttasks.getCurrentlyInstalledProducts()) {
        // 8/26/2015 ATTEMPTING TO FIXME AS SUGGESTED IN THE COMMENT LINE ABOVE
        if (!installedProduct.status.equals("Future Subscription") && productIdsProvidedByFutureSubscriptionsThatFailedToAttach.contains(installedProduct.productId)) {
            log.warning("Employing a workaround by removing installed product '" + installedProduct.productName + "' since we encountered a problem when attempting to attach a future subscription that provided for this installed product.");
            client.runCommandAndWait("rm -f " + ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", installedProduct.productId, currentProductCerts).file);
            continue;
        }
        Assert.assertEquals(installedProduct.status, "Future Subscription", "Status of every installed product should be a Future Subscription after subscribing all installed products to a future pool.  This Installed Product: " + installedProduct);
    }
    // finally assert that the overall system is non-compliant
    Assert.assertEquals(clienttasks.getFactValue(factNameForSystemCompliance), factValueForSystemNonCompliance, "When a system has products installed for which ALL are covered by future available subscription pools, the system should remain non-compliant (see value for fact '" + factNameForSystemCompliance + "') after having subscribed to every available subscription pool.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 62 with ProductCert

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

the class BugzillaTests method testCertificateStacking.

/**
 * @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-21985", "RHEL7-51847" }, 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", "certificateStacking", "blockedByBug-726409", "blockedByBug-1183175", "blockedByBug-1555582" }, enabled = true)
public void testCertificateStacking() throws JSONException, Exception {
    Map<String, String> attributes = new HashMap<String, String>();
    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);
    ProductCert installedProductCert100000000000002 = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "100000000000002", clienttasks.getCurrentProductCerts());
    Assert.assertNotNull(installedProductCert100000000000002, "Found installed product cert 100000000000002 needed for this test.");
    configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(new ProductCert[] { installedProductCert100000000000002 }));
    CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "multi-stackable");
    CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
    String resourcePath = "/products/multi-stackable";
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "stackable");
    CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
    resourcePath = "/products/stackable";
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    int sockets = 14;
    String poolid = null;
    String validity = null;
    List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
    listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
    clienttasks.config(null, null, true, listOfSectionNameValues);
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("virt.is_guest", String.valueOf(Boolean.FALSE));
    factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    clienttasks.facts(null, true, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    attributes.put("sockets", "2");
    attributes.put("arch", "ALL");
    attributes.put("type", "MKT");
    attributes.put("multi-entitlement", "yes");
    attributes.put("stacking_id", "726409");
    List<String> providedProducts = new ArrayList<String>();
    providedProducts.add("100000000000002");
    CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "Multi-Stackable for 100000000000002", "multi-stackable", 1, attributes, null);
    CandlepinTasks.createSubscriptionAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, 20, -1 * 24 * 60, /* 1 day ago */
    15 * 24 * 60, /* 15 days from now */
    getRandInt(), getRandInt(), "multi-stackable", providedProducts, 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);
    attributes.put("sockets", "4");
    attributes.put("multi-entitlement", "no");
    CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "Stackable for 100000000000002", "stackable", 1, attributes, null);
    CandlepinTasks.createSubscriptionAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, 20, -1 * 24 * 60, /* 1 day ago */
    15 * 24 * 60, /* 15 days from now */
    getRandInt(), getRandInt(), "stackable", providedProducts, null);
    jobDetail = CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
    jobDetail = CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 5 * 1000, 1);
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    for (SubscriptionPool availList : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (availList.subscriptionName.equals("Multi-Stackable for 100000000000002")) {
            poolid = availList.poolId;
            clienttasks.subscribe_(null, null, availList.poolId, null, null, "3", null, null, null, null, null, null, null);
            validity = clienttasks.getFactValue(factname);
            Assert.assertEquals(validity.trim(), "partial");
        } else if (availList.subscriptionName.equals("Stackable for 100000000000002")) {
            clienttasks.subscribe_(null, null, availList.poolId, null, null, null, null, null, null, null, null, null, null);
            validity = clienttasks.getFactValue(factname);
            Assert.assertEquals(validity.trim(), "partial");
        }
    }
    clienttasks.subscribe_(null, null, poolid, null, null, "2", null, null, null, null, null, null, null);
    clienttasks.getCurrentlyConsumedProductSubscriptions();
    validity = clienttasks.getFactValue(factname);
    Assert.assertEquals(validity.trim(), "valid");
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 63 with ProductCert

use of rhsm.data.ProductCert 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 64 with ProductCert

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

the class BugzillaTests method testAutohealFailForSLA.

/**
 * @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-21935", "RHEL7-51797" }, 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 a system with preference Premium for a product with SLA Standard should fail", groups = { "Tier3Tests", "AutoHealFailForSLA" }, enabled = true)
public void testAutohealFailForSLA() 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, null, null, null, null, null);
    /*List<String> availableServiceLevelData = clienttasks.getCurrentlyAvailableServiceLevels();
		String availableService = availableServiceLevelData
				.get(randomGenerator.nextInt(availableServiceLevelData.size()));*/
    clienttasks.service_level(null, null, "Standard", null, null, null, null, null, null, null, null, null, null);
    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);
    ProductCert productCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "32060", productCerts);
    configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(productCert));
    clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    clienttasks.service_level(null, null, "Premium", null, null, null, null, null, null, null, null, null, null);
    clienttasks.run_rhsmcertd_worker(true);
    List<ProductSubscription> consumed = clienttasks.getCurrentlyConsumedProductSubscriptions();
    Assert.assertTrue((consumed.isEmpty()), "autoheal has failed");
}
Also used : ProductSubscription(rhsm.data.ProductSubscription) ProductCert(rhsm.data.ProductCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 65 with ProductCert

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

the class BugzillaTests method getVerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists.

protected List<List<Object>> getVerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    String eusProductId = null;
    if ((clienttasks.arch.equals("ppc64")) && (clienttasks.variant.equals("Server")))
        eusProductId = "75";
    else if ((clienttasks.arch.equals("x86_64")) && (clienttasks.variant.equals("Server")))
        eusProductId = "70";
    else if ((clienttasks.arch.equals("x86_64")) && clienttasks.variant.equals("ComputeNode"))
        eusProductId = "217";
    else if ((clienttasks.arch.equals("s390x")) && (clienttasks.variant.equals("Server")))
        eusProductId = "73";
    if (eusProductId == null) {
        log.warning("This test does not yet cover variant '" + clienttasks.variant + "' on arch '" + clienttasks.arch + "'.");
        // return no rows and no test will be run
        return ll;
    }
    // unregister
    clienttasks.unregister(null, null, null, null);
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    // get current product cert and verify that rhelproduct is installed on
    // the system
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    SubscriptionPool pool = null;
    for (SubscriptionPool eusSubscriptionPool : SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, null, "*Extended*", null, null, null, null, null).getStdout())) {
        if ((CandlepinTasks.getPoolProvidedProductIds(sm_client1Username, sm_client1Password, sm_serverUrl, eusSubscriptionPool.poolId).contains(eusProductId))) {
            // and attach eus subscription
            clienttasks.subscribe(null, null, eusSubscriptionPool.poolId, null, null, null, null, null, null, null, null, null, null);
            pool = eusSubscriptionPool;
            break;
        }
    }
    if (pool == null) {
        log.warning("Could not find an available EUS subscription that covers EUS product '" + eusProductId + "'.");
        // return no rows and no test will be run
        return ll;
    }
    // find the entitlement that provides access to RHEL and EUS
    EntitlementCert eusEntitlementCerts = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    if (eusEntitlementCerts == null) {
        return ll;
    }
    // if eus repo is not enabled , enable it
    String rhelRepoUrl = null;
    for (Repo disabledRepo : Repo.parse(clienttasks.repos(null, false, true, (String) null, (String) null, null, null, null, null).getStdout())) {
        String variant = null;
        if (clienttasks.arch.equals("x86_64")) {
            if (clienttasks.variant.equals("ComputeNode"))
                variant = "hpc-node";
            if (clienttasks.variant.equals("Server"))
                variant = "server";
        } else if (clienttasks.arch.equals("ppc64") || (clienttasks.arch.equals("ppc64le"))) {
            variant = "for-power";
        } else if (clienttasks.arch.equals("s390x"))
            variant = "for-system-z";
        // add repos for eus-source rpms and debug rpms
        if ((disabledRepo.repoId.matches("rhel-[0-9]+-" + variant + "-eus-rpms"))) {
            clienttasks.repos(null, null, null, disabledRepo.repoId, (String) null, null, null, null, null);
        }
    }
    for (// if eus repo is enabled then add it to the data provider
    Repo enabledRepo : Repo.parse(clienttasks.repos(null, true, false, (String) null, (String) null, null, null, null, null).getStdout())) {
        if (enabledRepo.enabled) {
            String variant = null;
            if (clienttasks.arch.equals("x86_64")) {
                if (clienttasks.variant.equals("ComputeNode"))
                    variant = "hpc-node";
                if (clienttasks.variant.equals("Server"))
                    variant = "server";
            } else if (clienttasks.arch.equals("ppc64") || (clienttasks.arch.equals("ppc64le"))) {
                variant = "for-power";
            } else if (clienttasks.arch.equals("s390x"))
                variant = "for-system-z";
            if (enabledRepo.repoId.matches("rhel-[0-9]+-" + variant + "-eus-rpms")) {
                rhelRepoUrl = enabledRepo.repoUrl;
            }
        }
    }
    // against ppc64le
    for (String release : clienttasks.getCurrentlyAvailableReleases(null, null, null, null)) {
        // skip the latest releases; e.g. 6Server
        if (!isFloat(release))
            continue;
        List<String> bugIds = new ArrayList<String>();
        if (release.startsWith("6")) {
            if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c16
                bugIds.add("1357574");
            if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
                bugIds.add("1357574");
            if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c19
                bugIds.add("1357574");
            if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64"))
                // https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c19
                bugIds.add("1357574");
            if (release.matches("6.7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64"))
                bugIds.add("1352162");
        }
        if (release.startsWith("7")) {
            if (// && clienttasks.variant.equals("Server"))
            release.matches("7.1"))
                bugIds.add("1369920");
        }
        BlockedByBzBug blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, release, rhelRepoUrl, eusEntitlementCerts.file }));
    }
    return ll;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Aggregations

ProductCert (rhsm.data.ProductCert)90 Test (org.testng.annotations.Test)60 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)54 SkipException (org.testng.SkipException)44 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)40 ArrayList (java.util.ArrayList)40 File (java.io.File)26 SubscriptionPool (rhsm.data.SubscriptionPool)24 EntitlementCert (rhsm.data.EntitlementCert)23 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)22 InstalledProduct (rhsm.data.InstalledProduct)21 JSONObject (org.json.JSONObject)19 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)17 List (java.util.List)16 ContentNamespace (rhsm.data.ContentNamespace)15 HashSet (java.util.HashSet)13 Calendar (java.util.Calendar)7 HashMap (java.util.HashMap)7 BigInteger (java.math.BigInteger)6 JSONArray (org.json.JSONArray)6