Search in sources :

Example 6 with YumRepo

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

the class ReleaseTests method testReleaseverSubstitutionInRepoLists.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20010", "RHEL7-55175" }, 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 = "after subscribing to all available subscriptions, assert that content with url paths that reference $releasever are substituted with the consumers current release preference", groups = { "Tier1Tests", "blockedByBug-807407", "blockedByBug-962520" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseverSubstitutionInRepoLists() throws JSONException, Exception {
    // make sure we are newly registered
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    // subscribe to all available subscriptions
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // get current list of Repos and YumRepos before setting a release version preference
    List<Repo> reposBeforeSettingReleaseVer = clienttasks.getCurrentlySubscribedRepos();
    List<YumRepo> yumReposBeforeSettingReleaseVer = clienttasks.getCurrentlySubscribedYumRepos();
    boolean skipTest = true;
    for (Repo repo : reposBeforeSettingReleaseVer) {
        if (repo.repoUrl.contains("$releasever")) {
            skipTest = false;
            break;
        }
    }
    if (skipTest)
        throw new SkipException("After subscribing to all available subscriptions, could not find any enabled content with a repoUrl that employs $releasever");
    Assert.assertEquals(reposBeforeSettingReleaseVer.size(), yumReposBeforeSettingReleaseVer.size(), "The subscription-manager repos list count should match the yum reposlist count.");
    // now let's set a release version preference
    // cannot do this anymore, the value must be valid
    String releaseVer = "TestRelease-1.0";
    List<String> availableReleaseVers = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    if (availableReleaseVers.isEmpty())
        throw new SkipException("Cannot complete this test when there are no releases available to set.");
    // randomly pick an available release for testing
    releaseVer = availableReleaseVers.get(randomGenerator.nextInt(availableReleaseVers.size()));
    clienttasks.release(null, null, releaseVer, null, null, null, null, null);
    // assert that each of the Repos after setting a release version preference substitutes the $releasever
    for (Repo repoAfter : clienttasks.getCurrentlySubscribedRepos()) {
        Repo repoBefore = Repo.findFirstInstanceWithMatchingFieldFromList("repoName", repoAfter.repoName, reposBeforeSettingReleaseVer);
        Assert.assertNotNull(repoBefore, "Found the the same repoName from the subscription-manager repos --list after setting a release version preference.");
        if (!repoBefore.repoUrl.contains("$releasever")) {
            Assert.assertEquals(repoAfter.repoUrl, repoBefore.repoUrl, "After setting a release version preference, the subscription-manager repos --list reported repoUrl for '" + repoAfter.repoName + "' should remain unchanged since it did not contain the yum $releasever variable.");
        } else {
            Assert.assertEquals(repoAfter.repoUrl, repoBefore.repoUrl.replaceAll("\\$releasever", releaseVer), "After setting a release version preference, the subscription-manager repos --list reported repoUrl for '" + repoAfter.repoName + "' should have a variable substitution for $releasever.");
        }
    }
    // assert that each of the YumRepos after setting a release version preference actually substitutes the $releasever
    for (YumRepo yumRepoAfter : clienttasks.getCurrentlySubscribedYumRepos()) {
        YumRepo yumRepoBefore = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepoAfter.id, yumReposBeforeSettingReleaseVer);
        Assert.assertNotNull(yumRepoBefore, "Found the the same repo id from the yum repolist after setting a release version preference.");
        if (!yumRepoBefore.baseurl.contains("$releasever")) {
            Assert.assertEquals(yumRepoAfter.baseurl, yumRepoBefore.baseurl, "After setting a release version preference, the yum repolist reported baseurl for '" + yumRepoAfter.id + "' should remain unchanged since it did not contain the yum $releasever variable.");
        } else {
            Assert.assertEquals(yumRepoAfter.baseurl, yumRepoBefore.baseurl.replaceAll("\\$releasever", releaseVer), "After setting a release version preference, the yum repolist reported baseurl for '" + yumRepoAfter.id + "' should have a variable substitution for $releasever.");
        }
    }
    // now let's unset the release version preference
    clienttasks.release(null, null, null, true, null, null, null, null);
    // assert that each of the Repos and YumRepos after unsetting the release version preference where restore to their original values (containing $releasever)
    List<Repo> reposAfterSettingReleaseVer = clienttasks.getCurrentlySubscribedRepos();
    List<YumRepo> yumReposAfterSettingReleaseVer = clienttasks.getCurrentlySubscribedYumRepos();
    Assert.assertTrue(reposAfterSettingReleaseVer.containsAll(reposBeforeSettingReleaseVer) && reposBeforeSettingReleaseVer.containsAll(reposAfterSettingReleaseVer), "After unsetting the release version preference, all of the subscription-manager repos --list were restored to their original values.");
    Assert.assertTrue(yumReposAfterSettingReleaseVer.containsAll(yumReposBeforeSettingReleaseVer) && yumReposBeforeSettingReleaseVer.containsAll(yumReposAfterSettingReleaseVer), "After unsetting the release version preference, all of the yum repolist were restored to their original values.");
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 7 with YumRepo

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

