Search in sources :

Example 11 with BlockedByBzBug

use of com.redhat.qe.auto.bugzilla.BlockedByBzBug in project rhsm-qe by RedHatQE.

the class MigrationTests method getRhnMigrateClassicToRhsmDataAsListOfLists.

public List<List<Object>> getRhnMigrateClassicToRhsmDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    if (sm_rhnUsername.equals("")) {
        log.warning("RHN Username was not provided.");
        return ll;
    }
    if (sm_rhnPassword.equals("")) {
        log.warning("RHN Password was not provided.");
        return ll;
    }
    // 50;	// used to break down rhnAvailableChildChannels into smaller sub-lists to avoid bugs 818786 881952
    int rhnChildChannelSubSize = 40;
    // /*debugTesting*/ rhnChildChannelSubSize = 0;
    List<String> rhnAvailableNonBetaChildChannels = new ArrayList<String>();
    for (String rhnChannel : rhnAvailableChildChannels) if (!rhnChannel.contains("-beta"))
        rhnAvailableNonBetaChildChannels.add(rhnChannel);
    // when we are migrating away from RHN Classic to a non-hosted candlepin server, determine good credentials for rhsm registration
    // default
    String rhsmUsername = sm_clientUsername, rhsmPassword = sm_clientPassword, rhsmOrg = sm_clientOrg;
    if (clienttasks.register_(sm_rhnUsername, sm_rhnPassword, null, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null).getExitCode().equals(new Integer(0))) {
        // try sm_rhnUsername sm_rhnPassword...
        rhsmUsername = sm_rhnUsername;
        rhsmPassword = sm_rhnPassword;
        rhsmOrg = null;
    }
    // predict the valid service levels that will be available to the migrated consumer
    String consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(rhsmUsername, rhsmPassword, rhsmOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null));
    String orgKey = CandlepinTasks.getOwnerKeyOfConsumerId(rhsmUsername, rhsmPassword, sm_serverUrl, consumerId);
    List<String> rhsmServiceLevels = CandlepinTasks.getServiceLevelsForOrgKey(rhsmUsername, rhsmPassword, sm_serverUrl, orgKey);
    clienttasks.unregister(null, null, null, null);
    // predict the expected service level from the defaultServiceLevel on the Org
    JSONObject jsonOrg = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(rhsmUsername, rhsmPassword, sm_serverUrl, "/owners/" + orgKey));
    String defaultServiceLevel = (jsonOrg.get("defaultServiceLevel").equals(JSONObject.NULL)) ? "" : jsonOrg.getString("defaultServiceLevel");
    // Note: To avoid redundant prompting for credentials, rhn-migrate-classic-to-rhsm will NOT prompt for rhsm Username/Password/Org when the rhsm server matches subscription\.rhn\.(.+\.)*redhat\.com
    // This causes a testing problem when migrating from a satellite server to rhsm hosted - adding a valid --serverurl to the options is a good workaround
    String rhsmServerUrlOption = "";
    if (!doesStringContainMatches(sm_rhnHostname, "(rhn|rhsm)\\.(.+\\.)*redhat\\.com")) {
        // indicates that we are migrating from a non-hosted rhn server - as opposed to rhn.code.stage.redhat.com (stage) or rhn.redhat.com (production)
        if (doesStringContainMatches(sm_serverHostname, "subscription\\.(rhn|rhsm)\\.(.+\\.)*redhat\\.com")) {
            // force a valid --serverurl
            rhsmServerUrlOption = " --serverurl=" + "https://" + originalServerHostname + ":" + originalServerPort + originalServerPrefix;
        }
    } else {
        // we are migrating from rhn hosted...
        if (doesStringContainMatches(sm_serverHostname, "subscription\\.(rhn|rhsm)\\.(.+\\.)*redhat\\.com")) {
            // so don't pass them to the rhn-migrate-classic-to-rhsm.tcl script or else you won't get the expected rhn-migrate-classic-to-rhsm exit code because the tcl script will be prematurely exited without getting the actual exit code from rhn-migrate-classic-to-rhsm.
            if (sm_rhnUsername.equals(rhsmUsername)) {
                rhsmUsername = null;
                rhsmPassword = null;
                rhsmOrg = null;
            }
        }
    }
    // create some variations on a valid serverUrl to test the --serverurl option
    List<String> rhsmServerUrls = new ArrayList<String>();
    if (rhsmServerUrlOption.isEmpty()) {
        // skip testing variations on a valid serverUrl when a valid rhsmServerUrlOption is already being included in all data provided rows
        if (isHostnameHosted(originalServerHostname)) {
            rhsmServerUrls.add(originalServerHostname);
            rhsmServerUrls.add("https://" + originalServerHostname);
            rhsmServerUrls.add("https://" + originalServerHostname + originalServerPrefix);
            rhsmServerUrls.add("https://" + originalServerHostname + ":" + originalServerPort);
            rhsmServerUrls.add("https://" + originalServerHostname + ":" + originalServerPort + originalServerPrefix);
        } else {
            // Note: only a fully qualified server url will work for a non-hosted hostname because otherwise the (missing port/prefix defaults to 443/subscription) results will end up with: Unable to connect to certificate server: (111, 'Connection refused'). See /var/log/rhsm/rhsm.log for more details.
            rhsmServerUrls.add(originalServerHostname + ":" + originalServerPort + originalServerPrefix);
            rhsmServerUrls.add("https://" + originalServerHostname + ":" + originalServerPort + originalServerPrefix);
        }
    }
    // Object bugzilla, String rhnUsername, String rhnPassword, String rhnServer, List<String> rhnChannelsToAdd, String options, String rhsmUsername, String rhsmPassword, String rhsmOrg, Integer serviceLevelIndex, String serviceLevelExpected
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("849644"), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "-n" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    // ll.add(Arrays.asList(new Object[]{new BlockedByBzBug("849644"),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnAvailableChildChannels,		"-n"+rhsmServerUrlOption,		sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	null,	defaultServiceLevel}));
    /* 6/5/2014 although valid, all these rows take too long, replacing with a single row and a random subset of rhnAvailableChildChannels
		for (int i=0; i<rhnAvailableChildChannels.size(); i+=rhnChildChannelSubSize) {	// split rhnAvailableChildChannels into sub-lists of 50 channels to avoid bug 818786 - 502 Proxy Error traceback during large rhn-migrate-classic-to-rhsm
			List<String> rhnSubsetOfAvailableChildChannels = rhnAvailableChildChannels.subList(i,i+rhnChildChannelSubSize>rhnAvailableChildChannels.size()?rhnAvailableChildChannels.size():i+rhnChildChannelSubSize);
			ll.add(Arrays.asList(new Object[]{new BlockedByBzBug(new String[]{"849644","980209"}),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnSubsetOfAvailableChildChannels,	"-n -f"+rhsmServerUrlOption,	sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	null,	defaultServiceLevel}));		
			List<String> rhnNonBetaSubsetOfAvailableChildChannels = new ArrayList<String>(); for (String rhnChannel: rhnSubsetOfAvailableChildChannels) if (!rhnChannel.contains("-beta")) rhnNonBetaSubsetOfAvailableChildChannels.add(rhnChannel);
			ll.add(Arrays.asList(new Object[]{new BlockedByBzBug(new String[]{"849644","980209"}),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnNonBetaSubsetOfAvailableChildChannels,	"-n -f"+rhsmServerUrlOption,	sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	null,	defaultServiceLevel}));		
		}
		*/
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "849644", "980209" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableChildChannels, rhnChildChannelSubSize), "-n -f" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "849644", "980209" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableNonBetaChildChannels, rhnChildChannelSubSize), "-n -f" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977321"), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    // ll.add(Arrays.asList(new Object[]{new BlockedByBzBug("977321"),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnAvailableChildChannels,		""+rhsmServerUrlOption,			sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	/*areAllChannelsMapped(rhnAvailableChildChannels)?noServiceLevelIndex:*/null,	defaultServiceLevel}));
    /* 6/5/2014 although valid, all these rows take too long, replacing with a single row and a random subset of rhnAvailableChildChannels
		for (int i=0; i<rhnAvailableChildChannels.size(); i+=rhnChildChannelSubSize) {	// split rhnAvailableChildChannels into sub-lists of 50 channels to avoid bug 818786 - 502 Proxy Error traceback during large rhn-migrate-classic-to-rhsm
			List<String> rhnSubsetOfAvailableChildChannels = rhnAvailableChildChannels.subList(i,i+rhnChildChannelSubSize>rhnAvailableChildChannels.size()?rhnAvailableChildChannels.size():i+rhnChildChannelSubSize);
			ll.add(Arrays.asList(new Object[]{new BlockedByBzBug("977321"),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnSubsetOfAvailableChildChannels,	"-f"+rhsmServerUrlOption,	sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	null,	defaultServiceLevel}));		
			List<String> rhnNonBetaSubsetOfAvailableChildChannels = new ArrayList<String>(); for (String rhnChannel: rhnSubsetOfAvailableChildChannels) if (!rhnChannel.contains("-beta")) rhnNonBetaSubsetOfAvailableChildChannels.add(rhnChannel);
			ll.add(Arrays.asList(new Object[]{new BlockedByBzBug("977321"),	sm_rhnUsername,	sm_rhnPassword,	sm_rhnHostname,	rhnNonBetaSubsetOfAvailableChildChannels,	"-f"+rhsmServerUrlOption,	sm_rhnUsername,	sm_rhnPassword,	rhsmUsername,	rhsmPassword,	rhsmOrg,	null,	defaultServiceLevel}));		
		}
		*/
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977321"), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableChildChannels, rhnChildChannelSubSize), "-f" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug("977321"), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableNonBetaChildChannels, rhnChildChannelSubSize), "-f" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    // test variations of a valid serverUrl
    for (String serverUrl : rhsmServerUrls) {
        // randomly choose an available child channel just to add a little fun
        List<String> availableChildChannelList = rhnAvailableChildChannels.isEmpty() ? rhnAvailableChildChannels : Arrays.asList(rhnAvailableChildChannels.get(randomGenerator.nextInt(rhnAvailableChildChannels.size())));
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "977321", "1220493" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, availableChildChannelList, "-f --serverurl=" + serverUrl, sm_rhnUsername, sm_rhnPassword, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, defaultServiceLevel }));
    }
    // for (String serviceLevel : rhsmServiceLevels) {	// takes too long
    for (String serviceLevel : getRandomSubsetOfList(rhsmServiceLevels, 2)) {
        String options;
        options = String.format("--force --servicelevel=%s", serviceLevel);
        if (serviceLevel.contains(" "))
            options = String.format("--force --servicelevel \"%s\"", serviceLevel);
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "840169", "977321", "1149007" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableChildChannels, rhnChildChannelSubSize), options + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, serviceLevel }));
        options = String.format("-f -s %s", randomizeCaseOfCharactersInString(serviceLevel));
        if (serviceLevel.contains(" "))
            options = String.format("-f -s \"%s\"", randomizeCaseOfCharactersInString(serviceLevel));
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "840169", "841961", "977321", "1149007" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, getRandomSubsetOfList(rhnAvailableChildChannels, rhnChildChannelSubSize), options + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, null, serviceLevel }));
    }
    // attempt an unavailable servicelevel, then choose an available one from the index table
    if (!rhsmServiceLevels.isEmpty()) {
        int serviceLevelIndex = randomGenerator.nextInt(rhsmServiceLevels.size());
        String serviceLevel = rhsmServiceLevels.get(serviceLevelIndex);
        // since the interactive menu of available service-levels to choose from is indexed starting at 1.
        serviceLevelIndex++;
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "840169", "977321", "1149007" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "--force --servicelevel=UNAVAILABLE-SLA" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, serviceLevelIndex, serviceLevel }));
    }
    // attempt an unavailable servicelevel, then choose no service level
    if (!rhsmServiceLevels.isEmpty()) {
        // since the last item in the interactive menu of available service-levels is "#. No service level preference"
        int noServiceLevelIndex = rhsmServiceLevels.size() + 1;
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "840169", "977321", "1149007" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "--force --servicelevel=UNAVAILABLE-SLA" + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, rhsmOrg, noServiceLevelIndex, "" }));
    }
    // test --org as a command line option
    if (rhsmOrg != null) {
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "849644", "877331" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "--no-auto --org=" + rhsmOrg + rhsmServerUrlOption, sm_rhnUsername, sm_rhnPassword, rhsmUsername, rhsmPassword, null, null, defaultServiceLevel }));
    }
    // test --redhat-user --redhat-password --subscription-service-user --subscription-service-password as a command line option
    ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(new String[] { "912375", "1087603" }), sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), String.format("--redhat-user=%s --redhat-password=%s", sm_rhnUsername, sm_rhnPassword) + rhsmServerUrlOption, null, null, rhsmUsername, rhsmPassword, rhsmOrg, null, defaultServiceLevel }));
    // when rhsmOrg is not null, add bug BlockedByBzBug 849483 to all rows
    if (rhsmOrg != null)
        for (List<Object> l : ll) {
            // get the existing BlockedByBzBug
            BlockedByBzBug blockedByBzBug = (BlockedByBzBug) l.get(0);
            List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
            // 849483 - rhn-migrate-classic-to-rhsm fails to prompt for needed System Engine org credentials
            bugIds.add("849483");
            blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
            l.set(0, blockedByBzBug);
        }
    // when testing with child channels, add bug BlockedByBzBug 1075167 to affected rows
    for (List<Object> l : ll) {
        if (!((List<String>) (l.get(4))).isEmpty()) {
            // affected rows have a positive List<String> rhnChannelsToAdd
            // get the existing BlockedByBzBug
            BlockedByBzBug blockedByBzBug = (BlockedByBzBug) l.get(0);
            List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
            // Bug 1075167 - rhn-migrate-classic-to-rhsm throws Traceback KeyError: "Unknown feature: 'IDENTITY'"
            bugIds.add("1075167");
            blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
            l.set(0, blockedByBzBug);
        }
    }
    // when testing with --serverurl specified, add bug BlockedByBzBug 1131213 to affected rows
    for (List<Object> l : ll) {
        if (((String) (l.get(5))).contains("--serverurl")) {
            // affected rows contain --serverurl in the String options parameter
            // get the existing BlockedByBzBug
            BlockedByBzBug blockedByBzBug = (BlockedByBzBug) l.get(0);
            List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
            // Bug 1131213 - rhn-migrate-classic-to-rhsm throws gaierror: [Errno -2] Name or service not known
            bugIds.add("1131213");
            // Bug 1171808 - rhn-migrate-classic-to-rhsm throws gaierror: [Errno -2] Name or service not known
            bugIds.add("1171808");
            blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
            l.set(0, blockedByBzBug);
        }
    }
    // when testing with --serverurl/--destination-url specified, add bug BlockedByBzBug 1157761 to affected rows
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1")) {
        for (List<Object> l : ll) {
            if (((String) (l.get(5))).contains("--serverurl")) {
                // affected rows contain --serverurl in the String options parameter
                // get the existing BlockedByBzBug
                BlockedByBzBug blockedByBzBug = (BlockedByBzBug) l.get(0);
                List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
                // Bug 1157761 - broken --destination-url option in rhn-migrate-rhn-classic-to-rhsm
                bugIds.add("1157761");
                blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
                l.set(0, blockedByBzBug);
            }
        }
    }
    /* this update is also retrofitted in executeRhnMigrateClassicToRhsm */
    if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.1")) {
        for (List<Object> l : ll) {
            String options = (String) (l.get(5));
            if (options != null) {
                options = options.replace("--serverurl", "--destination-url");
                options = options.replace("--redhat-user", "--legacy-user");
                options = options.replace("--redhat-password", "--legacy-password");
                options = options.replace("--subscription-service-user", "--destination-user");
                options = options.replace("--subscription-service-password", "--destination-password");
                options = options.replace("--servicelevel", "--service-level");
            }
            if (clienttasks.isPackageVersion("subscription-manager-migration", ">=", "1.13.8-1")) {
                // 1157761: revert to "--servicelevel"
                if (options != null)
                    options = options.replace("--service-level", "--servicelevel");
            }
            l.set(5, options);
        }
    }
    return ll;
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Example 12 with BlockedByBzBug

