Search in sources :

Example 76 with ProductCert

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

the class MigrationDataTests method testMigrationProductCertsMatchThoseFromRhnDefinitions.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20098", "RHEL7-51105" }, 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 migration product certs match those from rhn definitions", groups = { "Tier1Tests", "blockedByBug-799152", "blockedByBug-814360", "blockedByBug-861420", "blockedByBug-861470", "blockedByBug-872959", "blockedByBug-875760", "blockedByBug-875802", "blockedByBug-1305695", "blockedByBug-1555913" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testMigrationProductCertsMatchThoseFromRhnDefinitions() {
    // assemble a list of rhnDefinitionsProductCertsDirs that we care about under [rcm/rcm-metadata.git] / product_ids /
    // Note: we care about all of the productCertsDirs
    SSHCommandResult result = client.runCommandAndWait("find " + clienttasks.rhnDefinitionsDir + "/product_ids -maxdepth 1 -type d");
    List<String> rhnDefinitionsProductCertsDirs = new ArrayList<String>();
    for (String productIdsDir : result.getStdout().split("\\n")) {
        if (!productIdsDir.equals(clienttasks.rhnDefinitionsDir + "/product_ids")) {
            // put logic here to exclude specific directories
            rhnDefinitionsProductCertsDirs.add(productIdsDir);
        }
    }
    Assert.assertTrue(!rhnDefinitionsProductCertsDirs.isEmpty(), "The " + clienttasks.rhnDefinitionsDir + "/product_ids is not empty.");
    // process all the migration product cert files into ProductCerts and assert they match those from the RHN Definitions
    // get all of the rhnDefnition product certs
    List<ProductCert> rhnDefnitionProductCerts = new ArrayList<ProductCert>();
    for (String rhnDefinitionsProductCertsDir : /*sm_*/
    rhnDefinitionsProductCertsDirs) {
        String tmpRhnDefinitionsProductCertsDir = /*clienttasks.rhnDefinitionsDir+*/
        rhnDefinitionsProductCertsDir;
        Assert.assertTrue(RemoteFileTasks.testExists(client, tmpRhnDefinitionsProductCertsDir), "The rhn definitions product certs dir '" + rhnDefinitionsProductCertsDir + "' has been locally cloned to '" + tmpRhnDefinitionsProductCertsDir + "'.");
        rhnDefnitionProductCerts.addAll(clienttasks.getProductCerts(tmpRhnDefinitionsProductCertsDir));
    }
    /* ALTERNATIVE WAY OF GETTING ALL rhnDefnition PRODUCT CERTS FROM ALL DIRECTORIES
		SSHCommandResult result = client.runCommandAndWait("find "+clienttasks.rhnDefinitionsDir+"/product_ids/ -name '*.pem'");
		String[] rhnDefnitionProductCertPaths = result.getStdout().trim().split("\\n");
		if (rhnDefnitionProductCertPaths.length==1 && rhnDefnitionProductCertPaths[0].equals("")) rhnDefnitionProductCertPaths = new String[]{};
		for (String rhnDefnitionProductCertPath : rhnDefnitionProductCertPaths) {
			rhnDefnitionProductCerts.add(clienttasks.getProductCertFromProductCertFile(new File(rhnDefnitionProductCertPath)));
		}
		*/
    // get the local migration product certs available for install
    List<ProductCert> migrationProductCerts = clienttasks.getProductCerts(baseProductsDir);
    // test that these local migration product certs came from the current rhnDefinitions structure
    boolean verifiedMatchForAllMigrationProductCertFiles = true;
    for (ProductCert migrationProductCert : migrationProductCerts) {
        if (rhnDefnitionProductCerts.contains(migrationProductCert)) {
            // LOGGING HOG	Assert.assertTrue(true, "Migration product cert '"+migrationProductCert.file+"' was found among the product certs declared for this release from ["+sm_rhnDefinitionsGitRepository+"] "+/*sm_*/rhnDefinitionsProductCertsDirs);
            Assert.assertTrue(true, "Migration product cert '" + migrationProductCert.file + "' was found among the product certs declared for this release from the product_ids directory under [" + sm_rhnDefinitionsGitRepository + "]");
        } else {
            log.warning("Migration product cert '" + migrationProductCert.file + "' was NOT found among the product certs declared for this release from [" + sm_rhnDefinitionsGitRepository + "] " + /*sm_*/
            rhnDefinitionsProductCertsDirs + ".  It may have been re-generated by release engineering.");
            log.info("Searching the current product certs defined by release engineering for a newly generated instance of this migration product cert...");
            boolean foundNewerVersionOfMigrationProductCert = false;
            for (ProductCert rhnDefnitionProductCert : rhnDefnitionProductCerts) {
                Set<String> rhnDefnitionProductCertProvidedTags = new HashSet<String>();
                Set<String> migrationProductCertProvidedTags = new HashSet<String>();
                // tags can be defined as a comma separated string
                if (rhnDefnitionProductCert.productNamespace.providedTags != null)
                    rhnDefnitionProductCertProvidedTags.addAll(Arrays.asList(rhnDefnitionProductCert.productNamespace.providedTags.split("\\s*,\\s*")));
                // tags can be defined as a comma separated string
                if (migrationProductCert.productNamespace.providedTags != null)
                    migrationProductCertProvidedTags.addAll(Arrays.asList(migrationProductCert.productNamespace.providedTags.split("\\s*,\\s*")));
                if (rhnDefnitionProductCert.productId.equals(migrationProductCert.productId) && // NOT A MUST MATCH		rhnDefnitionProductCert.productName.equals(migrationProductCert.productName) &&
                rhnDefnitionProductCert.productNamespace.version.equals(migrationProductCert.productNamespace.version) && rhnDefnitionProductCertProvidedTags.containsAll(migrationProductCertProvidedTags) && migrationProductCertProvidedTags.containsAll(rhnDefnitionProductCertProvidedTags) && rhnDefnitionProductCert.productNamespace.arch.equals(migrationProductCert.productNamespace.arch) && rhnDefnitionProductCert.productNamespace.brandType == migrationProductCert.productNamespace.brandType) {
                    foundNewerVersionOfMigrationProductCert = true;
                    Assert.assertTrue(foundNewerVersionOfMigrationProductCert, "Found a functionally equivalent product cert among the current product certs defined by release engineering.  This accounts for above warning.");
                    log.info("migrationProductCert:    " + migrationProductCert);
                    log.info("rhnDefnitionProductCert: " + rhnDefnitionProductCert);
                }
            }
            // skip a known issue that is irrelevant on RHEL7.  This is failing because rcm updated product cert product_ids/rhel-6.7-eus/EUS-Server-s390x-1a3bca323339-73.pem to product_ids/rhel-6.7-eus/EUS-Server-s390x-e9eb3d196edc-73.pem, but this is irrelevant on rhel7
            if (migrationProductCert.file.getPath().equals("/usr/share/rhsm/product/RHEL-7/EUS-Server-s390x-1a3bca323339-73.pem")) {
                // [root@jsefler-rhel7 rhnDefinitionsDir]# rct cat-cert /usr/share/rhsm/product/RHEL-7/EUS-Server-s390x-1a3bca323339-73.pem | grep -A7 "Product:"
                // Product:
                // ID: 73
                // Name: Red Hat Enterprise Linux for IBM System z - Extended Update Support
                // Version: 6.7
                // Arch: s390x
                // Tags: rhel-6-ibm-system-z
                // Brand Type:
                // Brand Name:
                log.info("Ignoring the WARNING for migration product cert '" + migrationProductCert.file + "' because it is irrelevant on RHEL7.  It applies to RHEL6: " + migrationProductCert.productNamespace);
                continue;
            }
            // skip a known issue product 126 was removed in commit http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/commit/product_ids?id=f04a9cfd3dbe971f710afedfecc7f7c8bdf4c307 but was NOT regenerated in http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/commit/product_ids?id=721aaec8aa57bff38929c6736dc98696b1a89011
            if (migrationProductCert.file.getPath().equals("/usr/share/rhsm/product/RHEL-7/Server-SJIS-x86_64-1d1c6aac9e3b-126.pem")) {
                // [root@jsefler-rhel7 ~]# rct cat-cert /usr/share/rhsm/product/RHEL-7/Server-SJIS-x86_64-1d1c6aac9e3b-126.pem | grep -A7 "Product:"
                // Product:
                // ID: 126
                // Name: Red Hat S-JIS Support (for RHEL Server)
                // Version: 7.4
                // Arch: x86_64
                // Tags: rhel-7-server-sjis,rhel-7-sjis
                // Brand Type:
                // Brand Name:
                log.info("Ignoring the WARNING for migration product cert '" + migrationProductCert.file + "' because it is extraneous ad will not harm anything.  It was excluded in the regenerated certs by rcm in commit http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/commit/product_ids?id=721aaec8aa57bff38929c6736dc98696b1a89011");
                continue;
            }
            if (!foundNewerVersionOfMigrationProductCert)
                verifiedMatchForAllMigrationProductCertFiles = false;
        }
    }
    // now assert that all of product certs from the current rhnDefinitions structure are locally available for install
    if (false) {
        // NOT A VALID TEST since all product certs from the current rhnDefinitions structure may not be mapped in product-certs.json file
        for (ProductCert rhnDefinitionProductCert : rhnDefnitionProductCerts) {
            if (migrationProductCerts.contains(rhnDefinitionProductCert)) {
                Assert.assertTrue(true, "CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was found among the local migration product certs available for installation.");
            } else {
                // determine if the rhnDefinitionProductCert is not mapped to any RHEL [5|6] RHN Channels defined in the product baseline file
                List<String> rhnChannels = cdnProductBaselineProductIdMap.get(rhnDefinitionProductCert.productId);
                if (rhnChannels == null) {
                    log.warning("CDN Product Baseline has an empty list of RHN Channels for Product ID '" + rhnDefinitionProductCert.productId + "' Name '" + rhnDefinitionProductCert.productName + "'.  This could be a rel-eng defect.");
                    rhnChannels = new ArrayList<String>();
                }
                Set<String> rhnChannelsFilteredForRhelRelease = new HashSet<String>();
                for (String rhnChannel : rhnChannels) {
                    // filter out all RHN Channels not associated with this release  (e.g., assume that an rhn channel containing "-5-" or ends in "-5" is only applicable to rhel5
                    if (!(rhnChannel.contains("-" + clienttasks.redhatReleaseX + "-") || rhnChannel.endsWith("-" + clienttasks.redhatReleaseX)))
                        continue;
                    rhnChannelsFilteredForRhelRelease.add(rhnChannel);
                }
                if (rhnChannelsFilteredForRhelRelease.isEmpty()) {
                    log.info("CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was NOT found among the current migration product certs.  No RHEL '" + clienttasks.redhatReleaseX + "' RHN Channels in '" + sm_rhnDefinitionsProductBaselineFile + "' map to Product ID '" + rhnDefinitionProductCert.productId + "' Name '" + rhnDefinitionProductCert.productName + "'.");
                } else {
                    log.warning("CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was NOT found among the current migration product certs.  It is probably a new product cert generated by release engineering and therefore subscription-manager-migration-data needs a regeneration.");
                    verifiedMatchForAllMigrationProductCertFiles = false;
                }
            }
        }
    }
    Assert.assertTrue(verifiedMatchForAllMigrationProductCertFiles, "All of the migration productCerts in directory '" + baseProductsDir + "' match the current [" + sm_rhnDefinitionsGitRepository + "] product certs for this RHEL release '" + clienttasks.redhatReleaseXY + "' ");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 77 with ProductCert

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

the class MigrationDataTests method testExpectedBaseChannelsSupportThisSystemsRhelVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20105", "RHEL7-55203" }, 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 expected RHN base channels supporting this system's RHEL release version are mapped to product certs whose version matches this system's RHEL release", groups = { "Tier1Tests", "blockedByBug-1110863", "blockedByBug-1148110", "blockedByBug-1197864", "blockedByBug-1300766", "blockedByBug-1222712", "blockedByBug-1228387", "blockedByBug-1241221", "blockedByBug-1328579", "blockedByBug-1328609", "blockedByBug-1366747", "blockedByBug-1393573", "blockedByBug-1436441", "blockedByBug-1510200", "blockedByBug-1555913" }, dependsOnMethods = { "testChannelCertMapping" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testExpectedBaseChannelsSupportThisSystemsRhelVersion() {
    // TEMPORARY WORKAROUND FOR BUG
    if (clienttasks.redhatReleaseXY.equals("7.5")) {
        // Bug 1549863 - Missing base RHN-to-ProductCert channel map for "rhel-ppc64le-server-7" and "rhel-aarch64-server-7"
        String bugId = "1549863";
        boolean invokeWorkaroundWhileBugIsOpen = true;
        try {
            if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
            } else {
                invokeWorkaroundWhileBugIsOpen = false;
            }
        } catch (BugzillaAPIException be) {
        /* ignore exception */
        } catch (RuntimeException re) {
        /* ignore exception */
        }
        if (invokeWorkaroundWhileBugIsOpen) {
            throw new SkipException("Skipping this test on '" + clienttasks.redhatReleaseXY + "' while bug '" + bugId + "' is open.");
        }
    }
    // END OF WORKAROUND
    List<String> expectedBaseChannels = new ArrayList<String>();
    if (clienttasks.redhatReleaseX.equals("7")) {
        // TEMPORARY WORKAROUND FOR BUG
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1078527 - channel-cert-mapping for ComputeNode rhel-7 product certs are missing and wrong
        String bugId1 = "1078527";
        // Bug 1078530 - product-certs.json appears to contain bad/missing mappings for ComputeNode rhel7 channels
        String bugId2 = "1078530";
        invokeWorkaroundWhileBugIsOpen = false;
        try {
            if (invokeWorkaroundWhileBugIsOpen && (BzChecker.getInstance().isBugOpen(bugId1) || BzChecker.getInstance().isBugOpen(bugId2))) {
                log.fine("Invoking workaround for Bugzillas:  https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId1 + " https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId2);
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId1);
                SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId2);
            } else {
                invokeWorkaroundWhileBugIsOpen = false;
            }
        } catch (BugzillaAPIException be) {
        /* ignore exception */
        } catch (RuntimeException re) {
        /* ignore exception */
        }
        if (invokeWorkaroundWhileBugIsOpen) {
            throw new SkipException("Skipping this test on '" + clienttasks.redhatReleaseX + "' while bug " + bugId1 + " or " + bugId2 + " is open.");
        }
        // END OF WORKAROUND
        // 68	Red Hat Enterprise Linux Desktop
        expectedBaseChannels.add("rhel-x86_64-client-7");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-x86_64-server-7");
        // 71	Red Hat Enterprise Linux Workstation
        expectedBaseChannels.add("rhel-x86_64-workstation-7");
        // 76	Red Hat Enterprise Linux for Scientific Computing
        expectedBaseChannels.add("rhel-x86_64-hpc-node-7");
        // 72	Red Hat Enterprise Linux for IBM System z
        expectedBaseChannels.add("rhel-s390x-server-7");
        // 74	Red Hat Enterprise Linux for IBM POWER
        expectedBaseChannels.add("rhel-ppc64-server-7");
        if (Float.valueOf(clienttasks.redhatReleaseXY) >= 7.3) {
            // TODO may need updates after bug 1549863 is resolved
            // 279	Red Hat Enterprise Linux for Power, little endian
            expectedBaseChannels.add("rhel-ppc64le-server-7");
            // 294	Red Hat Enterprise Linux Server for ARM Development Preview <= Preview?
            expectedBaseChannels.add("rhel-aarch64-server-7");
        }
    } else if (clienttasks.redhatReleaseX.equals("6")) {
        // // TEMPORARY WORKAROUND FOR BUG
        // String bugId = "0000"; boolean invokeWorkaroundWhileBugIsOpen = true;
        // try {if (invokeWorkaroundWhileBugIsOpen&&BzChecker.getInstance().isBugOpen(bugId)) {log.fine("Invoking workaround for "+BzChecker.getInstance().getBugState(bugId).toString()+" Bugzilla "+bugId+".  (https://bugzilla.redhat.com/show_bug.cgi?id="+bugId+")");SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);} else {invokeWorkaroundWhileBugIsOpen=false;}} catch (BugzillaAPIException be) {/* ignore exception */} catch (RuntimeException re) {/* ignore exception */}
        // if (invokeWorkaroundWhileBugIsOpen) {
        // throw new SkipException("Skipping this test on '"+clienttasks.redhatReleaseX+"' while bug '"+bugId+"' is open.");
        // }
        // // END OF WORKAROUND
        // 68	Red Hat Enterprise Linux Desktop
        expectedBaseChannels.add("rhel-i386-client-6");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-i386-server-6");
        // 71	Red Hat Enterprise Linux Workstation
        expectedBaseChannels.add("rhel-i386-workstation-6");
        // 68	Red Hat Enterprise Linux Desktop
        expectedBaseChannels.add("rhel-x86_64-client-6");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-x86_64-server-6");
        // 71	Red Hat Enterprise Linux Workstation
        expectedBaseChannels.add("rhel-x86_64-workstation-6");
        // 72	Red Hat Enterprise Linux for IBM System z
        expectedBaseChannels.add("rhel-s390x-server-6");
        // 74	Red Hat Enterprise Linux for IBM POWER
        expectedBaseChannels.add("rhel-ppc64-server-6");
        // 76	Red Hat Enterprise Linux for Scientific Computing
        expectedBaseChannels.add("rhel-x86_64-hpc-node-6");
    } else if (clienttasks.redhatReleaseX.equals("5")) {
        // // TEMPORARY WORKAROUND FOR BUG
        // String bugId = "0000"; boolean invokeWorkaroundWhileBugIsOpen = true;
        // try {if (invokeWorkaroundWhileBugIsOpen&&BzChecker.getInstance().isBugOpen(bugId)) {log.fine("Invoking workaround for "+BzChecker.getInstance().getBugState(bugId).toString()+" Bugzilla "+bugId+".  (https://bugzilla.redhat.com/show_bug.cgi?id="+bugId+")");SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);} else {invokeWorkaroundWhileBugIsOpen=false;}} catch (BugzillaAPIException be) {/* ignore exception */} catch (RuntimeException re) {/* ignore exception */}
        // if (invokeWorkaroundWhileBugIsOpen) {
        // throw new SkipException("Skipping this test on '"+clienttasks.redhatReleaseX+"' while bug '"+bugId+"' is open.");
        // }
        // // END OF WORKAROUND
        // 68	Red Hat Enterprise Linux Desktop
        expectedBaseChannels.add("rhel-i386-client-5");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-i386-server-5");
        // 71	Red Hat Enterprise Linux Workstation
        expectedBaseChannels.add("rhel-i386-client-workstation-5");
        // 68	Red Hat Enterprise Linux Desktop
        expectedBaseChannels.add("rhel-x86_64-client-5");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-x86_64-server-5");
        // 71	Red Hat Enterprise Linux Workstation
        expectedBaseChannels.add("rhel-x86_64-client-workstation-5");
        // 69	Red Hat Enterprise Linux Server
        expectedBaseChannels.add("rhel-ia64-server-5");
        // 72	Red Hat Enterprise Linux for IBM System z
        expectedBaseChannels.add("rhel-s390x-server-5");
        // 74	Red Hat Enterprise Linux for IBM POWER
        expectedBaseChannels.add("rhel-ppc-server-5");
    }
    if (expectedBaseChannels.isEmpty())
        Assert.fail("Do not know the expected RHN Base Channels for this test.");
    // verify all expectedBaseChannels are accounted for in the channel mapping file
    boolean allExpectedBaseChannelsMapped = true;
    for (String expectedBaseChannel : expectedBaseChannels) {
        if (channelsToProductCertFilenamesMap.containsKey(expectedBaseChannel)) {
            Assert.assertTrue(channelsToProductCertFilenamesMap.containsKey(expectedBaseChannel), "RHN Channel mapping file '" + channelCertMappingFilename + "' accounts for RHN base channel '" + expectedBaseChannel + "'.");
        } else {
            log.warning("RHN Channel mapping file '" + channelCertMappingFilename + "' does NOT account for RHN base channel '" + expectedBaseChannel + "'.");
            allExpectedBaseChannelsMapped = false;
        }
    }
    // NOTE: This test block is also covered by VerifyRhnRhelChannelsProductCertSupportThisSystemsRhelVersion_Test (Keeping it here for completeness)
    // verify all of the expectedBaseChannels are mapped to a product cert that supports this system's dot release of RHEL
    boolean allBaseChannelProductCertsMatchThisRhelRelease = true;
    for (String expectedBaseChannel : expectedBaseChannels) {
        if (channelsToProductCertFilenamesMap.containsKey(expectedBaseChannel)) {
            if (channelsToProductCertFilenamesMap.get(expectedBaseChannel).equalsIgnoreCase("none")) {
                log.warning("RHN RHEL Base Channel '" + expectedBaseChannel + "' should NOT be mapped to none in mapping file '" + channelCertMappingFilename + "'.");
                allBaseChannelProductCertsMatchThisRhelRelease = false;
            } else {
                ProductCert migrationProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + channelsToProductCertFilenamesMap.get(expectedBaseChannel)));
                if (clienttasks.redhatReleaseXY.equals(migrationProductCert.productNamespace.version)) {
                    Assert.assertEquals(clienttasks.redhatReleaseXY, migrationProductCert.productNamespace.version, "RHN RHEL Base Channel '" + expectedBaseChannel + "' maps to the following product cert that matches RHEL dot release '" + clienttasks.redhatReleaseXY + "': " + migrationProductCert);
                } else {
                    log.warning("RHN RHEL Base Channel '" + expectedBaseChannel + "' maps to the following product cert that does NOT match RHEL dot release '" + clienttasks.redhatReleaseXY + "': " + migrationProductCert);
                    allBaseChannelProductCertsMatchThisRhelRelease = false;
                }
            }
        }
    }
    if (!allExpectedBaseChannelsMapped)
        Assert.fail("Review logged warnings above for expected RHN base channels that are not mapped.");
    if (!allBaseChannelProductCertsMatchThisRhelRelease)
        Assert.fail("Review logged warnings above for expected RHN base channel product cert versions that do not match this system.s dot release.");
}
Also used : ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 78 with ProductCert

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

