Search in sources :

Example 26 with YumRepo

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

the class ReposTests method testYumConfigManagerTransactionsWillNowGenerateRedhatRepo.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47936", "RHEL7-99418" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "verify that the subscription-manager yum plugin will be invoked by yum-config-manager thereby populating the redhat.repo file (eliminating the need to run a seemingly no-op yum repolist just to populate an empty/missing redhat.repo file.)  Reference RFE Bugzilla 1329349", groups = { "Tier1Tests", "blockedByBug-1329349", "blockedByBug-1486326", "blockedByBug-1480659", "blockedByBug-1486338" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumConfigManagerTransactionsWillNowGenerateRedhatRepo() throws JSONException, Exception {
    // register with auto-subscribe to get an entitlement to at least one yum repo
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    List<YumRepo> subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    if (subscribedYumRepos.isEmpty())
        throw new SkipException("There are no entitled yum repos available for this test.");
    // get all the disabled yum repos for this test
    List<YumRepo> disabledYumRepos = YumRepo.findAllInstancesWithMatchingFieldFromList("enabled", false, subscribedYumRepos);
    if (disabledYumRepos.isEmpty())
        throw new SkipException("Could not find any entitled yum repos that were disabled for this test.");
    List<String> disabledRepos = new ArrayList<String>();
    for (YumRepo disabledYumRepo : disabledYumRepos) disabledRepos.add(disabledYumRepo.id);
    // manually delete or truncate the redhat.repo files
    client.runCommandAndWait("rm -f " + clienttasks.redhatRepoFile);
    client.runCommandAndWait("rm -f " + clienttasks.redhatRepoServerValueFile);
    Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.redhatRepoFile));
    // use yum-config-manager to enable the repos that were disabled by default
    clienttasks.yumConfigManagerEnableRepos(disabledRepos, null);
    // assert that the redhat.repo was regenerated by the new subscription-manager plugin to yum-config-manager (blocked by RFE Bug 1329349)
    Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.redhatRepoFile), "File '" + clienttasks.redhatRepoFile + "' has been automatically generated by a subscription-manager plugin to yum-config-manager.");
    // assert that the yum repos within redhat.repo are now enabled
    subscribedYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    for (String disabledRepo : disabledRepos) {
        YumRepo yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", disabledRepo, subscribedYumRepos);
        Assert.assertTrue(yumRepo.enabled, "Entitled yum repo '" + disabledRepo + "' (which was disabled by default) appears in '" + clienttasks.redhatRepoFile + "' as enabled after using yum-config-manager to enable it.");
    }
    // run yum repolist enabled and assert that all the repos are enabled (blocked by Bug 1480659)
    ArrayList<String> yumRepoListEnabledRepos = clienttasks.getYumRepolist("enabled");
    for (String disabledRepo : disabledRepos) {
        Assert.assertTrue(yumRepoListEnabledRepos.contains(disabledRepo), "Entitled yum repo '" + disabledRepo + "' which was disabled by default, appears in 'yum repolist enabled' as enabled after using yum-config-manager to enable it.");
    }
}
Also used : ArrayList(java.util.ArrayList) YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 27 with YumRepo

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