use of com.redhat.qe.auto.bugzilla.BlockedByBzBug in project rhsm-qe by RedHatQE.

the class OstreeTests method getOstreeSubscriptionPoolsDataAsListOfLists.

protected List<List<Object>> getOstreeSubscriptionPoolsDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (!checkPackageVersionBeforeClass())
        return ll;
    // disable /etc/rhsm/pluginconf.d/ostree_content.OstreeContentPlugin.conf while this dataProvider runs
    clienttasks.updateConfFileParameter(ostreeContentPluginFile.getPath(), "enabled", "0");
    // register the host
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // attach each available pool in search of ones that provide content of type="ostree"
    List<SubscriptionPool> currentlyAvailableSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    // 37091 Product Name:   Awesome OS OStree Bits
    if (sm_serverType.equals(CandlepinType.standalone))
        currentlyAvailableSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools("37091", sm_serverUrl);
    // /*debugTesting DO NOT COMMIT THIS LINE UNCOMMENTED */ if (sm_serverType.equals(CandlepinType.hosted)) currentlyAvailableSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools("272", sm_serverUrl);	// 272 Product Name:   Red Hat Enterprise Linux Atomic Host Beta
    for (SubscriptionPool subscriptionPool : currentlyAvailableSubscriptionPools) {
        File serialPemFile = clienttasks.subscribeToSubscriptionPool_(subscriptionPool);
        EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(serialPemFile);
        if (ContentNamespace.findFirstInstanceWithMatchingFieldFromList("type", "ostree", entitlementCert.contentNamespaces) != null) {
            BlockedByBzBug blockedByBzBug = null;
            // Bug 1153366 - SKU RH00004 should not provide more than one Atomic product
            if (subscriptionPool.productId.equals("RH00004"))
                blockedByBzBug = new BlockedByBzBug("1153366");
            if (subscriptionPool.productId.equals("RH00003"))
                blockedByBzBug = new BlockedByBzBug("1153366");
            // Object bugzilla, SubscriptionPool osTreeSubscriptionPool
            ll.add(Arrays.asList(new Object[] { blockedByBzBug, subscriptionPool }));
        }
    }
    // remove all entitlements
    clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    // re-register the host to reduce the chance of a RateLimitExceededException
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // re-enable /etc/rhsm/pluginconf.d/ostree_content.OstreeContentPlugin.conf
    clienttasks.updateConfFileParameter(ostreeContentPluginFile.getPath(), "enabled", "1");
    return ll;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Example 13 with BlockedByBzBug

