Search in sources :

Example 26 with ProductCert

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

the class MigrationTests method testRhnMigrateClassicToRhsm_Rhel5ClientDesktopVersusWorkstation.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-26764", "RHEL7-55205" }, 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 = "migrating a RHEL5 Client - Desktop versus Workstation", groups = { "Tier1Tests", "RhnMigrateClassicToRhsm_Test", "blockedByBug-786257", "blockedByBug-853233", "blockedByBug-1111258" }, dependsOnMethods = {}, enabled = true)
public void testRhnMigrateClassicToRhsm_Rhel5ClientDesktopVersusWorkstation() throws JSONException {
    if (sm_rhnHostname.equals(""))
        throw new SkipException("This test requires access to RHN Classic or Satellite 5.");
    log.info("Red Hat Enterprise Linux Desktop (productId=68) corresponds to the base RHN Channel (rhel-ARCH-client-5) for a 5Client system where ARCH=i386,x86_64.");
    log.info("Red Hat Enterprise Linux Workstation (productId=71) corresponds to child RHN Channel (rhel-ARCH-client-workstation-5) for a 5Client system where ARCH=i386,x86_64.");
    log.info("After migrating from RHN Classic to RHSM, these two product certs should not be installed at the same time; Workstation shoul prevail.");
    // when we are migrating away from RHN Classic to a non-hosted candlepin server, choose the credentials that will be used to register
    String rhsmUsername = null, rhsmPassword = null, rhsmOrg = null;
    if (!isCurrentlyConfiguredServerTypeHosted()) {
        // or this may work too: if (!sm_serverType.equals(CandlepinType.hosted)) {
        rhsmUsername = sm_clientUsername;
        rhsmPassword = sm_clientPassword;
        rhsmOrg = sm_clientOrg;
    }
    // 2273         "Name": "Red Hat Enterprise Linux Desktop",
    // 2274         "Product ID": "68",
    // 2275         "RHN Channels": [
    // 2276             "rhel-i386-client-5",
    // 2277             "rhel-i386-client-5-beta",
    // 2278             "rhel-i386-client-5-beta-debuginfo",
    // 2279             "rhel-i386-client-5-debuginfo",
    // 2280             "rhel-i386-client-6",
    // 2281             "rhel-i386-client-6-beta",
    // 2282             "rhel-i386-client-6-beta-debuginfo",
    // 2283             "rhel-i386-client-6-debuginfo",
    // 2284             "rhel-i386-client-optional-6",
    // 2285             "rhel-i386-client-optional-6-beta",
    // 2286             "rhel-i386-client-optional-6-beta-debuginfo",
    // 2287             "rhel-i386-client-optional-6-debuginfo",
    // 2288             "rhel-i386-client-supplementary-5",
    // 2289             "rhel-i386-client-supplementary-5-beta",
    // 2290             "rhel-i386-client-supplementary-5-beta-debuginfo",
    // 2291             "rhel-i386-client-supplementary-5-debuginfo",
    // 2292             "rhel-i386-client-supplementary-6",
    // 2293             "rhel-i386-client-supplementary-6-beta",
    // 2294             "rhel-i386-client-supplementary-6-beta-debuginfo",
    // 2295             "rhel-i386-client-supplementary-6-debuginfo",
    // 2296             "rhel-i386-rhev-agent-5-client",
    // 2297             "rhel-i386-rhev-agent-5-client-beta",
    // 2298             "rhel-i386-rhev-agent-6-client",
    // 2299             "rhel-i386-rhev-agent-6-client-beta",
    // 2300             "rhel-i386-rhev-agent-6-client-beta-debuginfo",
    // 2301             "rhel-i386-rhev-agent-6-client-debuginfo",
    // 2302             "rhel-x86_64-client-5",
    // 2303             "rhel-x86_64-client-5-beta",
    // 2304             "rhel-x86_64-client-5-beta-debuginfo",
    // 2305             "rhel-x86_64-client-5-debuginfo",
    // 2306             "rhel-x86_64-client-6",
    // 2307             "rhel-x86_64-client-6-beta",
    // 2308             "rhel-x86_64-client-6-beta-debuginfo",
    // 2309             "rhel-x86_64-client-6-debuginfo",
    // 2310             "rhel-x86_64-client-optional-6",
    // 2311             "rhel-x86_64-client-optional-6-beta",
    // 2312             "rhel-x86_64-client-optional-6-beta-debuginfo",
    // 2313             "rhel-x86_64-client-optional-6-debuginfo",
    // 2314             "rhel-x86_64-client-supplementary-5",
    // 2315             "rhel-x86_64-client-supplementary-5-beta",
    // 2316             "rhel-x86_64-client-supplementary-5-beta-debuginfo",
    // 2317             "rhel-x86_64-client-supplementary-5-debuginfo",
    // 2318             "rhel-x86_64-client-supplementary-6",
    // 2319             "rhel-x86_64-client-supplementary-6-beta",
    // 2320             "rhel-x86_64-client-supplementary-6-beta-debuginfo",
    // 2321             "rhel-x86_64-client-supplementary-6-debuginfo",
    // 2322             "rhel-x86_64-rhev-agent-5-client",
    // 2323             "rhel-x86_64-rhev-agent-5-client-beta",
    // 2324             "rhel-x86_64-rhev-agent-6-client",
    // 2325             "rhel-x86_64-rhev-agent-6-client-beta",
    // 2326             "rhel-x86_64-rhev-agent-6-client-beta-debuginfo",
    // 2327             "rhel-x86_64-rhev-agent-6-client-debuginfo"
    // 2328         ]
    // 10289         "Name": "Red Hat Enterprise Linux Workstation",
    // 10290         "Product ID": "71",
    // 10291         "RHN Channels": [
    // 10292             "rhel-i386-client-5",
    // 10293             "rhel-i386-client-5-beta",
    // 10294             "rhel-i386-client-5-beta-debuginfo",
    // 10295             "rhel-i386-client-5-debuginfo",
    // 10296             "rhel-i386-client-supplementary-5",
    // 10297             "rhel-i386-client-supplementary-5-beta",
    // 10298             "rhel-i386-client-supplementary-5-beta-debuginfo",
    // 10299             "rhel-i386-client-supplementary-5-debuginfo",
    // 10300             "rhel-i386-client-vt-5",
    // 10301             "rhel-i386-client-vt-5-beta",
    // 10302             "rhel-i386-client-vt-5-beta-debuginfo",
    // 10303             "rhel-i386-client-vt-5-debuginfo",
    // 10304             "rhel-i386-client-workstation-5",
    // 10305             "rhel-i386-client-workstation-5-beta",
    // 10306             "rhel-i386-client-workstation-5-beta-debuginfo",
    // 10307             "rhel-i386-client-workstation-5-debuginfo",
    // 10308             "rhel-i386-rhev-agent-6-workstation",
    // 10309             "rhel-i386-rhev-agent-6-workstation-beta",
    // 10310             "rhel-i386-rhev-agent-6-workstation-beta-debuginfo",
    // 10311             "rhel-i386-rhev-agent-6-workstation-debuginfo",
    // 10312             "rhel-i386-workstation-6",
    // 10313             "rhel-i386-workstation-6-beta",
    // 10314             "rhel-i386-workstation-6-beta-debuginfo",
    // 10315             "rhel-i386-workstation-6-debuginfo",
    // 10316             "rhel-i386-workstation-optional-6",
    // 10317             "rhel-i386-workstation-optional-6-beta",
    // 10318             "rhel-i386-workstation-optional-6-beta-debuginfo",
    // 10319             "rhel-i386-workstation-optional-6-debuginfo",
    // 10320             "rhel-i386-workstation-supplementary-6",
    // 10321             "rhel-i386-workstation-supplementary-6-beta",
    // 10322             "rhel-i386-workstation-supplementary-6-beta-debuginfo",
    // 10323             "rhel-i386-workstation-supplementary-6-debuginfo",
    // 10324             "rhel-x86_64-client-5",
    // 10325             "rhel-x86_64-client-5-beta",
    // 10326             "rhel-x86_64-client-5-beta-debuginfo",
    // 10327             "rhel-x86_64-client-5-debuginfo",
    // 10328             "rhel-x86_64-client-supplementary-5",
    // 10329             "rhel-x86_64-client-supplementary-5-beta",
    // 10330             "rhel-x86_64-client-supplementary-5-beta-debuginfo",
    // 10331             "rhel-x86_64-client-supplementary-5-debuginfo",
    // 10332             "rhel-x86_64-client-vt-5",
    // 10333             "rhel-x86_64-client-vt-5-beta",
    // 10334             "rhel-x86_64-client-vt-5-beta-debuginfo",
    // 10335             "rhel-x86_64-client-vt-5-debuginfo",
    // 10336             "rhel-x86_64-client-workstation-5",
    // 10337             "rhel-x86_64-client-workstation-5-beta",
    // 10338             "rhel-x86_64-client-workstation-5-beta-debuginfo",
    // 10339             "rhel-x86_64-client-workstation-5-debuginfo",
    // 10340             "rhel-x86_64-rhev-agent-6-workstation",
    // 10341             "rhel-x86_64-rhev-agent-6-workstation-beta",
    // 10342             "rhel-x86_64-rhev-agent-6-workstation-beta-debuginfo",
    // 10343             "rhel-x86_64-rhev-agent-6-workstation-debuginfo",
    // 10344             "rhel-x86_64-workstation-6",
    // 10345             "rhel-x86_64-workstation-6-beta",
    // 10346             "rhel-x86_64-workstation-6-beta-debuginfo",
    // 10347             "rhel-x86_64-workstation-6-debuginfo",
    // 10348             "rhel-x86_64-workstation-optional-6",
    // 10349             "rhel-x86_64-workstation-optional-6-beta",
    // 10350             "rhel-x86_64-workstation-optional-6-beta-debuginfo",
    // 10351             "rhel-x86_64-workstation-optional-6-debuginfo",
    // 10352             "rhel-x86_64-workstation-supplementary-6",
    // 10353             "rhel-x86_64-workstation-supplementary-6-beta",
    // 10354             "rhel-x86_64-workstation-supplementary-6-beta-debuginfo",
    // 10355             "rhel-x86_64-workstation-supplementary-6-debuginfo"
    // 10356         ]
    // this test is only applicable on a RHEL 5Client
    final String applicableReleasever = "5Client";
    if (!clienttasks.releasever.equals(applicableReleasever))
        throw new SkipException("This test is only executable when the redhat-release is '" + applicableReleasever + "'.");
    // decide what product arch applies to our system
    // default
    String arch = clienttasks.arch;
    // RHEL supports i386 packages, but can be run on all 32-bit arch hardware
    if (Arrays.asList("i386", "i486", "i586", "i686").contains(clienttasks.arch))
        arch = "i386";
    if (!Arrays.asList("i386", "x86_64").contains(arch))
        Assert.fail("RHEL " + applicableReleasever + " should only be available on i386 and x86_64 arches (not: " + arch + ").");
    // Case 1: add RHN Channels for Desktop only; migration should only install Desktop product 68
    List<String> rhnChannelsToAddForDesktop = new ArrayList<String>();
    // rhnChannelsToAdd.add(String.format("rhel-%s-client-5",arch));	// this is the base channel and will already be consumed by rhnreg_ks
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-5-beta", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-5-beta-debuginfo", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-5-debuginfo", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-supplementary-5", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-supplementary-5-beta", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-supplementary-5-beta-debuginfo", arch));
    rhnChannelsToAddForDesktop.add(String.format("rhel-%s-client-supplementary-5-debuginfo", arch));
    testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, rhnChannelsToAddForDesktop, "--no-auto", sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, null);
    List<ProductCert> productCertsMigrated = clienttasks.getCurrentProductCerts();
    String productIdForDesktop = "68";
    for (ProductCert productCert : productCertsMigrated) {
        Assert.assertEquals(productCert.productId, productIdForDesktop, "Migration tool " + rhnMigrateTool + " should only install product certificate id '" + productIdForDesktop + "' when consuming RHN Child Channels " + rhnChannelsToAddForDesktop);
    }
    // Case 2: add RHN Channels for Workstation only; migration should only install Workstation product 71
    List<String> rhnChannelsToAddForWorkstation = new ArrayList<String>();
    // rhnChannelsToAdd.add(String.format("rhel-%s-client-5",arch));	// this is the base channel and will already be consumed by rhnreg_ks
    /*
		rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-vt-5",arch));
		rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-vt-5-beta",arch));
		rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-vt-5-beta-debuginfo",arch));
		rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-vt-5-debuginfo",arch));
		*/
    rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-workstation-5", arch));
    rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-workstation-5-beta", arch));
    rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-workstation-5-beta-debuginfo", arch));
    rhnChannelsToAddForWorkstation.add(String.format("rhel-%s-client-workstation-5-debuginfo", arch));
    testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, rhnChannelsToAddForWorkstation, "--no-auto", sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, null);
    productCertsMigrated = clienttasks.getCurrentProductCerts();
    String productIdForWorkstation = "71";
    for (ProductCert productCert : productCertsMigrated) {
        Assert.assertEquals(productCert.productId, productIdForWorkstation, "Migration tool " + rhnMigrateTool + " should only install product certificate id '" + productIdForWorkstation + "' when consuming RHN Child Channels " + rhnChannelsToAddForWorkstation);
    }
    // Case 3: add RHN Channels for Virtualization only; migration should only install Workstation product 71
    // Bug 853233 - rhn-migrate-classic-to-rhsm is installing both Desktop(68) and Workstation(71) when rhel-ARCH-client-vt-5 channel is consumed
    List<String> rhnChannelsToAddForVirtualization = new ArrayList<String>();
    // rhnChannelsToAdd.add(String.format("rhel-%s-client-5",arch));	// this is the base channel and will already be consumed by rhnreg_ks
    rhnChannelsToAddForVirtualization.add(String.format("rhel-%s-client-vt-5", arch));
    rhnChannelsToAddForVirtualization.add(String.format("rhel-%s-client-vt-5-beta", arch));
    rhnChannelsToAddForVirtualization.add(String.format("rhel-%s-client-vt-5-beta-debuginfo", arch));
    rhnChannelsToAddForVirtualization.add(String.format("rhel-%s-client-vt-5-debuginfo", arch));
    testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, rhnChannelsToAddForVirtualization, "--no-auto", sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, null);
    productCertsMigrated = clienttasks.getCurrentProductCerts();
    /*String*/
    productIdForWorkstation = "71";
    for (ProductCert productCert : productCertsMigrated) {
        Assert.assertEquals(productCert.productId, productIdForWorkstation, "Migration tool " + rhnMigrateTool + " should only install product certificate id '" + productIdForWorkstation + "' when consuming RHN Child Channels " + rhnChannelsToAddForVirtualization);
    }
    // Case 4: add RHN Channels for both Desktop and Workstation; migration should only install Workstation product 71
    List<String> rhnChannelsToAddForBoth = new ArrayList<String>();
    rhnChannelsToAddForBoth.addAll(rhnChannelsToAddForDesktop);
    rhnChannelsToAddForBoth.addAll(rhnChannelsToAddForWorkstation);
    rhnChannelsToAddForBoth.addAll(rhnChannelsToAddForVirtualization);
    testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, rhnChannelsToAddForBoth, "--no-auto", sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, null);
    productCertsMigrated = clienttasks.getCurrentProductCerts();
    for (ProductCert productCert : productCertsMigrated) {
        Assert.assertEquals(productCert.productId, productIdForWorkstation, "Migration tool " + rhnMigrateTool + " should only install product certificate id '" + productIdForWorkstation + "' when consuming RHN Child Channels " + rhnChannelsToAddForBoth);
    }
}
Also used : ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 27 with ProductCert

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