the class ReposTests method testReposListPreservesSimultaneousEnablementOfRedhatRepos.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19971", "RHEL7-51010" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "subscription-manager: after subscribing to all pools, verify that edits (using subscription-manager --enable --disable options specified multiple times in a single call) to repos in redhat.repo are preserved.", groups = { "Tier1Tests", "blockedByBug-843915", "blockedByBug-962520", "blockedByBug-1034649", "blockedByBug-1121272", "blockedByBug-1366301" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListPreservesSimultaneousEnablementOfRedhatRepos() {
    // 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 all available subscription so as to populate the redhat.repo file
    clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    // get the current listing of repos
    // determined by calling subscription-manager repos --list
    List<Repo> originalRepos = clienttasks.getCurrentlySubscribedRepos();
    // List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos();	// determined by parsing /etc/yum.repos.d/redhat.repo
    // verify the repos listed and yumRepos are in sync
    // for (Repo repo : originalRepos) {
    // Assert.assertNotNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repo.repoId, yumRepos),"Found yum repo id ["+repo.repoId+"] matching current repos --list item: "+repo);
    // }
    // assemble lists of the current repoIds to be collectively toggled
    List<String> enableRepoIds = new ArrayList<String>();
    List<String> disableRepoIds = new ArrayList<String>();
    for (Repo repo : originalRepos) {
        if (repo.enabled) {
            disableRepoIds.add(repo.repoId);
        } else {
            enableRepoIds.add(repo.repoId);
        }
    }
    // collectively toggle the enablement of the current repos
    clienttasks.repos(null, null, null, enableRepoIds, disableRepoIds, null, null, null, null);
    // verify that the change is preserved by subscription-manager repos --list
    // determined by calling subscription-manager repos --list
    List<Repo> toggledRepos = clienttasks.getCurrentlySubscribedRepos();
    // List<YumRepo> toggledYumRepos = clienttasks.getCurrentlySubscribedYumRepos();	// determined by parsing /etc/yum.repos.d/redhat.repo
    // assert enablement of all the original repos have been toggled
    Assert.assertEquals(toggledRepos.size(), originalRepos.size(), "The count of repos listed should remain the same after collectively toggling their enablement.");
    for (Repo originalRepo : originalRepos) {
        Repo toggledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", originalRepo.repoId, toggledRepos);
        Assert.assertTrue(toggledRepo.enabled.equals(!originalRepo.enabled), "Repo [" + originalRepo.repoId + "] enablement has been toggled from '" + originalRepo.enabled + "' to '" + !originalRepo.enabled + "'.");
    }
    // now remove and refresh entitlement certificates and again assert the toggled enablement is preserved
    log.info("Remove and refresh entitlement certs...");
    clienttasks.removeAllCerts(false, true, false);
    clienttasks.refresh(null, null, null, null);
    // verify that the change is preserved by subscription-manager repos --list
    // determined by calling subscription-manager repos --list
    toggledRepos = clienttasks.getCurrentlySubscribedRepos();
    // List<YumRepo> toggledYumRepos = clienttasks.getCurrentlySubscribedYumRepos();	// determined by parsing /etc/yum.repos.d/redhat.repo
    // assert enablement of all the original repos have been toggled
    Assert.assertEquals(toggledRepos.size(), originalRepos.size(), "Even after refreshing certificates, the count of repos listed should remain the same after collectively toggling their enablement.");
    for (Repo originalRepo : originalRepos) {
        Repo toggledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", originalRepo.repoId, toggledRepos);
        Assert.assertTrue(toggledRepo.enabled.equals(!originalRepo.enabled), "Even after refreshing certificates, repo [" + originalRepo.repoId + "] enablement has been toggled from '" + originalRepo.enabled + "' to '" + !originalRepo.enabled + "'.");
    }
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) ArrayList(java.util.ArrayList) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 28 with YumRepo

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

the class ReposTests method testReposListDisabledReportsOnlyDisabledContentNamespaces.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20368", "RHEL7-51684" }, 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: subscribe to a pool and verify that repos list --list-disabled reports only the disabled repos from the newly entitled content namespaces", groups = { "Tier3Tests", "blockedByBug-1119648" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListDisabledReportsOnlyDisabledContentNamespaces() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.4-1"))
        throw new SkipException("The repos --list-disabled 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.");
    List<YumRepo> disabledYumRepos = YumRepo.findAllInstancesWithMatchingFieldFromList("enabled", Boolean.FALSE, subscribedYumRepos);
    // get the list of currently disabled repos
    SSHCommandResult sshCommandResult = clienttasks.repos(null, null, true, (String) null, (String) null, null, null, null, null);
    List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
    // verify that the disabledYumRepos are all present in the listDisabledRepos
    for (YumRepo yumRepo : disabledYumRepos) {
        Repo disabledRepo = Repo.findFirstInstanceWithMatchingFieldFromList("repoId", yumRepo.id, listDisabledRepos);
        Assert.assertNotNull(disabledRepo, "Disabled yum repo [" + yumRepo.id + "] is included in the report of repos --list-disabled.");
    }
    Assert.assertEquals(listDisabledRepos.size(), disabledYumRepos.size(), "The number of --list-disabled repos matches the number of disabled yum repos in '" + clienttasks.redhatRepoFile + "'.");
}
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 29 with YumRepo

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