use of com.redhat.qe.auto.bugzilla.BlockedByBzBug in project rhsm-qe by RedHatQE.

the class PofilterTranslationTests method getCandlepinTranslationFilePofilterTestDataAsListOfLists.

protected List<List<Object>> getCandlepinTranslationFilePofilterTestDataAsListOfLists() {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    // Server side
    Map<File, List<Translation>> translationFileMapForCandlepin = buildTranslationFileMapForCandlepin();
    for (File translationFile : translationFileMapForCandlepin.keySet()) {
        for (String pofilterTest : pofilterTests) {
            Set<String> bugIds = new HashSet<String>();
            // skip candlepin accelerators tests
            if (pofilterTest.equals("accelerators")) {
                log.warning("Skipping the Candlepin accelerators pofilter tests because there are no gnome gui menu items generated from the candlepin msgids");
                continue;
            }
            // skip candlepin untranslated tests
            if (pofilterTest.equals("untranslated")) {
                log.warning("Skipping the Candlepin untranslated pofilter tests because candlepin master translations are a moving target and may never be 100% complete.  Moreover, candlepin releases do NOT follow the RHEL schedule like subscription-manager does.");
                continue;
            }
            // Bug 842450 - [ja_JP] failed pofilter newlines option test for candlepin translations
            if (pofilterTest.equals("newlines") && translationFile.getName().equals("ja.po"))
                bugIds.add("842450");
            if (pofilterTest.equals("tabs") && translationFile.getName().equals("ja.po"))
                bugIds.add("842450");
            // Bug 842784 - [ALL LANG] failed pofilter untranslated option test for candlepin translations
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("pa.po"))
                bugIds.add("842784");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("bn_IN.po"))
                bugIds.add("842784");
            // Bug 962011 - [ALL] candlepin master translations for all the new "compliance reasons" are needed
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("it.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("es_ES.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("pt_BR.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("gu.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("or.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("as.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("kn.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("de_DE.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("ko.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("ru.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("mr.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("hi.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("ja.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("te.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("ta_IN.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("ml.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("fr.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("zh_CN.po"))
                bugIds.add("962011");
            if (pofilterTest.equals("untranslated") && translationFile.getName().equals("zh_TW.po"))
                bugIds.add("962011");
            // Bug 865561 - [pa_IN] the pofilter escapes test is failing on msgid "Consumer Type with id {0} could not be found."
            if (pofilterTest.equals("escapes") && translationFile.getName().equals("pa.po"))
                bugIds.add("865561");
            // Bug 929218 - [de_DE] pofilter unchanged test is failing
            if (pofilterTest.equals("unchanged") && translationFile.getName().equals("de_DE.po"))
                bugIds.add("929218");
            // Bug 1266127 - pofilter startwhitespace tests fail for many language translations in candlepin master
            if (pofilterTest.equals("startwhitespace"))
                bugIds.add("1266127");
            // Bug 1266125 - pofilter endwhitespace tests fail for many language translations in candlepin master
            if (pofilterTest.equals("endwhitespace"))
                bugIds.add("1266125");
            // Bug 1545909 - [fr] poor French translation for msgid "Candlepin is in Suspend mode, please check /status resource to get more details"
            if (pofilterTest.equals("filepaths") && translationFile.getName().equals("fr.po"))
                bugIds.add("1545909");
            // Bug 1545925 - [ja] the msgid "Bad Request" is not translated
            if (pofilterTest.equals("unchanged") && translationFile.getName().equals("ja.po"))
                bugIds.add("1545925");
            BlockedByBzBug blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
            ll.add(Arrays.asList(new Object[] { blockedByBzBug, pofilterTest, translationFile }));
        }
    }
    return ll;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug) HashSet(java.util.HashSet)

Example 14 with BlockedByBzBug

use of com.redhat.qe.auto.bugzilla.BlockedByBzBug in project rhsm-qe by RedHatQE.

the class ProxyTests method getVersionAttemptsUsingProxyServerDataAs2dArray.

@DataProvider(name = "getVersionAttemptsUsingProxyServerData")
public Object[][] getVersionAttemptsUsingProxyServerDataAs2dArray() {
    // return TestNGUtils.convertListOfListsTo2dArray(getValidRegisterAttemptsUsingProxyServerDataAsListOfLists());
    List<List<Object>> ll = new ArrayList<List<Object>>();
    for (List<Object> l : getValidRegisterAttemptsUsingProxyServerDataAsListOfLists()) {
        // nullify the blockedByBug parameter since this function was originally not blocked by any bug
        BlockedByBzBug blockedByBzBug = null;
        List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
        // add BlockedByBzBug to rows that are expecting a proxy error
        if (l.get(8) == /*stdout*/
        pErrMsg || l.get(9) == /*stderr*/
        pErrMsg || l.get(8) == /*stdout*/
        rErrMsg || l.get(9) == /*stderr*/
        rErrMsg) {
            // Bug 1336551 - status and version modules are not using cache when bad command line proxy is specified
            bugIds.add("1336551");
        }
        // Bug 1345962 - unbound method endheaders() must be called with HTTPSConnection instance as first argument (got RhsmProxyHTTPSConnection instance instead)
        bugIds.add("1345962");
        blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
        // Note: The version module should always succeed, yet report subscription management server: Unknown when connection fails to the server
        if (clienttasks.isPackageVersion("subscription-manager", "<", "1.18.2-1")) {
            // post commit ad982c13e79917e082f336255ecc42615e1e7707	1176219: Error out if bad proxy settings detected
            if (l.get(8) == /*stdout*/
            nErrMsg || l.get(9) == /*stderr*/
            nErrMsg) {
                ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), Integer.valueOf(0), /*exitCode*/
                "subscription management server: Unknown", /*stdout*/
                "" /*stderr*/
                }));
            } else {
                ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), Integer.valueOf(0), /*exitCode*/
                "subscription management server: " + servertasks.statusVersion, /*stdout*/
                "" /*stderr*/
                }));
            }
        } else {
            // not anymore...  since CLOSED WONFIX Bug 1336551 - status and version modules are not using cache when bad command line proxy is specified
            if (Integer.valueOf(0).equals(l.get(7))) {
                // indicates success
                ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), Integer.valueOf(0), /*exitCode*/
                "subscription management server: " + servertasks.statusVersion, /*stdout*/
                "" /*stderr*/
                }));
            } else {
                ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), /*exitCode*/
                l.get(8), /*stdout*/
                l.get(9) /*stderr*/
                }));
            }
        }
    }
    return TestNGUtils.convertListOfListsTo2dArray(ll);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug) DataProvider(org.testng.annotations.DataProvider)