the class MigrationTests method testRhnMigrateClassicToRhsm.

// rhn-migrate-classic-to-rhsm Test methods ***********************************************************************
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20111", "RHEL7-51115" }, 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 = "Register system using RHN Classic and then Execute migration tool rhn-migrate-classic-to-rhsm with options after adding RHN Channels", groups = { "Tier1Tests", "RhnMigrateClassicToRhsm_Test", "blockedByBug-966745", "blockedByBug-840169", "blockedbyBug-878986", "blockedByBug-1052297", "blockedByBug-1111258", "blockedByBug-1512948", "blockedByBug-1516832" }, dependsOnMethods = {}, dataProvider = "RhnMigrateClassicToRhsmData", enabled = true)
public // @ImplementsNitrateTest(caseId=130764,130762) // TODO some expected yum repo assertions are not yet automated
void testRhnMigrateClassicToRhsm(Object bugzilla, String rhnreg_ksUsername, String rhnreg_ksPassword, String rhnHostname, List<String> rhnChannelsToAdd, String options, String rhnUsername, String rhnPassword, String rhsmUsername, String rhsmPassword, String rhsmOrg, Integer serviceLevelIndex, String serviceLevelExpected) throws JSONException {
    if (sm_rhnHostname.equals(""))
        throw new SkipException("This test requires access to RHN Classic or Satellite 5.");
    if (Integer.valueOf(clienttasks.redhatReleaseX) >= 7 && clienttasks.arch.equals("ppc64le"))
        throw new SkipException("Use of rhn-migrate-classic-to-rhsm is not necessary on RHEL '" + client1tasks.redhatReleaseX + "' arch '" + clienttasks.arch + "' since this product was not released on RHN Classic.");
    if (Integer.valueOf(clienttasks.redhatReleaseX) >= 7 && clienttasks.arch.equals("aarch64"))
        throw new SkipException("Use of rhn-migrate-classic-to-rhsm is not necessary on RHEL '" + client1tasks.redhatReleaseX + "' arch '" + clienttasks.arch + "' since this product was not released on RHN Classic.");
    if (false) {
        // TODO maybe this should go after the unregister and removeAll commands
        // make sure our serverUrl is configured to it's original good value
        restoreOriginallyConfiguredServerUrl();
        // make sure we are NOT registered to RHSM
        clienttasks.unregister(null, null, null, null);
        // deleting the currently installed product certs
        clienttasks.removeAllCerts(false, false, true);
        clienttasks.removeAllFacts();
    } else {
        // TODO: 8/12/2013 Attempting the following logic in response to above TODO
        // make sure we are NOT registered to RHSM (and system is clean from prior test) ignoring errors like:
        // ssh root@cloud-qe-9.idm.lab.bos.redhat.com subscription-manager unregister
        // Stdout: Runtime Error Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.candlepin.model.Pool#8a99f9823fc4919b013fc49408a302b7] at org.hibernate.persister.entity.AbstractEntityPersister.check:1,782
        // Stderr:
        // ExitCode: 255
        clienttasks.unregister_(null, null, null, null);
        clienttasks.removeAllCerts(true, true, true);
        clienttasks.removeAllFacts();
        restoreOriginallyConfiguredServerUrl();
    }
    // randomly remove a benign rhn classic package (just to add a little unnecessary fun)
    if (randomGenerator.nextBoolean() && clienttasks.isPackageInstalled("osad"))
        clienttasks.yumRemovePackage("osad");
    if (randomGenerator.nextBoolean() && clienttasks.isPackageInstalled("openscap"))
        clienttasks.yumRemovePackage("openscap");
    // register to RHN Classic
    String rhnSystemId = clienttasks.registerToRhnClassic(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname);
    Assert.assertTrue(clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId), "Confirmed that rhn systemId '" + rhnSystemId + "' is currently registered.");
    // subscribe to more RHN Classic channels
    if (rhnChannelsToAdd.size() > 0)
        addRhnClassicChannels(rhnreg_ksUsername, rhnreg_ksPassword, rhnChannelsToAdd);
    // get a list of the consumed RHN Classic channels
    List<String> rhnChannelsConsumed = clienttasks.getCurrentRhnClassicChannels();
    if (rhnChannelsToAdd.size() > 0)
        Assert.assertTrue(rhnChannelsConsumed.containsAll(rhnChannelsToAdd), "All of the RHN Classic channels added appear to be consumed.");
    // get a map of the productid.js file before we attempt migration
    Map<String, List<String>> productIdRepoMapBeforeMigration = clienttasks.getProductIdToReposMap();
    // get the product cert filenames that we should expect rhn-migrate-classic-to-rhsm to copy (or use the ones supplied to the @Test)
    Set<String> expectedMigrationProductCertFilenames = getExpectedMappedProductCertFilenamesCorrespondingToChannels(rhnChannelsConsumed);
    // screw up the currently configured [server]hostname:port/prefix when the command line options specify a new URL
    if (options.contains("--serverurl") || options.contains("--destination-url")) {
        log.info("Configuring a bad server hostname:port/prefix to test that the specified --serverurl can override it...");
        List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
        if (doesStringContainMatches(options, "(--serverurl|--destination-url)=(https://)?[\\w\\.-]+")) {
            // hostname
            listOfSectionNameValues.add(new String[] { "server", "hostname", "bad-hostname.com" });
        }
        if (doesStringContainMatches(options, "(--serverurl|--destination-url)=(https://)?[\\w\\.-]+:\\d+")) {
            // port
            listOfSectionNameValues.add(new String[] { "server", "port", "000" });
        }
        if (doesStringContainMatches(options, "(--serverurl|--destination-url)=(https://)?[\\w\\.-]+(:\\d+)?/\\w+")) {
            // prefix
            listOfSectionNameValues.add(new String[] { "server", "prefix", "/bad-prefix" });
        }
        clienttasks.config(null, null, true, listOfSectionNameValues);
    }
    // execute rhn-migrate-classic-to-rhsm with options
    SSHCommandResult sshCommandResult = executeRhnMigrateClassicToRhsm(options, rhnUsername, rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, serviceLevelIndex);
    // assert valid usage
    if (sshCommandResult.getStdout().contains("Usage: rhn-migrate-classic-to-rhsms")) {
        Assert.fail("Detected a usage error.");
    }
    // get a map of the productid.js file after we attempt migration
    Map<String, List<String>> productIdRepoMapAfterMigration = clienttasks.getProductIdToReposMap();
    // assert the exit code
    checkForKnownBug881952(sshCommandResult);
    checkForKnownBug1130637(sshCommandResult);
    String expectedMsg;
    if (!getProductCertFilenamesContainingNonUniqueProductIds(expectedMigrationProductCertFilenames).isEmpty()) {
        log.warning("The RHN Classic channels currently consumed map to multiple product certs that share the same product ID " + getProductCertFilenamesContainingNonUniqueProductIds(expectedMigrationProductCertFilenames) + ".  We must abort in this case.  Therefore, the " + rhnMigrateTool + " command should have exited with code 1.");
        // TEMPORARY WORKAROUND FOR BUG
        // Bug 1006985 - rhn-migrate-classic-to-rhsm should abort when it encounters RHN channels that map to different products certs that share the same productId
        String bugId = "1006985";
        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("The remainder of this test is blocked by bug " + bugId + ".  There is no workaround.");
        }
        // END OF WORKAROUND
        // +-----------------------------------------------------+
        // Unable to continue migration!
        // +-----------------------------------------------------+
        // You are subscribed to channels that have conflicting product certificates.
        // The following channels map to product ID 69:
        // rhel-x86_64-rhev-agent-6-server
        // rhel-x86_64-rhev-agent-6-server-beta
        // rhel-x86_64-rhev-agent-6-server-beta-debuginfo
        // rhel-x86_64-rhev-agent-6-server-debuginfo
        // rhel-x86_64-server-6
        // rhel-x86_64-server-6-cf-tools-1
        // rhel-x86_64-server-6-cf-tools-1-beta
        // rhel-x86_64-server-6-cf-tools-1-beta-debuginfo
        // rhel-x86_64-server-6-cf-tools-1-debuginfo
        // Reduce the number of channels per product ID to 1 and run migration again.
        // To remove a channel, use 'rhn-channel --remove --channel=<conflicting_channel>'.
        // TODO Improve the expectedMsg to better assert the list of conflicting channels
        expectedMsg = "Unable to continue migration!";
        Assert.assertTrue(sshCommandResult.getStdout().contains(expectedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
        Assert.assertEquals(sshCommandResult.getExitCode(), new Integer(1), "ExitCode from call to '" + rhnMigrateTool + " " + options + "' when currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        Assert.assertTrue(clienttasks.isRhnSystemRegistered(), "This system is still registered using RHN Classic when currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        // assert that no product certs have been copied yet
        // OLD		Assert.assertEquals(clienttasks.getCurrentlyInstalledProducts().size(), 0, "No productCerts have been migrated when "+rhnMigrateTool+" aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        Assert.assertEquals(clienttasks.getProductCerts(clienttasks.productCertDir).size(), 0, "No productCerts have been migrated when " + rhnMigrateTool + " aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        // assert that we are not yet registered to RHSM
        Assert.assertNull(clienttasks.getCurrentConsumerCert(), "We should NOT be registered to RHSM when " + rhnMigrateTool + " aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        // assert that we are still registered to RHN
        Assert.assertTrue(clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId), "Confirmed that rhn systemId '" + rhnSystemId + "' is still registered since our migration attempt aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        // assert that the rhnplugin is still enabled
        Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForRhn, "enabled"), "1", "The enabled yum plugin configuration for RHN.");
        // assert that productid.js is unchanged
        Assert.assertTrue(productIdRepoMapBeforeMigration.keySet().containsAll(productIdRepoMapAfterMigration.keySet()) && productIdRepoMapAfterMigration.keySet().containsAll(productIdRepoMapBeforeMigration.keySet()), "The '" + clienttasks.productIdJsonFile + "' productIds remain unchanged when " + rhnMigrateTool + " aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        for (String productId : productIdRepoMapBeforeMigration.keySet()) {
            Assert.assertTrue(productIdRepoMapBeforeMigration.get(productId).containsAll(productIdRepoMapAfterMigration.get(productId)) && productIdRepoMapAfterMigration.get(productId).containsAll(productIdRepoMapBeforeMigration.get(productId)), "The '" + clienttasks.productIdJsonFile + "' productIds repos for '" + productId + "' remain unchanged when " + rhnMigrateTool + " aborts because the currently consumed RHN Classic channels map to multiple productCerts sharing the same productId.");
        }
        return;
    } else if (!areAllChannelsMapped(rhnChannelsConsumed) && !options.contains("-f")) /*--force*/
    {
        // when not all of the rhnChannelsConsumed have been mapped to a productCert and no --force has been specified.
        log.warning("Not all of the channels are mapped to a product cert.  Therefore, the " + rhnMigrateTool + " command should have exited with code 1.");
        expectedMsg = "Use --force to ignore these channels and continue the migration.";
        Assert.assertTrue(sshCommandResult.getStdout().contains(expectedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
        Assert.assertEquals(sshCommandResult.getExitCode(), new Integer(1), "ExitCode from call to '" + rhnMigrateTool + " " + options + "' when any of the channels are not mapped to a productCert.");
        Assert.assertTrue(clienttasks.isRhnSystemRegistered(), "This system is still registered using RHN Classic when rhn-migrate-classic-to-rhsm requires --force to continue.");
        // assert that no product certs have been copied yet
        Assert.assertEquals(clienttasks.getCurrentlyInstalledProducts().size(), 0, "No productCerts have been migrated when " + rhnMigrateTool + " requires --force to continue.");
        // assert that we are not yet registered to RHSM
        Assert.assertNull(clienttasks.getCurrentConsumerCert(), "We should NOT be registered to RHSM when " + rhnMigrateTool + " requires --force to continue.");
        // assert that we are still registered to RHN
        Assert.assertTrue(clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId), "Confirmed that rhn systemId '" + rhnSystemId + "' is still registered since our migration attempt requires --force to continue.");
        // assert that the rhnplugin is still enabled
        Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForRhn, "enabled"), "1", "The enabled yum plugin configuration for RHN.");
        // assert that productid.js is unchanged
        Assert.assertTrue(productIdRepoMapBeforeMigration.keySet().containsAll(productIdRepoMapAfterMigration.keySet()) && productIdRepoMapAfterMigration.keySet().containsAll(productIdRepoMapBeforeMigration.keySet()), "The '" + clienttasks.productIdJsonFile + "' productIds remain unchanged when " + rhnMigrateTool + " requires --force to continue.");
        for (String productId : productIdRepoMapBeforeMigration.keySet()) {
            Assert.assertTrue(productIdRepoMapBeforeMigration.get(productId).containsAll(productIdRepoMapAfterMigration.get(productId)) && productIdRepoMapAfterMigration.get(productId).containsAll(productIdRepoMapBeforeMigration.get(productId)), "The '" + clienttasks.productIdJsonFile + "' productIds repos for '" + productId + "' remain unchanged when " + rhnMigrateTool + " requires --force to continue.");
        }
        return;
    } else if (rhnChannelsConsumed.isEmpty()) {
        log.warning("Modifying expected results when the current RHN Classically registered system is not consuming any RHN channels.");
        String expectedStdout = "Problem encountered getting the list of subscribed channels.  Exiting.";
        // changed by commit c0f8052ec2b5b7b5c736eb626e381aef0e5327e5
        if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1"))
            expectedStdout = "Problem encountered getting the list of subscribed channels.  See /var/log/rhsm/rhsm.log for more details.";
        Assert.assertTrue(sshCommandResult.getStdout().trim().endsWith(expectedStdout), "The expected stdout result from call to '" + rhnMigrateTool + "' when no RHN Classic channels are being consumed: " + expectedStdout);
        // Assert.assertEquals(sshCommandResult.getExitCode(), new Integer(1), "The expected exit code from call to '"+rhnMigrateTool+"' when no RHN Classic channels are being consumed.");		// the exitCode can be altered by the expect script rhn-migrate-classic-to-rhsm.tcl when the final arg slaIndex is non-null; therefore don't bother asserting exitCode; asserting stdout is sufficient
        Assert.assertTrue(clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId), "Confirmed that rhn systemId '" + rhnSystemId + "' is still registered after '" + rhnMigrateTool + "' exits due to: " + expectedStdout);
        // assert that productid.js is unchanged
        Assert.assertTrue(productIdRepoMapBeforeMigration.keySet().containsAll(productIdRepoMapAfterMigration.keySet()) && productIdRepoMapAfterMigration.keySet().containsAll(productIdRepoMapBeforeMigration.keySet()), "The '" + clienttasks.productIdJsonFile + "' productIds remain unchanged when " + rhnMigrateTool + " exits due to: " + expectedStdout);
        for (String productId : productIdRepoMapBeforeMigration.keySet()) {
            Assert.assertTrue(productIdRepoMapBeforeMigration.get(productId).containsAll(productIdRepoMapAfterMigration.get(productId)) && productIdRepoMapAfterMigration.get(productId).containsAll(productIdRepoMapBeforeMigration.get(productId)), "The '" + clienttasks.productIdJsonFile + "' productIds repos for '" + productId + "' remain unchanged when " + rhnMigrateTool + " exits due to: " + expectedStdout);
        }
        return;
    }
    Assert.assertEquals(sshCommandResult.getExitCode(), new Integer(0), "ExitCode from call to '" + rhnMigrateTool + " " + options + "' when all of the channels are mapped.");
    // assert product certificates are copied
    expectedMsg = String.format("Product certificates copied successfully to %s !", clienttasks.productCertDir);
    expectedMsg = String.format("Product certificates copied successfully to %s", clienttasks.productCertDir);
    // Bug 852107 - String Update: rhn-migrate-classic-to-rhsm output
    expectedMsg = String.format("Product certificates installed successfully to %s.", clienttasks.productCertDir);
    Assert.assertTrue(sshCommandResult.getStdout().contains(expectedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
    // assert that the expected product certs mapped from the consumed RHN Classic channels are now installed
    // OLD	List<ProductCert> migratedProductCerts = clienttasks.getCurrentProductCerts();
    // OLD	Assert.assertEquals(clienttasks.getCurrentlyInstalledProducts().size(), expectedMigrationProductCertFilenames.size(), "The number of productCerts installed after running "+rhnMigrateTool+" with "+options+".  (If this fails, one of these migration certs may have clobbered the other "+expectedMigrationProductCertFilenames+")");
    List<ProductCert> migratedProductCerts = clienttasks.getProductCerts(clienttasks.productCertDir);
    Assert.assertEquals(migratedProductCerts.size(), expectedMigrationProductCertFilenames.size(), "The number of productCerts in '" + clienttasks.productCertDir + "' after running " + rhnMigrateTool + " with options '" + options + "'.  (If this fails, one of these migration certs may have clobbered the other " + expectedMigrationProductCertFilenames + ")");
    for (String expectedMigrationProductCertFilename : expectedMigrationProductCertFilenames) {
        ProductCert expectedMigrationProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + expectedMigrationProductCertFilename));
        Assert.assertTrue(migratedProductCerts.contains(expectedMigrationProductCert), "The newly migrated product certs in '" + clienttasks.productCertDir + "' includes the expected migration productCert: " + expectedMigrationProductCert);
    }
    // assert the expected migration.* facts are set
    // [root@ibm-x3620m3-01 ~]# subscription-manager facts --list | grep migration
    Map<String, String> factMap = clienttasks.getFacts();
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13")) {
        // migration.classic_system_id: 1000021964
        // migration.migrated_from: https://sat-56-server.usersys.redhat.com/XMLRPC
        // migration.migration_date: 2015-02-07T18:42:18.744943
        // migration.classic_system_id: 1033298347
        // migration.migrated_from: https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC
        // migration.migration_date: 2015-02-24T19:52:14.685785
        String expectedMigrationFromFact = rhnHostname + "/XMLRPC";
        if (!expectedMigrationFromFact.startsWith("http"))
            expectedMigrationFromFact = "https://xmlrpc." + expectedMigrationFromFact;
        Assert.assertEquals(factMap.get(migrationFromFact), expectedMigrationFromFact, "The migration fact '" + migrationFromFact + "' should be set after running " + rhnMigrateTool + " with " + options + ".");
    } else {
        // migration.classic_system_id: 1023061526
        // migration.migrated_from: rhn_hosted_classic
        // migration.migration_date: 2012-07-13T18:51:44.254543
        Assert.assertEquals(factMap.get(migrationFromFact), "rhn_hosted_classic", "The migration fact '" + migrationFromFact + "' should be set after running " + rhnMigrateTool + " with " + options + ".");
    }
    Assert.assertEquals(factMap.get(migrationSystemIdFact), rhnSystemId, "The migration fact '" + migrationSystemIdFact + "' should be set after running " + rhnMigrateTool + " with " + options + ".");
    Assert.assertNotNull(factMap.get(migrationDateFact), "The migration fact '" + migrationDateFact + "' should be set after running " + rhnMigrateTool + " with " + options + ".");
    // tolerance in seconds to assert that the migration_date facts was set within the last few seconds
    int tol = 300;
    Calendar migrationDate;
    /* 10-23-2015 DELETEME AFTER PROVING THAT migrationDateFactWithGMTOffsetTimeZone WORKS
//		if (client.runCommandAndWait("date +%Z").getStdout().trim().endsWith("DT")) {	// are we currently on daylight summer/savings time?
//			// determined on Mar 9, 2015 (day after Daylight Summer/Savings Time starts), when date +%Z returns EDT, passing passing null for timeZone will correctly pass the migrationDateFact assertion (Note: passing "EDT" will actually screw it up)
//			migrationDate = parseDateStringUsingDatePattern(factMap.get(migrationDateFact), "yyyy-MM-dd'T'HH:mm:ss", null);	// NOTE: The .SSS milliseconds was dropped from the date pattern because it was getting confused as seconds from the six digit value in migration.migration_date: 2012-08-08T11:11:15.818782
//		} else {
//			migrationDate = parseDateStringUsingDatePattern(factMap.get(migrationDateFact), "yyyy-MM-dd'T'HH:mm:ss", client.runCommandAndWait("date +%Z").getStdout().trim());	// NOTE: The .SSS milliseconds was dropped from the date pattern because it was getting confused as seconds from the six digit value in migration.migration_date: 2012-08-08T11:11:15.818782
//		}
*/
    // the time zone is absent from the value of the migration.migration_date fact (arguably an RFE bug), let's append the GMTOffsetTimeZone of the client
    // [root@ibm-hs22-04 ~]# subscription-manager facts | grep migration_date
    // migration.migration_date: 2015-10-24T00:01:54.040880
    // [root@ibm-hs22-04 ~]# date -d "2015-10-24T00:01:54.040880" -Iseconds
    // 2015-10-24T00:01:54+0200
    // [root@ibm-hs22-04 ~]# date +%Z
    // CEST
    String migrationDateFactWithGMTOffsetTimeZone = client.runCommandAndWait("date -d \"" + factMap.get(migrationDateFact) + "\" -Iseconds").getStdout().trim();
    String systemTimeZone = client.runCommandAndWait("date +%Z").getStdout().trim();
    String systemTimeZoneHHMM = client.runCommandAndWait("date +%:z").getStdout().trim();
    migrationDate = parseDateStringUsingDatePattern(migrationDateFactWithGMTOffsetTimeZone, "yyyy-MM-dd'T'HH:mm:ssZ", systemTimeZone);
    // seconds since 1970-01-01 00:00:00 UTC (will be the same value no matter what TimeZone the system is in
    long systemTimeInSeconds = Long.valueOf(client.runCommandAndWait("date +%s").getStdout().trim());
    long migratTimeInSeconds = migrationDate.getTimeInMillis() / 1000;
    // workaround on RHEL5 and RHEL6 for coreutils bug
    if (Integer.valueOf(clienttasks.redhatReleaseX) < 7) {
        // bump up the time in seconds by taking 7 hours and subtracting the time zone HH:MM offset)  TODO: determine if this formula works during daylight savings time.
        migratTimeInSeconds += 7 * /*hours*/
        60 * 60 - (Integer.parseInt(systemTimeZoneHHMM.split(":")[0]) * /*hours*/
        60 * 60 + Integer.parseInt(systemTimeZoneHHMM.split(":")[1]) * /*minutes*/
        60);
    }
    Assert.assertTrue(systemTimeInSeconds - tol < migratTimeInSeconds && migratTimeInSeconds < systemTimeInSeconds + tol, "The migration date fact '" + factMap.get(migrationDateFact) + "' was set within the last '" + tol + "' seconds (local system time).  Actual diff='" + String.valueOf(systemTimeInSeconds - migratTimeInSeconds) + "' seconds.");
    // assert we are no longer registered to RHN Classic
    // Two possible results can occur when the rhn-migrate-classic-to-rhsm script attempts to unregister from RHN Classic.  We need to tolerate both cases...
    String successfulUnregisterMsg = "System successfully unregistered from RHN Classic.";
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13"))
        successfulUnregisterMsg = "System successfully unregistered from legacy server.";
    String unsuccessfulUnregisterMsg = "Did not receive a completed unregistration message from RHN Classic for system " + rhnSystemId + "." + "\n" + "Please investigate on the Customer Portal at https://access.redhat.com.";
    if (sshCommandResult.getStdout().contains(successfulUnregisterMsg)) {
        // Case 1: number of subscribed channels is low and all communication completes in a timely fashion.  Here is a snippet from stdout:
        // Preparing to unregister system from RHN Classic ...
        // System successfully unregistered from RHN Classic.
        Assert.assertTrue(sshCommandResult.getStdout().contains(successfulUnregisterMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + successfulUnregisterMsg);
        Assert.assertTrue(!sshCommandResult.getStdout().contains(unsuccessfulUnregisterMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' does NOT contain message: " + unsuccessfulUnregisterMsg);
        Assert.assertTrue(!clienttasks.isRhnSystemRegistered(), "This system is NOT registered using RHN Classic. Therefore this system will no longer communicate with RHN Classic.");
        Assert.assertTrue(!clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId), "Confirmed that rhn systemId '" + rhnSystemId + "' is no longer registered on the RHN Classic server.");
    } else {
        // Case 2: number of subscribed channels is high and communication fails in a timely fashion (see bug 881952).  Here is a snippet from stdout:
        // Preparing to unregister system from RHN Classic ...
        // Did not receive a completed unregistration message from RHN Classic for system 1023722557.
        // Please investigate on the Customer Portal at https://access.redhat.com.
        log.warning("Did not detect expected message '" + successfulUnregisterMsg + "' from " + rhnMigrateTool + " stdout.  Nevertheless, the tool should inform us and continue the migration process.");
        Assert.assertTrue(sshCommandResult.getStdout().contains(unsuccessfulUnregisterMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + unsuccessfulUnregisterMsg);
        Assert.assertTrue(!clienttasks.isRhnSystemRegistered(), "This system is NOT registered using RHN Classic. Therefore this system will no longer communicate with RHN Classic.");
        if (!clienttasks.isRhnSystemIdRegistered(rhnreg_ksUsername, rhnreg_ksPassword, rhnHostname, rhnSystemId)) {
            Assert.assertFalse(false, "Confirmed that rhn systemId '" + rhnSystemId + "' is no longer registered on the RHN Classic server.");
        } else {
            log.warning("The RHN Classic server believes that this system is still registered.  SystemId '" + rhnSystemId + "' should be manually deleted on the Customer Portal.");
        }
    }
    // assert that the legacy services have been stopped (introduced by RFE Bug 1185914
    // Product certificates installed successfully to /etc/pki/product.
    // 
    // Preparing to unregister system from legacy server...
    // System successfully unregistered from legacy server.
    // Stopping and disabling legacy services...
    // osad: unrecognized service
    // osad: unrecognized service
    // TEMPORARY WORKAROUND FOR BUG
    // Bug 1390341 - rhn-migrate-classic-to-rhsm is failing to stop and disable services
    String bugId1 = "1390341";
    // Bug 1432231 - rhn-migrate-classic-to-rhsm is failing to stop and disable services
    String bugId2 = "1432231";
    boolean invokeWorkaroundWhileBug1IsOpen = true;
    boolean invokeWorkaroundWhileBug2IsOpen = true;
    try {
        if (BzChecker.getInstance().isBugOpen(bugId1)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId1).toString() + " Bugzilla " + bugId1 + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId1 + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId1);
        } else {
            invokeWorkaroundWhileBug1IsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    try {
        if (BzChecker.getInstance().isBugOpen(bugId2)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId2).toString() + " Bugzilla " + bugId2 + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId2 + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId2);
        } else {
            invokeWorkaroundWhileBug2IsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    if (invokeWorkaroundWhileBug1IsOpen || invokeWorkaroundWhileBug2IsOpen) {
        log.warning("Skipping assertion of stopped and disabled services while bug '" + bugId1 + "' OR '" + bugId2 + "' is open.");
        ;
    } else // END OF WORKAROUND
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.18.2-1")) {
        String stoppingServicesMsg = "Stopping and disabling legacy services...";
        Assert.assertTrue(sshCommandResult.getStdout().contains(stoppingServicesMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + stoppingServicesMsg);
        // taken from https://bugzilla.redhat.com/show_bug.cgi?id=1185914#c0
        if (clienttasks.isPackageInstalled("osad")) {
            if (Integer.valueOf(clienttasks.redhatReleaseX) >= 7) {
                // [root@jsefler-rhel7 ~]# systemctl is-enabled osad.service
                // osad.service is not a native service, redirecting to /sbin/chkconfig.
                // Executing /sbin/chkconfig osad --level=5
                // disabled
                // [root@jsefler-rhel7 ~]# echo $?
                // 1
                SSHCommandResult sshSystemctlIsEnabledCommandResult = client.runCommandAndWait("systemctl is-enabled osad.service");
                Assert.assertEquals(sshSystemctlIsEnabledCommandResult.getStdout().trim(), "disabled", "Expected stdout for systemctl is-enabled osad.service");
                Assert.assertEquals(sshSystemctlIsEnabledCommandResult.getExitCode(), Integer.valueOf(1), "Expected exitCode for systemctl is-enabled osad.service");
                // [root@jsefler-rhel7 ~]# systemctl is-active osad.service
                // unknown
                // [root@jsefler-rhel7 ~]# echo $?
                // 3
                SSHCommandResult sshSystemctlIsActiveCommandResult = client.runCommandAndWait("systemctl is-active osad.service");
                Assert.assertEquals(sshSystemctlIsActiveCommandResult.getStdout().trim(), "unknown", "Expected stdout for systemctl is-active osad.service");
                Assert.assertEquals(sshSystemctlIsActiveCommandResult.getExitCode(), Integer.valueOf(3), "Expected exitCode for systemctl is-active osad.service");
            } else {
                // [root@jsefler-rhel6 ~]# service osad status
                // osad is stopped
                // [root@jsefler-rhel6 ~]# echo $?
                // 3
                SSHCommandResult sshServiceCommandResult = client.runCommandAndWait("service osad status");
                Assert.assertEquals(sshServiceCommandResult.getExitCode(), Integer.valueOf(3), "Expected exitCode for service osad status");
                Assert.assertEquals(sshServiceCommandResult.getStdout().trim(), "osad is stopped", "Expected stdout for service osad status");
                // [root@jsefler-rhel6 ~]# chkconfig --list osad
                // osad           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
                SSHCommandResult sshChkconfigCommandResult = client.runCommandAndWait("chkconfig --list osad");
                Assert.assertEquals(sshChkconfigCommandResult.getExitCode(), Integer.valueOf(0), "Expected exitCode for chkconfig --list osad");
                String sshChkconfigRegex = "osad\\s+0:off\\s+1:off\\s+2:off\\s+3:off\\s+4:off\\s+5:off\\s+6:off";
                Assert.assertTrue(sshChkconfigCommandResult.getStdout().trim().matches(sshChkconfigRegex), "Expected stdout for chkconfig --list osad to match regex '" + sshChkconfigRegex + "'.");
            }
        }
        if (clienttasks.isPackageInstalled("rhnsd")) {
            if (Integer.valueOf(clienttasks.redhatReleaseX) >= 7) {
                // [root@jsefler-rhel7 ~]# systemctl is-enabled rhnsd.service
                // rhnsd.service is not a native service, redirecting to /sbin/chkconfig.
                // Executing /sbin/chkconfig rhnsd --level=5
                // disabled
                // [root@jsefler-rhel7 ~]# echo $?
                // 1
                SSHCommandResult sshSystemctlIsEnabledCommandResult = client.runCommandAndWait("systemctl is-enabled rhnsd.service");
                Assert.assertEquals(sshSystemctlIsEnabledCommandResult.getStdout().trim(), "disabled", "Expected stdout for systemctl is-enabled rhnsd.service");
                Assert.assertEquals(sshSystemctlIsEnabledCommandResult.getExitCode(), Integer.valueOf(1), "Expected exitCode for systemctl is-enabled rhnsd.service");
                // [root@jsefler-rhel7 ~]# chkconfig --list rhnsd
                // 
                // Note: This output shows SysV services only and does not include native
                // systemd services. SysV configuration data might be overridden by native
                // systemd configuration.
                // 
                // If you want to list systemd services use 'systemctl list-unit-files'.
                // To see services enabled on particular target use
                // 'systemctl list-dependencies [target]'.
                // 
                // rhnsd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
                SSHCommandResult sshChkconfigCommandResult = client.runCommandAndWait("chkconfig --list rhnsd");
                Assert.assertEquals(sshChkconfigCommandResult.getExitCode(), Integer.valueOf(0), "Expected exitCode for chkconfig --list rhnsd");
                String sshChkconfigRegex = "rhnsd\\s+0:off\\s+1:off\\s+2:off\\s+3:off\\s+4:off\\s+5:off\\s+6:off";
                Assert.assertTrue(sshChkconfigCommandResult.getStdout().trim().matches(sshChkconfigRegex), "Expected stdout for chkconfig --list rhnsd to match regex '" + sshChkconfigRegex + "'.");
                // [root@jsefler-rhel7 ~]# systemctl is-active rhnsd.service
                // unknown
                // [root@jsefler-rhel7 ~]# echo $?
                // 3
                SSHCommandResult sshSystemctlIsActiveCommandResult = client.runCommandAndWait("systemctl is-active rhnsd.service");
                Assert.assertEquals(sshSystemctlIsActiveCommandResult.getStdout().trim(), "unknown", "Expected stdout for systemctl is-active rhnsd.service");
                Assert.assertEquals(sshSystemctlIsActiveCommandResult.getExitCode(), Integer.valueOf(3), "Expected exitCode for systemctl is-active rhnsd.service");
            } else {
                // [root@jsefler-rhel6 ~]# service rhnsd status
                // [root@jsefler-rhel6 ~]# echo $?
                // 6
                SSHCommandResult sshServiceCommandResult = client.runCommandAndWait("service rhnsd status");
                Assert.assertEquals(sshServiceCommandResult.getExitCode(), Integer.valueOf(6), "Expected exitCode for service rhnsd status - because /etc/init.d/rhnsd is programmed to exit 6 when there is no systemid file");
                Assert.assertEquals(sshServiceCommandResult.getStdout().trim(), "", "Expected stdout for service rhnsd status");
                // [root@jsefler-rhel6 ~]# chkconfig --list rhnsd
                // rhnsd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off
                SSHCommandResult sshChkconfigCommandResult = client.runCommandAndWait("chkconfig --list rhnsd");
                Assert.assertEquals(sshChkconfigCommandResult.getExitCode(), Integer.valueOf(0), "Expected exitCode for chkconfig --list rhnsd");
                String sshChkconfigRegex = "rhnsd\\s+0:off\\s+1:off\\s+2:off\\s+3:off\\s+4:off\\s+5:off\\s+6:off";
                Assert.assertTrue(sshChkconfigCommandResult.getStdout().trim().matches(sshChkconfigRegex), "Expected stdout for chkconfig --list rhnsd to match regex '" + sshChkconfigRegex + "'.");
            }
        }
        // assert that no FAILED nor Usage errors occurred
        // Bug 1390341 - rhn-migrate-classic-to-rhsm is failing to stop and disable services
        Assert.assertTrue(!sshCommandResult.getStdout().contains("FAILED"), "Should not encounter a FAILED message when Stopping and disabling legacy services");
        // Bug 1390341 - rhn-migrate-classic-to-rhsm is failing to stop and disable services
        Assert.assertTrue(!sshCommandResult.getStdout().contains("Usage"), "Should not encounter a Usage error when Stopping and disabling legacy services");
    }
    String removingPackagesMsg = "Removing legacy packages...";
    if (options.contains("--remove-rhn-packages")) {
        Assert.assertTrue(sshCommandResult.getStdout().contains(removingPackagesMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + removingPackagesMsg);
    } else {
        Assert.assertTrue(!sshCommandResult.getStdout().contains(removingPackagesMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' does not contain message: " + removingPackagesMsg);
    }
    // assert that when --serverurl is specified, its hostname:port/prefix are preserved into rhsm.conf
    if (options.contains("--serverurl") || options.contains("--destination-url")) {
        // comparing to original configuration values because these are the ones I am using in the dataProvider
        Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "server", "hostname"), originalServerHostname, "The value of the [server]hostname newly configured in " + clienttasks.rhsmConfFile + " was extracted from the --serverurl option specified in rhn-migrated-classic-to-rhsm options '" + options + "'.");
        Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "server", "port"), originalServerPort, "The value of the [server]port newly configured in " + clienttasks.rhsmConfFile + " was extracted from the --serverurl option specified in rhn-migrated-classic-to-rhsm options '" + options + "'.");
        Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "server", "prefix"), originalServerPrefix, "The value of the [server]prefix newly configured in " + clienttasks.rhsmConfFile + " was extracted from the --serverurl option specified in rhn-migrated-classic-to-rhsm options '" + options + "'.");
    }
    // assert that we are newly registered using rhsm
    clienttasks.identity(null, null, null, null, null, null, null, null);
    Assert.assertNotNull(clienttasks.getCurrentConsumerId(), "The existance of a consumer cert indicates that the system is currently registered using RHSM.");
    expectedMsg = String.format("System '%s' successfully registered to Red Hat Subscription Management.", clienttasks.hostname);
    // changed by commit fad3de89
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1"))
        expectedMsg = String.format("System '%s' successfully registered.", clienttasks.hostname);
    // TEMPORARY WORKAROUND FOR BUG
    // Bug 1451003 - subscription-manager identity reports redundant UUID info in the name field
    String bugId = "1451003";
    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) {
        log.warning("Skipping assertion that Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
    } else
        // END OF WORKAROUND
        Assert.assertTrue(sshCommandResult.getStdout().contains(expectedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
    // assert the the expected service level was set as a preference on the registered consumer
    if (serviceLevelExpected != null) {
        String serviceLevel = clienttasks.getCurrentServiceLevel();
        Assert.assertTrue(serviceLevelExpected.equalsIgnoreCase(serviceLevel), "Regardless of case, the serviceLevel requested during migration (or possibly the org's defaultServiceLevel) was set as the system's service level preference (serviceLevelExpected='" + serviceLevelExpected + "').");
    }
    // assert that when --no-auto is specified, no entitlements were granted during the rhsm registration
    String autosubscribeAttemptedMsg = "Attempting to auto-subscribe to appropriate subscriptions ...";
    // changed by bug 876294
    autosubscribeAttemptedMsg = "Attempting to auto-attach to appropriate subscriptions ...";
    // changed by subscription-manager commit 1fba5696
    autosubscribeAttemptedMsg = "Attempting to auto-attach to appropriate subscriptions...";
    // commit fad3de89779f2217e788b3564ef5dca7f85914fb removed the "Attempting to auto-attach to appropriate subscriptions..." feedback
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1"))
        autosubscribeAttemptedMsg = "Installed Product Current Status:";
    String autosubscribeFailedMsg = "Unable to auto-subscribe.  Do your existing subscriptions match the products installed on this system?";
    // changed by bug 876294
    autosubscribeFailedMsg = "Unable to auto-attach.  Do your existing subscriptions match the products installed on this system?";
    // commit fad3de89779f2217e788b3564ef5dca7f85914fb	// matches functionality from bug 864195
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1"))
        autosubscribeFailedMsg = "Unable to find available subscriptions for all your installed products.";
    // OLD	if (options.contains("-n")) { // -n, --no-auto   Do not autosubscribe when registering with subscription-manager
    if (options.contains("-n") && !options.contains("--activation-key")) {
        // -n, --no-auto   Do not autosubscribe when registering with subscription-manager
        // assert that autosubscribe was NOT attempted
        Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeAttemptedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' does NOT contain message: " + autosubscribeAttemptedMsg);
        Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' does NOT contain message: " + autosubscribeFailedMsg);
        // assert that we are NOT registered using rhsm
        /* THIS ASSERTION IS WRONG! DON'T DO IT!  BUG 849644
			clienttasks.identity_(null, null, null, null, null, null, null);
			Assert.assertNull(clienttasks.getCurrentConsumerCert(),"We should NOT be registered to RHSM after a call to "+rhnMigrateTool+" with options "+options+".");
			*/
        // assert that we are NOT consuming any entitlements
        Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "We should NOT be consuming any RHSM entitlements after call to " + rhnMigrateTool + " with options (" + options + ") that indicate no autosubscribe.");
    // OLD	} else {
    }
    if (!options.contains("-n") && !options.contains("--activation-key")) {
        // assert that autosubscribe was attempted
        Assert.assertTrue(sshCommandResult.getStdout().contains(autosubscribeAttemptedMsg), "Stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + autosubscribeAttemptedMsg);
        // assert that the migrated productCert corresponding to the base channel has been autosubscribed by checking the status on the installedProduct
        // FIXME This assertion is wrong when there are no available subscriptions that provide for the migrated product certs' providesTags; however since we register as qa@redhat.com, I think we have access to all base rhel subscriptions
        // FIXME if a service-level is provided that is not available, then this product may NOT be subscribed
        /* DECIDED NOT TO FIXME SINCE THIS ASSERTION IS THE JOB OF DEDICATED AUTOSUBSCRIBE TESTS IN SubscribeTests.java
			InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToProductCert(clienttasks.getProductCertFromProductCertFile(new File(clienttasks.productCertDir+"/"+getPemFileNameFromProductCertFilename(channelsToProductCertFilenamesMap.get(rhnBaseChannel)))));
			Assert.assertEquals(installedProduct.status, "Subscribed","The migrated product cert corresponding to the RHN Classic base channel '"+rhnBaseChannel+"' was autosubscribed: "+installedProduct);
			*/
        // assert that autosubscribe feedback was a success (or not)
        List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
        if (consumedProductSubscriptions.isEmpty()) {
            Assert.assertTrue(sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "Assuming the base RHN channel has been migrated, but no entitlements have been granted, stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + autosubscribeFailedMsg);
        }
        /*else { // 06/15/2015: This else block is wrong since an RHN Channel could have been successfully migrated, but there is no subscription available to cover it.  Replacing it with a call to get the compliance status
				Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "When autosubscribe is successful and entitlements have been granted, stdout from call to '"+rhnMigrateTool+" "+options+"' does NOT contain message: "+autosubscribeFailedMsg);				
			} */
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
            // post commit 7957b8df95c575e6e8713c2f1a0f8f754e32aed3 bug 1119688
            SSHCommandResult statusResult = clienttasks.status(null, null, null, null, null);
            if (statusResult.getStdout().contains("Overall Status: Invalid")) {
                Assert.assertTrue(sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "Since the subscription-manager overall status appears Invalid, the most likely reason is because at least one of the migrated products could not be auto-subscribed.  Therefore stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + autosubscribeFailedMsg);
            } else {
                // Note: "Overall Status: Insufficient" is possible and likely when the auto-subscribed subscription pool is Temporary
                Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "Since the subscription-manager overall status does not appear Invalid (overall status of Current or Insufficient are likely), all of the migrated products should have been auto-subscribed.  Therefore stdout from call to '" + rhnMigrateTool + " " + options + "' does NOT contain message: " + autosubscribeFailedMsg);
            }
        }
        // assert that when no --servicelevel is specified, then no service level preference will be set on the registered consumer
        if (!options.contains("-s ") && !options.contains("--servicelevel") && !options.contains("--service-level") && (serviceLevelExpected == null || serviceLevelExpected.isEmpty())) {
            // assert no service level preference was set
            Assert.assertEquals(clienttasks.getCurrentServiceLevel(), "", "No servicelevel preference should be set on the consumer when no service level was requested.");
        }
        // assert the service levels consumed from autosubscribe match the requested serviceLevel
        if (serviceLevelExpected != null && !serviceLevelExpected.isEmpty()) {
            // when a valid servicelevel was either specified or chosen
            expectedMsg = String.format("Service level set to: %s", serviceLevelExpected);
            Assert.assertTrue(sshCommandResult.getStdout().toUpperCase().contains(expectedMsg.toUpperCase()), "Regardless of service level case, the stdout from call to '" + rhnMigrateTool + " " + options + "' contains message: " + expectedMsg);
            for (ProductSubscription productSubscription : consumedProductSubscriptions) {
                Assert.assertNotNull(productSubscription.serviceLevel, "When migrating from RHN Classic with a specified service level '" + serviceLevelExpected + "', this auto consumed product subscription's service level should not be null: " + productSubscription);
                if (sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
                    log.info("Exempt service levels: " + sm_exemptServiceLevelsInUpperCase);
                    Assert.assertTrue(sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase()), "This auto consumed product subscription's service level is among the exempt service levels: " + productSubscription);
                } else {
                    Assert.assertTrue(productSubscription.serviceLevel.equalsIgnoreCase(serviceLevelExpected), "When migrating from RHN Classic with a specified service level '" + serviceLevelExpected + "', this auto consumed product subscription's service level should match: " + productSubscription);
                }
            }
        }
    }
    if (options.contains("--activation-key")) {
        // assert that autosubscribe was NOT attempted
        // Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeAttemptedMsg), "Stdout from call to '"+rhnMigrateTool+" "+options+"' does NOT contain message: "+autosubscribeAttemptedMsg);	// not a fair assertion since autosubscribeAttemptedMsg was set to "Installed Product Current Status:"
        // Assert.assertTrue(!sshCommandResult.getStdout().contains(autosubscribeFailedMsg), "Stdout from call to '"+rhnMigrateTool+" "+options+"' does NOT contain message: "+autosubscribeFailedMsg);	// also not a fair assertion since autosubscribeFailedMsg was set to "Unable to find available subscriptions for all your installed products."
        Assert.assertTrue(!sshCommandResult.getStdout().toLowerCase().contains("auto-attach"), "Stdout from an attempt to migrate with options (" + options + ") which include an activation key should make no reference to 'auto-attach'");
        Assert.assertTrue(!sshCommandResult.getStdout().toLowerCase().contains("auto-subscribe"), "Stdout from an attempt to migrate with options (" + options + ") which include an activation key should make no reference to 'auto-subscribe'");
        // assert that we are consuming entitlements, TODO but this is really dependent on the activation key
        Assert.assertTrue(!clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "We should be consuming some entitlements after a call to " + rhnMigrateTool + " with options (" + options + ").  This assumes the activation key contained one or more pools.");
    // TODO When an activation key is used, all of the consumed subscriptions should have come from the activation key.
    // It would be best to make these assertion in the test that calls this function.
    }
    // assert that the rhnplugin has been disabled
    Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForRhn, "enabled"), "0", "The enabled yum plugin configuration for RHN.");
    // assert that productid.js is updated with productid mappings for all of the rhnChannelsConsumed; coverage for Bug 972883 - rhn-migrate-classic-to-rhsm tool neglects to populate /var/lib/rhsm/productid.js
    client.runCommandAndWait("cat " + clienttasks.productIdJsonFile);
    for (String rhnChannelConsumed : rhnChannelsConsumed) {
        if (channelsToProductCertFilenamesMap.containsKey(rhnChannelConsumed)) {
            String productId = MigrationDataTests.getProductIdFromProductCertFilename(channelsToProductCertFilenamesMap.get(rhnChannelConsumed));
            // special case (see RhnMigrateClassicToRhsm_Rhel5ClientDesktopVersusWorkstation_Test)
            if (clienttasks.releasever.equals("5Client")) {
                String productIdForDesktop = "68";
                String productIdForWorkstation = "71";
                if (productId.equals(productIdForDesktop)) {
                    log.info("Encountered a special case for migration of a 5Client system from RHN Classic to RHSM...");
                    log.info("Red Hat Enterprise Linux Desktop (productId=68) corresponds to the base RHN Channel (rhel-ARCH-client-5) for a 5Client system where ARCH=i386,x86_64.");
                    log.info("Red Hat Enterprise Linux Workstation (productId=71) corresponds to child RHN Channel (rhel-ARCH-client-workstation-5) for a 5Client system where ARCH=i386,x86_64.");
                    log.info("After migrating from RHN Classic to RHSM, these two product certs should not be installed at the same time; Workstation should prevail.");
                    if (productIdRepoMapAfterMigration.containsKey(productIdForWorkstation)) {
                        Assert.assertTrue(!productIdRepoMapAfterMigration.containsKey(productId), "The '" + clienttasks.productIdJsonFile + "' database should NOT contain an entry for productId '" + productId + "' which was migrated for consumption of Classic RHN Channel '" + rhnChannelConsumed + "' when Workstation channels for product '" + productIdForWorkstation + "' have also been migrated (Workstation wins).");
                        continue;
                    }
                }
            }
            if (productId.equalsIgnoreCase("none")) {
                Assert.assertTrue(!productIdRepoMapAfterMigration.containsKey(productId), "The '" + clienttasks.productIdJsonFile + "' database does NOT contain an entry for productId '" + productId + "' after migration while consuming Classic RHN Channel '" + rhnChannelConsumed + "'.");
            } else {
                Assert.assertTrue(productIdRepoMapAfterMigration.containsKey(productId), "The '" + clienttasks.productIdJsonFile + "' database contains an entry for productId '" + productId + "' which was migrated for consumption of Classic RHN Channel '" + rhnChannelConsumed + "'.");
                Assert.assertTrue(productIdRepoMapAfterMigration.get(productId).contains(rhnChannelConsumed), "The '" + clienttasks.productIdJsonFile + "' database entry for productId '" + productId + "' contains Classic RHN Channel/Repo '" + rhnChannelConsumed + "'.");
            }
        }
    }
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) ProductCert(rhsm.data.ProductCert) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) List(java.util.List) 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 28 with ProductCert

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