the class MigrationDataTests method testRhnRhelChannelsProductCertSupportThisSystemsRhelVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20107", "RHEL7-51112" }, 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 expected RHN RHEL channels supporting this system's RHEL release X.Y version are mapped to product certs whose version matches this system's RHEL release X.Y (also asserts beta channels to Beta product certs)", groups = { "Tier1Tests", "blockedByBug-1080072", "blockedByBug-1110863", "blockedByBug-1148110", "blockedByBug-1197864", "blockedByBug-1300766", "blockedByBug-1222712", "blockedByBug-1241221", "blockedByBug-1328579", "blockedByBug-1393573", "blockedByBug-1436441", "blockedByBug-1510200", "blockedByBug-1555913" }, dataProvider = "RhnRhelChannelsFromChannelMappingData", dependsOnMethods = { "testChannelCertMapping" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRhnRhelChannelsProductCertSupportThisSystemsRhelVersion(Object bugzilla, String rhnRhelChannel) {
    Assert.assertTrue(!channelsToProductCertFilenamesMap.get(rhnRhelChannel).equalsIgnoreCase("none"), "RHN RHEL Channel '" + rhnRhelChannel + "' does not map to None.");
    ProductCert rhnRhelProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + channelsToProductCertFilenamesMap.get(rhnRhelChannel)));
    if (rhnRhelChannel.contains(/*clienttasks.redhatReleaseX+*/
    "-beta-") || rhnRhelChannel.endsWith(/*clienttasks.redhatReleaseX+*/
    "-beta")) {
        String expectedProductNamespaceVersion = clienttasks.redhatReleaseXY + " Beta";
        if (!rhnRhelProductCert.productNamespace.version.equals(expectedProductNamespaceVersion)) {
            log.warning("RHN RHEL Beta Channel '" + rhnRhelChannel + "' maps to the following product cert that should correspond to this RHEL minor release (expected='" + expectedProductNamespaceVersion + "' actual='" + rhnRhelProductCert.productNamespace.version + "'): " + rhnRhelProductCert.productNamespace);
            throw new SkipException("Skipping this failed test instance in favor of RFE Bug https://bugzilla.redhat.com/show_bug.cgi?id=1437233 that will intensionally exclude beta channels to product cert mappings.  Also referencing precedence bugs that have been CLOSED WONTFIX on beta channels: 1435255 1435245");
        }
        Assert.assertEquals(rhnRhelProductCert.productNamespace.version, expectedProductNamespaceVersion, "RHN RHEL Beta Channel '" + rhnRhelChannel + "' maps to the following product cert that corresponds to this RHEL minor release '" + clienttasks.redhatReleaseXY + "': " + rhnRhelProductCert.productNamespace);
    } else {
        Assert.assertEquals(rhnRhelProductCert.productNamespace.version, clienttasks.redhatReleaseXY, "RHN RHEL Channel '" + rhnRhelChannel + "' maps to the following product cert that corresponds to this RHEL minor release '" + clienttasks.redhatReleaseXY + "': " + rhnRhelProductCert.productNamespace);
    }
}
Also used : 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 79 with ProductCert

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