the class ReposTests method verifyTogglingTheEnablementOfRedhatRepo.

/**
 * @param yumRepo
 * @param manually - if true, then toggling the enabled flag in yumRepo is performed manually using sed, otherwise subscription-manager repos --enable or --disable option is used
 */
protected void verifyTogglingTheEnablementOfRedhatRepo(YumRepo yumRepo, boolean manually) {
    Repo repo = new Repo(yumRepo.name, yumRepo.id, yumRepo.baseurl, yumRepo.enabled);
    // assert that the yumRepo is reported in the subscription-manager repos
    List<Repo> currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
    Assert.assertTrue(currentlySubscribedRepos.contains(repo), "The yumRepo '" + yumRepo + "' is represented in the subscription-manager repos --list by: " + repo);
    // also verify that yumRepo is reported in the yum repolist
    Assert.assertTrue(clienttasks.getYumRepolist(yumRepo.enabled ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' before manually changing its enabled value.");
    // edit the redhat.repo and change the enabled parameter for this yumRepo
    // toggle the value
    Boolean newEnabledValue = yumRepo.enabled ? false : true;
    if (manually) {
        // toggle the enabled flag manually
        clienttasks.updateYumRepoParameter(clienttasks.redhatRepoFile, yumRepo.id, "enabled", newEnabledValue.toString());
    } else if (newEnabledValue) {
        // toggle the enabled flag using subscription-manager repos --enable
        clienttasks.repos(null, null, null, yumRepo.id, null, null, null, null, null);
    } else {
        // toggle the enabled flag using subscription-manager repos --disable
        clienttasks.repos(null, null, null, null, yumRepo.id, null, null, null, null);
    }
    Repo newRepo = new Repo(yumRepo.name, yumRepo.id, yumRepo.baseurl, newEnabledValue);
    // verify that the change is preserved by subscription-manager repos --list
    currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
    Assert.assertTrue(currentlySubscribedRepos.contains(newRepo), "yumRepo id '" + yumRepo.id + "' was manually changed to enabled=" + newEnabledValue + " and the subscription-manager repos --list reflects the change as: " + newRepo);
    Assert.assertFalse(currentlySubscribedRepos.contains(repo), "The original repo (" + repo + ") is no longer found in subscription-manager repos --list.");
    // also verify the change is reflected in yum repolist
    Assert.assertTrue(clienttasks.getYumRepolist(newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
    Assert.assertFalse(clienttasks.getYumRepolist(!newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
    // now remove and refresh entitlement certificates and again assert the manual edits are preserved
    log.info("Remove and refresh entitlement certs...");
    clienttasks.removeAllCerts(false, true, false);
    clienttasks.refresh(null, null, null, null);
    // verify that the change is preserved by subscription-manager repos --list (even after deleting and refreshing entitlement certs)
    currentlySubscribedRepos = clienttasks.getCurrentlySubscribedRepos();
    Assert.assertTrue(currentlySubscribedRepos.contains(newRepo), "yumRepo id '" + yumRepo.id + "' was manually changed to enabled=" + newEnabledValue + " and even after deleting and refreshing certs, the subscription-manager repos --list reflects the change as: " + newRepo);
    Assert.assertFalse(currentlySubscribedRepos.contains(repo), "The original repo (" + repo + ") is no longer found in subscription-manager repos --list.");
    // also verify the change is reflected in yum repolist (even after deleting and refreshing entitlement certs)
    Assert.assertTrue(clienttasks.getYumRepolist(newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "even after deleting and refreshing certs, yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
    Assert.assertFalse(clienttasks.getYumRepolist(!newEnabledValue ? "enabled" : "disabled").contains(yumRepo.id), "even after deleting and refreshing certs, yum repolist properly reports the enablement of yumRepo id '" + yumRepo.id + "' which was manually changed to '" + newEnabledValue + "'.");
}
Also used : Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo)

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