the class PluginTests method testPluginsListWithEnabledProductIdRemoveTestPlugin.

// TODO ProductIdRemoveTestPlugin Tests ***************************************************
// CURRENTLY BLOCKED BY BUGZILLA 922882
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL7-55178" }, 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 = "enable ProductIdRemoveTestPlugin and assert the plugins list reports enablement", groups = { "Tier1Tests", "blockedByBug-922882" }, priority = 710, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testPluginsListWithEnabledProductIdRemoveTestPlugin() {
    // Red Hat Enterprise Linux High Availability (for RHEL Server)
    String haProductId = "83";
    // Red Hat Enterprise Linux High Availability (for IBM z Systems)
    if (clienttasks.arch.startsWith("s390"))
        haProductId = "300";
    // TEMPORARY WORKAROUND FOR BUG
    String bugId = "922882";
    boolean invokeWorkaroundWhileBugIsOpen = true;
    // RFE Bug 922882 was CLOSED NOTABUG and will be re-opened when actually needed.  However, we still need to invoke this workaround to remove the ccs package from the prior test
    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) {
        // remove the HA package that was installed by prior test verifyEnabledProductIdInstallTestPluginHooksAreCalled_Test
        List<String> haPackages = HighAvailabilityTests.getHighAvailabilityPackages(clienttasks.redhatReleaseXY, clienttasks.arch);
        if (!haPackages.isEmpty() && clienttasks.isPackageInstalled(haPackages.get(0))) {
            // yum -y remove ccs
            clienttasks.yumRemovePackage(haPackages.get(0));
        }
        // remove the HA product cert too
        InstalledProduct haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentlyInstalledProducts());
        if (haInstalledProduct != null) {
            ProductCert haInstalledProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentProductCerts());
            log.warning("Manually removing installed High Availability product cert and restoring '" + clienttasks.productIdJsonFile + "' (you are probably running a RHEL5 client)...");
            client.runCommandAndWait("rm -f " + haInstalledProductCert.file.getPath());
            restoreProductIdJsonFileAfterClass();
            haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentlyInstalledProducts());
        }
        Assert.assertNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should NOT be installed after successful removal of all High Availability packages.");
        throw new SkipException("Skipping test while bug '" + bugId + "' is not implemented.");
    }
    // END OF WORKAROUND
    Assert.fail("This test will be implemented after RFE bug 922882 is implemented.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 29 with ProductCert

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

the class ContentTests method getEnabledRepoAndSubscriptionPoolDataAsListOfLists.

protected List<List<Object>> getEnabledRepoAndSubscriptionPoolDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    if (sm_clientUsername == null)
        return ll;
    if (sm_clientPassword == null)
        return ll;
    // get the currently installed product certs to be used when checking for conditional content tagging
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    // assure we are freshly registered and process all available subscription pools
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        // /*debugTesting*/if (!pool.productId.equals("RH2501844")) continue;
        String quantity = null;
        // when the Suggested quantity is 0, let's specify a quantity to avoid Stdout: Quantity '1' is not a multiple of instance multiplier '2'
        if (pool.suggested != null)
            if (pool.suggested < 1)
                quantity = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "instance_multiplier");
        /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
        File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool, quantity);
        Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
        EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (!contentNamespace.type.equalsIgnoreCase("yum"))
                continue;
            if (contentNamespace.enabled && clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
                String repoLabel = contentNamespace.label;
                // String availableGroup, String installedGroup, String repoLabel, SubscriptionPool pool, String quantity
                ll.add(Arrays.asList(new Object[] { repoLabel, pool, quantity }));
            }
        }
        // minimize the number of dataProvided rows (useful during automated testcase development)
        if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
            break;
    }
    // no reason to remain subscribed to any subscriptions
    clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    return ll;
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) ProductCert(rhsm.data.ProductCert) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File)