the class MigrationDataTests method testMigrationProductCertsMatchThoseFromRhnDefinitions_DEPRECATED.

@Deprecated
@Test(description = "Verify that the migration product certs match those from rhn definitions", groups = { "Tier1Tests", "blockedByBug-799152", "blockedByBug-814360", "blockedByBug-861420", "blockedByBug-861470", "blockedByBug-872959", "blockedByBug-875760", "blockedByBug-875802" }, // 9/9/2013 RHEL65: disabled in favor of new VerifyMigrationProductCertsMatchThoseFromRhnDefinitions_Test
enabled = false)
public // @ImplementsNitrateTest(caseId=)
void testMigrationProductCertsMatchThoseFromRhnDefinitions_DEPRECATED() {
    // process all the migration product cert files into ProductCerts and assert they match those from the RHN Definitions
    // get all of the rhnDefnition product certs
    List<ProductCert> rhnDefnitionProductCerts = new ArrayList<ProductCert>();
    for (String rhnDefinitionsProductCertsDir : sm_rhnDefinitionsProductCertsDirs) {
        String tmpRhnDefinitionsProductCertsDir = clienttasks.rhnDefinitionsDir + rhnDefinitionsProductCertsDir;
        Assert.assertTrue(RemoteFileTasks.testExists(client, tmpRhnDefinitionsProductCertsDir), "The rhn definitions product certs dir '" + rhnDefinitionsProductCertsDir + "' has been locally cloned to '" + tmpRhnDefinitionsProductCertsDir + "'.");
        rhnDefnitionProductCerts.addAll(clienttasks.getProductCerts(tmpRhnDefinitionsProductCertsDir));
    }
    /* ALTERNATIVE WAY OF GETTING ALL rhnDefnition PRODUCT CERTS FROM ALL DIRECTORIES
		SSHCommandResult result = client.runCommandAndWait("find "+clienttasks.rhnDefinitionsDir+"/product_ids/ -name '*.pem'");
		String[] rhnDefnitionProductCertPaths = result.getStdout().trim().split("\\n");
		if (rhnDefnitionProductCertPaths.length==1 && rhnDefnitionProductCertPaths[0].equals("")) rhnDefnitionProductCertPaths = new String[]{};
		for (String rhnDefnitionProductCertPath : rhnDefnitionProductCertPaths) {
			rhnDefnitionProductCerts.add(clienttasks.getProductCertFromProductCertFile(new File(rhnDefnitionProductCertPath)));
		}
		*/
    // get the local migration product certs available for install
    List<ProductCert> migrationProductCerts = clienttasks.getProductCerts(baseProductsDir);
    // test that these local migration product certs came from the current rhnDefinitions structure
    boolean verifiedMatchForAllMigrationProductCertFiles = true;
    for (ProductCert migrationProductCert : migrationProductCerts) {
        if (rhnDefnitionProductCerts.contains(migrationProductCert)) {
            Assert.assertTrue(true, "Migration product cert '" + migrationProductCert.file + "' was found among the product certs declared for this release from [" + sm_rhnDefinitionsGitRepository + "] " + sm_rhnDefinitionsProductCertsDirs);
        } else {
            log.warning("Migration product cert '" + migrationProductCert.file + "' was NOT found among the product certs declared for this release from [" + sm_rhnDefinitionsGitRepository + "] " + sm_rhnDefinitionsProductCertsDirs + ".  It may have been re-generated by release engineering.");
            verifiedMatchForAllMigrationProductCertFiles = false;
        }
    }
    // now assert that all of product certs from the current rhnDefinitions structure are locally available for install
    for (ProductCert rhnDefinitionProductCert : rhnDefnitionProductCerts) {
        if (migrationProductCerts.contains(rhnDefinitionProductCert)) {
            Assert.assertTrue(true, "CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was found among the local migration product certs available for installation.");
        } else {
            // determine if the rhnDefinitionProductCert is not mapped to any RHEL [5|6] RHN Channels defined in the product baseline file
            List<String> rhnChannels = cdnProductBaselineProductIdMap.get(rhnDefinitionProductCert.productId);
            if (rhnChannels == null) {
                log.warning("CDN Product Baseline has an empty list of RHN Channels for Product ID '" + rhnDefinitionProductCert.productId + "' Name '" + rhnDefinitionProductCert.productName + "'.  This could be a rel-eng defect.");
                rhnChannels = new ArrayList<String>();
            }
            Set<String> rhnChannelsFilteredForRhelRelease = new HashSet<String>();
            for (String rhnChannel : rhnChannels) {
                // filter out all RHN Channels not associated with this release  (e.g., assume that an rhn channel containing "-5-" or ends in "-5" is only applicable to rhel5
                if (!(rhnChannel.contains("-" + clienttasks.redhatReleaseX + "-") || rhnChannel.endsWith("-" + clienttasks.redhatReleaseX)))
                    continue;
                rhnChannelsFilteredForRhelRelease.add(rhnChannel);
            }
            if (rhnChannelsFilteredForRhelRelease.isEmpty()) {
                log.info("CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was NOT found among the current migration product certs.  No RHEL '" + clienttasks.redhatReleaseX + "' RHN Channels in '" + sm_rhnDefinitionsProductBaselineFile + "' map to Product ID '" + rhnDefinitionProductCert.productId + "' Name '" + rhnDefinitionProductCert.productName + "'.");
            } else {
                log.warning("CDN product cert [" + sm_rhnDefinitionsGitRepository + "] " + rhnDefinitionProductCert.file.getPath().replaceFirst(clienttasks.rhnDefinitionsDir, "") + " was NOT found among the current migration product certs.  It is probably a new product cert generated by release engineering and therefore subscription-manager-migration-data needs a regeneration.");
                verifiedMatchForAllMigrationProductCertFiles = false;
            }
        }
    }
    Assert.assertTrue(verifiedMatchForAllMigrationProductCertFiles, "All of the migration productCerts in directory '" + baseProductsDir + "' match the current [" + sm_rhnDefinitionsGitRepository + "] product certs for this RHEL release '" + clienttasks.redhatReleaseXY + "' ");
}
Also used : ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 80 with ProductCert

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