the class RepoOverrideTests method attachRandomSubscriptionThatProvidesYumRepos.

// Candidates for an automated Test:
// Configuration methods ***********************************************************************
// Protected methods ***********************************************************************
/**
 * @return a list of YumRepos that result after randomly attaching a subscription
 */
protected List<YumRepo> attachRandomSubscriptionThatProvidesYumRepos() {
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    if (pools.isEmpty())
        throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
    // = new ArrayList<YumRepo>();
    List<YumRepo> yumRepos;
    do {
        // not important clienttasks.unsubscribe_(true, (BigInteger)null, null, null, null);
        // randomly pick a pool
        SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
        // /*debugTesting*/ pool = SubscriptionPool.findFirstInstanceWithCaseInsensitiveMatchingFieldFromList("productId", "awesomeos-per-arch-cont", pools);
        pools.remove(pool);
        clienttasks.subscribeToSubscriptionPool(pool);
        yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    } while (yumRepos.isEmpty() && !pools.isEmpty());
    if (yumRepos.isEmpty())
        throw new SkipException("Could not find a pool that provided YumRepos after subscribing.");
    return yumRepos;
}
Also used : SkipException(org.testng.SkipException) YumRepo(rhsm.data.YumRepo) SubscriptionPool(rhsm.data.SubscriptionPool)

Example 8 with YumRepo

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