Example 15 with BlockedByBzBug

use of com.redhat.qe.auto.bugzilla.BlockedByBzBug in project rhsm-qe by RedHatQE.

the class ProxyTests method getRegisterAttemptsToVerifyHonoringNoProxyDataAsListOfLists.

protected List<List<Object>> getRegisterAttemptsToVerifyHonoringNoProxyDataAsListOfLists() {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    // /* TOO EXHAUSTIVE TAKES 40 MINUTES */ for (List<Object> l : getValidRegisterAttemptsUsingProxyServerViaRhsmConfigDataAsListOfLists()) {
    for (List<Object> l : getRandomSubsetOfList(getValidRegisterAttemptsUsingProxyServerViaRhsmConfigDataAsListOfLists(), 3)) {
        // append a value for no_proxy and a boolean to indicate if it should be honored or not
        String noProxy;
        Boolean hostnameMatchesNoProxy;
        // get the existing BlockedByBzBug
        BlockedByBzBug blockedByBzBug = (BlockedByBzBug) l.get(0);
        List<String> bugIds = blockedByBzBug == null ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(blockedByBzBug.getBugIds()));
        // add more BlockedByBzBug to rows that are expecting a network error
        // bugIds.add("1234");	// Bug 1234
        blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
        // Object blockedByBug (0), String username (1), String password (2), Sring org (3), String proxy (4), String proxyuser (5), String proxypassword (6), String proxy_hostnameConfig (7), String proxy_portConfig (8), String proxy_userConfig (9), String proxy_passwordConfig (10), Integer exitCode (11), String stdout (12), String stderr (13), SSHCommandRunner proxyRunner (14), String proxyLog (15), String proxyLogGrepPattern (16)
        // Bug 1457197 - --noproxy option no longer match "*" for host names
        bugIds.add("1457197");
        // * matches subscription.rhn.redhat.com
        noProxy = "*";
        // * matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(bugIds.toArray(new String[] {})), l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        bugIds.remove("1457197");
        // subscription.rhn.redhat.com matches subscription.rhn.redhat.com
        noProxy = sm_serverHostname;
        // subscription.rhn.redhat.com matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        // *.aventail.com,home.com,.seanet.com,subscription.rhn.redhat.com matches subscription.rhn.redhat.com
        noProxy = "*.aventail.com,home.com,.seanet.com," + sm_serverHostname;
        // *.aventail.com,home.com,.seanet.com,subscription.rhn.redhat.com matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        // .rhn.redhat.com matches subscription.rhn.redhat.com
        noProxy = sm_serverHostname.replaceFirst("[^\\.]+", "");
        // .rhn.redhat.com matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        // *.aventail.com,home.com,.seanet.com,.rhn.redhat.com matches subscription.rhn.redhat.com
        noProxy = "*.aventail.com,home.com,.seanet.com," + sm_serverHostname.replaceFirst("[^\\.]+", "");
        // *.aventail.com,home.com,.seanet.com,.rhn.redhat.com matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        // *.aventail.com,home.com,.seanet.com does not match subscription.rhn.redhat.com
        noProxy = "*.aventail.com,home.com,.seanet.com";
        // *.aventail.com,home.com,.seanet.com does not match subscription.rhn.redhat.com
        hostnameMatchesNoProxy = false;
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        // Bug 1443164 	no_proxy does not match the host name when *.redhat.com is used	// This case does not work on RHEL since the the only wildcard supported by the library is no_proxy=* which is likely an RFE bug against component X?
        bugIds.add("1443164");
        // *.rhn.redhat.com matches subscription.rhn.redhat.com
        noProxy = sm_serverHostname.replaceFirst("[^\\.]+", "*");
        // *.rhn.redhat.com matches subscription.rhn.redhat.com
        hostnameMatchesNoProxy = true;
        ll.add(Arrays.asList(new Object[] { new BlockedByBzBug(bugIds.toArray(new String[] {})), l.get(1), l.get(2), l.get(3), l.get(4), l.get(5), l.get(6), l.get(7), l.get(8), l.get(9), l.get(10), l.get(11), l.get(12), l.get(13), l.get(14), l.get(15), l.get(16), noProxy, hostnameMatchesNoProxy }));
        bugIds.remove("1443164");
    }
    return ll;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Aggregations

BlockedByBzBug (com.redhat.qe.auto.bugzilla.BlockedByBzBug)67 ArrayList (java.util.ArrayList)67 List (java.util.List)67 JSONObject (org.json.JSONObject)21 HashSet (java.util.HashSet)18 File (java.io.File)14 DataProvider (org.testng.annotations.DataProvider)14 SubscriptionPool (rhsm.data.SubscriptionPool)7 BigInteger (java.math.BigInteger)5 ProductCert (rhsm.data.ProductCert)5 HashMap (java.util.HashMap)3 JSONArray (org.json.JSONArray)3 EntitlementCert (rhsm.data.EntitlementCert)3 Repo (rhsm.data.Repo)2 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 SkipException (org.testng.SkipException)1 ConsumerType (rhsm.base.ConsumerType)1 YumRepo (rhsm.data.YumRepo)1