Example 30 with ProductCert

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

the class ContentTests method testEnableDisableManageReposAndVerifyContentAvailable.

// Test methods ***********************************************************************
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-25987", "RHEL7-51485" }, 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 = "Tier2")
@Test(description = "subscription-manager Yum plugin: enable/disable", groups = { "Tier2Tests", "FipsTests", "EnableDisableManageReposAndVerifyContentAvailable_Test", "blockedByBug-804227", "blockedByBug-871146", "blockedByBug-905546", "blockedByBug-1017866" }, // dataProvider="getAvailableSubscriptionPoolsData",	// very thorough, but takes too long to execute and rarely finds more bugs
dataProvider = "getRandomSubsetOfAvailableSubscriptionPoolsData", enabled = true)
@ImplementsNitrateTest(caseId = 41696, fromPlan = 2479)
public void testEnableDisableManageReposAndVerifyContentAvailable(SubscriptionPool pool) throws JSONException, Exception {
    // get the currently installed product certs to be used when checking for conditional content tagging
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    log.info("Before beginning this test, we will stop the rhsmcertd so that it does not interfere with this test and make sure we are not subscribed...");
    clienttasks.stop_rhsmcertd();
    clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    // Enable rhsm manage_repos configuration
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "1" });
    log.info("Subscribe to the pool and start testing that yum repolist reports the expected repo id/labels...");
    File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
    Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    // 1. Run a 'yum repolist' and get a list of all of the available repositories corresponding to your entitled products
    // 1. Repolist contains repositories corresponding to your entitled products
    ArrayList<String> repolist = clienttasks.getYumRepolist("enabled");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with the manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
            continue;
        }
        if (contentNamespace.enabled) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist enabled includes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes disabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        }
    }
    repolist = clienttasks.getYumRepolist("disabled");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist disabled excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
            continue;
        }
        if (contentNamespace.enabled) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist disabled excludes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist disabled includes disabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        }
    }
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist all includes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
        }
    }
    log.info("Unsubscribe from the pool and verify that yum repolist no longer reports the expected repo id/labels...");
    clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber);
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having unsubscribed from Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
    }
    // Disable rhsm manage_repos configuration
    log.info("Now we will disable the rhsm manage_repos configuration with enabled=0..");
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "0" });
    log.info("Again let's subscribe to the same pool and verify that yum repolist does NOT report any of the entitled repo id/labels since the manage_repos has been disabled...");
    entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
    Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
    entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    // 2. Run a 'yum repolist' and get a list of all of the available repositories corresponding to your entitled products
    // 2. Repolist does not contain repositories corresponding to your entitled products
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with the manage_repos configuration disabled.");
    }
    log.info("Now we will enable manage_repos and expect the repo list to be updated");
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "1" });
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist all now includes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' followed by manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all still excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' followed by manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
        }
    }
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

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