the class RepoOverrideTests method testAddAndRemoveRepoOverridesOneRepoAtATime.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19976", "RHEL7-51015" }, 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 = "add yum repo overrides, verify they persist, and remove them one repo at a time", groups = { "Tier1Tests", "blockedByBug-1069230", "blockedByBug-1034396" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAddAndRemoveRepoOverridesOneRepoAtATime() {
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // subscribe to a random pool (so as to consume an entitlement) and remember the original list of YumRepos read from the redhat.repo file
    List<YumRepo> originalYumRepos = attachRandomSubscriptionThatProvidesYumRepos();
    // choose a random small subset of repos to test repo-override
    List<YumRepo> originalYumReposSubset = getRandomSubsetOfList(originalYumRepos, 5);
    // add several repo overrides (one repo at a time)
    Map<String, Map<String, String>> repoOverridesMapOfMaps = new HashMap<String, Map<String, String>>();
    for (YumRepo yumRepo : originalYumReposSubset) {
        String repoId = yumRepo.id;
        Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
        repoOverrideNameValueMap.put("enabled", "true");
        repoOverrideNameValueMap.put("gpgcheck", "false");
        repoOverrideNameValueMap.put("exclude", "foo-bar");
        repoOverrideNameValueMap.put("retries", "5");
        repoOverrideNameValueMap.put("ui_repoid_vars", "releasever basearch foo");
        repoOverrideNameValueMap.put("sslverify", "false");
        repoOverrideNameValueMap.put("sslcacert", "/overridden/candlepin.pem");
        repoOverrideNameValueMap.put("sslclientkey", "/overridden/serial-key.pem");
        repoOverrideNameValueMap.put("sslclientcert", "/overridden/serial.pem");
        repoOverridesMapOfMaps.put(repoId, repoOverrideNameValueMap);
        clienttasks.repo_override(null, null, repoId, null, repoOverrideNameValueMap, null, null, null, null);
    }
    // verify the current YumRepos read from the redhat.repo file actually contain the overrides
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, true);
    // unsubscribe/resubscribe
    SSHCommandResult listResultBeforeUnsubscribe = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    List<String> poolIds = new ArrayList<String>();
    for (ProductSubscription productSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        clienttasks.unsubscribe(true, productSubscription.serialNumber, null, null, null, null, null);
        poolIds.add(productSubscription.poolId);
    }
    SSHCommandResult listResultAfterUnsubscribe = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    // valid prior to bug 1034396	Assert.assertEquals(listResultAfterUnsubscribe.getStdout().trim(), "This system does not have any subscriptions.", "Stdout from repo-override --list without any subscriptions attached (but should still have overrides cached in the consumer).");
    Assert.assertEquals(listResultAfterUnsubscribe.getStdout(), listResultBeforeUnsubscribe.getStdout(), "Stdout from repo-override --list without any subscriptions attached should be identical to the list when subscriptions were attached.");
    Assert.assertTrue(clienttasks.getCurrentlySubscribedYumRepos().isEmpty(), "The YumRepos in '" + clienttasks.redhatRepoFile + "' should be empty after unsubscribing from each serial.");
    clienttasks.subscribe(null, null, poolIds, null, null, null, null, null, null, null, null, null, null);
    // ...and verify the YumRepos read from the redhat.repo file persists the overrides
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
    // remove names from one repo override and verify the list
    // choose one repoId
    String repoId = (String) repoOverridesMapOfMaps.keySet().toArray()[0];
    clienttasks.repo_override(null, null, Arrays.asList(new String[] { repoId }), Arrays.asList(new String[] { "name" }), null, null, null, null, null);
    repoOverridesMapOfMaps.get(repoId).remove("name");
    clienttasks.repo_override(null, null, Arrays.asList(new String[] { repoId }), Arrays.asList(new String[] { "name", "enabled", "ui_repoid_vars" }), null, null, null, null, null);
    repoOverridesMapOfMaps.get(repoId).remove("name");
    repoOverridesMapOfMaps.get(repoId).remove("enabled");
    repoOverridesMapOfMaps.get(repoId).remove("ui_repoid_vars");
    // clienttasks.repo_override(null,null,Arrays.asList(new String[]{repoId}),Arrays.asList(new String[]{"gpgcheck","exclude","retries"}),null,null,null,null);	// for test variability, let's not delete these
    // repoOverridesMapOfMaps.get(repoId).remove("gpgcheck");
    // repoOverridesMapOfMaps.get(repoId).remove("exclude");
    // repoOverridesMapOfMaps.get(repoId).remove("retries");
    clienttasks.repo_override(null, null, Arrays.asList(new String[] { repoId }), Arrays.asList(new String[] { "sslverify", "sslcacert", "sslclientkey", "sslclientcert" }), null, null, null, null, null);
    repoOverridesMapOfMaps.get(repoId).remove("sslverify");
    repoOverridesMapOfMaps.get(repoId).remove("sslcacert");
    repoOverridesMapOfMaps.get(repoId).remove("sslclientkey");
    repoOverridesMapOfMaps.get(repoId).remove("sslclientcert");
    // repoOverridesMapOfMaps.remove(repoid);	// remove one repoid from the overrides Map
    // verify the current YumRepos read from the redhat.repo file no longer contains the removed override (the original should be restored)
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
    // remove all of the repo overrides
    clienttasks.repo_override(null, true, (String) null, (String) null, null, null, null, null, null);
    repoOverridesMapOfMaps.clear();
    // TEMPORARY WORKAROUND
    if (CandlepinType.standalone.equals(sm_serverType)) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1195501 - The redhat.repo file should be refreshed after a successful repo-override removal
        String bugId = "1195501";
        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) {
            // trigger a yum transaction so that subscription-manager yum plugin will refresh redhat.repo
            // sshCommandRunner.runCommandAndWait("killall -9 yum"); // is this needed?
            // sshCommandRunner.runCommandAndWait("yum repolist all --disableplugin=rhnplugin"); // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
            // sshCommandRunner.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin"); // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
            // NOT REALLY SURE WHAT TO DO HERE SINCE THE WORKAROUNDS ARE UNRELIABLE
            log.warning("Skipping test's final assertion on repo-override removal while bug '" + bugId + "' is open.");
            return;
        }
    }
    // END OF WORKAROUND
    // verify the current YumRepos read from the redhat.repo file no longer contains any overrides (the original should be restored)
    verifyCurrentYumReposReflectRepoOverrides(originalYumRepos, repoOverridesMapOfMaps, false);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) YumRepo(rhsm.data.YumRepo) HashMap(java.util.HashMap) Map(java.util.Map) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 9 with YumRepo

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

the class ReposTests method testReposListEnabledReportsNoMatchesFoundWhenNoThereAreNoEnabledRepos.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20389", "RHEL7-51685" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: repos --list-enabled should give feedback when there are no enabled repos", groups = { "Tier3Tests", "blockedByBug-1151925" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListEnabledReportsNoMatchesFoundWhenNoThereAreNoEnabledRepos() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.4-1"))
        throw new SkipException("The repos --list-enabled function was not implemented until version subscription-manager-1.13.4-1");
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    if (subscribedYumRepos.isEmpty())
        throw new SkipException("There are no entitled yum repos available for this test.");
    // use a wildcard to disable all the repos
    clienttasks.repos(null, null, null, null, "*", null, null, null, null);
    // get the list of currently disabled repos (list should be empty)
    SSHCommandResult sshCommandResult = clienttasks.repos(null, true, false, (String) null, (String) null, null, null, null, null);
    List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
    Assert.assertTrue(listDisabledRepos.isEmpty(), "After using a wildcard to disable all repos, the repos --list-enabled should be empty.");
    // assert the feedback when no repos are disabled
    String expectedStdout = "There were no available repositories matching the specified criteria.";
    Assert.assertEquals(sshCommandResult.getStdout().trim(), expectedStdout, "After using a wildcard to disable all repos, the repos --list-enabled should report feedback indicating no matches.");
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) YumRepo(rhsm.data.YumRepo) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 10 with YumRepo

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