the class MigrationDataTests method testMigrationProductCertsSupportThisSystemsRhelVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20106", "RHEL7-51111" }, 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 migration product certs support this system's RHEL release version", groups = { "Tier1Tests", "blockedByBug-782208", "blockedByBug-1006060", "blockedByBug-1025338", "blockedByBug-1080072", "blockedByBug-1110863", "blockedByBug-1148110", "blockedByBug-1197864", "blockedByBug-1300766", "blockedByBug-1241221", "blockedByBug-1328579", "blockedByBug-1393573", "blockedByBug-1436441", "blockedByBug-1510200", "blockedByBug-1555913" }, dependsOnMethods = { "testChannelCertMapping" }, enabled = true)
@ImplementsNitrateTest(caseId = 130940)
public void testMigrationProductCertsSupportThisSystemsRhelVersion() {
    // process all the migration product cert files into ProductCerts and assert their version
    boolean verifiedVersionOfAllMigrationProductCertFiles = false;
    int numberOfMigrationProductCertsSupportingThisRelease = 0;
    for (ProductCert productCert : clienttasks.getProductCerts(baseProductsDir)) {
        if (productCert.productNamespace.providedTags == null || !productCert.productNamespace.providedTags.toLowerCase().contains("rhel")) {
            log.info("Migration productCert '" + productCert.file + "' providesTags '" + productCert.productNamespace.providedTags + "' which are NOT RHEL tags.  Skipping assertion that its version matches this system's RHEL version.");
            continue;
        }
        if (productCert.productNamespace.version.equals(clienttasks.redhatReleaseXY)) {
            Assert.assertTrue(true, "Migration productCert '" + productCert.file + "' supports this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
            numberOfMigrationProductCertsSupportingThisRelease++;
        } else {
            log.warning("Migration productCert '" + productCert.file + "' providesTags '" + productCert.productNamespace.providedTags + "' version '" + productCert.productNamespace.version + "' does NOT support this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
        }
    }
    Assert.assertTrue(numberOfMigrationProductCertsSupportingThisRelease > 0, "At least one 'actual=" + numberOfMigrationProductCertsSupportingThisRelease + "' migration productCerts in directory '" + baseProductsDir + "' support this version of RHEL '" + clienttasks.redhatReleaseXY + "'.");
}
Also used : ProductCert(rhsm.data.ProductCert) 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

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