the class ReposTests method testYumRepoListPreservesAdditionalOptionsToRedhatReposUsingManualEditsButRepoOverridesTakePrecedence.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20298", "RHEL7-51698" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: verify that overrides take precedence to manually edited repository options in redhat.repo and assert persistence.", groups = { "Tier3Tests", "blockedByBug-1098891", "blockedByBug-1101571", "blockedByBug-1101584" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRepoListPreservesAdditionalOptionsToRedhatReposUsingManualEditsButRepoOverridesTakePrecedence() throws JSONException, Exception {
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    if (subscribedYumRepos.isEmpty())
        throw new SkipException("There are no entitled yum repos available for this test.");
    // choose the first disabled yum repo for this test
    YumRepo yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("enabled", false, subscribedYumRepos);
    if (yumRepo == null)
        throw new SkipException("Could not find a disabled yum repo available for this test.");
    // manually enable the yum repo
    yumRepo.enabled = true;
    clienttasks.updateYumRepo(clienttasks.redhatRepoFile, yumRepo);
    // assert that the manually added repository options do not get clobbered by a new yum transaction
    // issue a new yum transaction
    client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    // getCurrentlySubscribedYumRepos() includes a yum transaction: "yum -q repolist --disableplugin=rhnplugin"	(NOT ANYMORE after bug 1008016)
    YumRepo yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
    Assert.assertNotNull(yumRepoAfterUpdate, "Found yum repo [" + yumRepo.id + "] in '" + clienttasks.redhatRepoFile + "'.");
    Assert.assertTrue(yumRepoAfterUpdate.enabled, "Yum repo [" + yumRepo.id + "] has persisted the manual enablement.");
    // use subscription-manager repos to disable the repo
    clienttasks.repos(null, null, null, null, yumRepo.id, null, null, null, null);
    // assert that the yum repo was disabled and a repo-override was created that takes precedence over the manually enabled yum repo
    // issue a new yum transaction
    client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    // getCurrentlySubscribedYumRepos() includes a yum transaction: "yum -q repolist --disableplugin=rhnplugin"	(NOT ANYMORE after bug 1008016)
    yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
    Assert.assertNotNull(yumRepoAfterUpdate, "Found yum repo [" + yumRepo.id + "] in '" + clienttasks.redhatRepoFile + "'.");
    Assert.assertFalse(yumRepoAfterUpdate.enabled, "Yum repo [" + yumRepo.id + "] has persisted the disablement by subscription-manager.");
    Assert.assertTrue(SubscriptionManagerCLITestScript.doesStringContainMatches(clienttasks.repo_override(true, null, (String) null, (String) null, null, null, null, null, null).getStdout(), String.format(SubscriptionManagerTasks.repoOverrideListRepositoryNameValueRegexFormat, yumRepo.id, "enabled", "0")), "After a calling subscription-manager repos --enable, the subscription-manager repo-override list includes an override for repo='" + yumRepo.id + "' name='" + "enabled" + "' value='" + "0" + "'.");
    // now attempt to manually re-enable yum repo
    clienttasks.updateYumRepo(clienttasks.redhatRepoFile, yumRepo);
    // assert that the attempt to manually re-enable the yum repo fails since the subscription-manager repo override takes precedence over manual edits.
    // issue a new yum transaction
    client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    // getCurrentlySubscribedYumRepos() includes a yum transaction: "yum -q repolist --disableplugin=rhnplugin"	(NOT ANYMORE after bug 1008016)
    yumRepoAfterUpdate = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", yumRepo.id, clienttasks.getCurrentlySubscribedYumRepos());
    Assert.assertNotNull(yumRepoAfterUpdate, "Found yum repo [" + yumRepo.id + "] in '" + clienttasks.redhatRepoFile + "'.");
    Assert.assertFalse(yumRepoAfterUpdate.enabled, "Yum repo [" + yumRepo.id + "] is still disabled after an attempt to manually enable it (because repo-override should take precedence).");
}
Also used : YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

YumRepo (rhsm.data.YumRepo)29 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)23 Test (org.testng.annotations.Test)23 SkipException (org.testng.SkipException)17 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)12 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Repo (rhsm.data.Repo)8 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)4 Map (java.util.Map)4 BigInteger (java.math.BigInteger)3 ContentNamespace (rhsm.data.ContentNamespace)3 EntitlementCert (rhsm.data.EntitlementCert)3 ProductSubscription (rhsm.data.ProductSubscription)3 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)2 ProductCert (rhsm.data.ProductCert)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1