Search in sources :

Example 16 with YumRepo

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

the class DockerTests method testYumRepolistIsEmptyOnRunningDockerImageWhenHostIsUnregistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL7-55538" }, 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 a running container has no yum repolist when the host has no entitlement", groups = { "Tier1Tests" }, dependsOnMethods = { "testPullDockerImage" }, dataProvider = "getDockerImageData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRepolistIsEmptyOnRunningDockerImageWhenHostIsUnregistered(Object bugzilla, String dockerImage) {
    // unregister the host
    clienttasks.unregister(null, null, null, null);
    // verify the host has no redhat.repo content
    List<YumRepo> yumReposOnHost = clienttasks.getCurrentlySubscribedYumRepos();
    Assert.assertTrue(yumReposOnHost.isEmpty(), "When the host is unregistered, its list of yum repos in '" + clienttasks.redhatRepoFile + "' is empty.");
    // verify yum repolist is empty for running docker image
    // [root@jsefler-7 ~]# docker run --rm docker-registry.usersys.redhat.com/brew/rhel7:latest yum repolist
    // Loaded plugins: product-id, subscription-manager
    // repolist: 0
    SSHCommandResult yumRepolistResultOnRunningDockerImage = client.runCommandAndWait("docker run --rm " + dockerImage + " yum repolist");
    Assert.assertEquals(yumRepolistResultOnRunningDockerImage.getExitCode(), Integer.valueOf(0), "Exit code from docker run yum repolist command.");
    String expectedStdoutMsg = "repolist: 0";
    Assert.assertTrue(yumRepolistResultOnRunningDockerImage.getStdout().trim().endsWith(expectedStdoutMsg), "Stdout from docker run yum repolist command ends with '" + expectedStdoutMsg + "'");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) YumRepo(rhsm.data.YumRepo) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 17 with YumRepo

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

the class BugzillaTests method testEmptyRepoOverrideRemove.

/*
	 * @author redakkan
	 *
	 * @throws exception
	 *
	 * @throws JSONException *
	 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47894", "RHEL7-96268" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli repo listing and override management
workitemId = "RHEL6-28545", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli repo listing and override management
workitemId = "RHEL7-84934", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.MEDIUM, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify repo-override --remove='' does not remove the overrides from the given repo", groups = { "Tier3Tests", "blockedByBug-1331739" }, enabled = true)
public void testEmptyRepoOverrideRemove() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.19.4-1")) {
        // fix : https://github.com/candlepin/subscription-manager/pull/1474
        new SkipException("This test applies a newer version of subscription manager that includes fixes for bugs 1331739");
    }
    // register
    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);
    // subscribe to a random pool
    List<YumRepo> originalYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    if (originalYumRepos.isEmpty())
        throw new SkipException("After registering with auto-subscribe, no yum repos were entitled. This test requires some redhat repos.");
    // choose a random small subset of repos to test repo-override
    List<YumRepo> originalYumReposSubset = getRandomSubsetOfList(originalYumRepos, 3);
    Map<String, Map<String, String>> repoOverridesMapOfMaps = new HashMap<String, Map<String, String>>();
    Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
    repoOverrideNameValueMap.put("enabled", "true");
    repoOverrideNameValueMap.put("gpgcheck", "false");
    repoOverrideNameValueMap.put("exclude", "foo-bar");
    for (YumRepo yumRepo : originalYumReposSubset) repoOverridesMapOfMaps.put(yumRepo.id, repoOverrideNameValueMap);
    List<String> repoIds = new ArrayList<String>(repoOverridesMapOfMaps.keySet());
    // Creating repo-overrides on the selected repo
    clienttasks.repo_override(null, null, repoIds, null, repoOverrideNameValueMap, null, null, null, null);
    // Gets the current repo-override list from the system
    SSHCommandResult listResultBeforeRemove = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    // repo-override remove with empty set of name values
    SSHCommandResult result = clienttasks.repo_override_(null, null, repoIds, Arrays.asList(new String[] { "" }), null, null, null, null, null);
    // Gets the current repo-override list AFTER REMOVE from the system
    SSHCommandResult listResultAfterRemove = clienttasks.repo_override_(true, null, (String) null, (String) null, null, null, null, null, null);
    Assert.assertEquals(listResultBeforeRemove.getStdout().trim(), listResultAfterRemove.getStdout().trim(), "Repo-overrides list After subscription-manager repo-override --repo=<id> --remove='' should be identical to the list before executing the command");
    Assert.assertEquals(result.getStderr().trim(), "Error: You must specify an override name with --remove.");
    Assert.assertEquals(result.getExitCode(), Integer.valueOf(64), "ExitCode of subscription-manager repo-override --remove without names should be 64");
}
Also used : HashMap(java.util.HashMap) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) YumRepo(rhsm.data.YumRepo) Map(java.util.Map) HashMap(java.util.HashMap) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 18 with YumRepo

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

the class RepoOverrideTests method verifyCurrentYumReposReflectRepoOverrides.

protected void verifyCurrentYumReposReflectRepoOverrides(List<YumRepo> originalYumRepos, Map<String, Map<String, String>> repoOverridesMapOfMaps, boolean includeVerificationOfNames_sslclient) {
    // verify the current YumRepos read from the redhat.repo file actually contain the overrides
    List<YumRepo> currentYumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    Assert.assertEquals(currentYumRepos.size(), originalYumRepos.size(), "The number of yum repos in " + clienttasks.redhatRepoFile + " should remain the same after applying subscription-manager repo-overrides.");
    for (YumRepo currentYumRepo : currentYumRepos) {
        String name, repoId = currentYumRepo.id;
        YumRepo originalYumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repoId, originalYumRepos);
        // this list of names should include all the fields from public class YumRepo
        name = "id";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.id == null ? null : currentYumRepo.id.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.id == null ? null : currentYumRepo.id.toString(), originalYumRepo.id == null ? null : originalYumRepo.id.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "name";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.name == null ? null : currentYumRepo.name.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.name == null ? null : currentYumRepo.name.toString(), originalYumRepo.name == null ? null : originalYumRepo.name.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "baseurl";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.baseurl == null ? null : currentYumRepo.baseurl.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.baseurl == null ? null : currentYumRepo.baseurl.toString(), originalYumRepo.baseurl == null ? null : originalYumRepo.baseurl.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "enabled";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.enabled == null ? null : currentYumRepo.enabled.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.enabled == null ? null : currentYumRepo.enabled.toString(), originalYumRepo.enabled == null ? null : originalYumRepo.enabled.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "gpgcheck";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.gpgcheck == null ? null : currentYumRepo.gpgcheck.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.gpgcheck == null ? null : currentYumRepo.gpgcheck.toString(), originalYumRepo.gpgcheck == null ? null : originalYumRepo.gpgcheck.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "sslcacert";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.sslcacert == null ? null : currentYumRepo.sslcacert.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.sslcacert == null ? null : currentYumRepo.sslcacert.toString(), originalYumRepo.sslcacert == null ? null : originalYumRepo.sslcacert.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "sslverify";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.sslverify == null ? null : currentYumRepo.sslverify.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.sslverify == null ? null : currentYumRepo.sslverify.toString(), originalYumRepo.sslverify == null ? null : originalYumRepo.sslverify.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        /* these two options are verified below to account for boolean includeVerificationOfNames_sslclient
			name = "sslclientcert";			if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {Assert.assertEquals(currentYumRepo.sslclientcert==null?null:currentYumRepo.sslclientcert.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='"+repoId+"' name='"+name+"'.");} else {Assert.assertEquals(currentYumRepo.sslclientcert==null?null:currentYumRepo.sslclientcert.toString(), originalYumRepo.sslclientcert==null?null:originalYumRepo.sslclientcert.toString(), "There should NOT be a repo-override for repoId='"+repoId+"' name='"+name+"'.");}
			name = "sslclientkey";			if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {Assert.assertEquals(currentYumRepo.sslclientkey==null?null:currentYumRepo.sslclientkey.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='"+repoId+"' name='"+name+"'.");} else {Assert.assertEquals(currentYumRepo.sslclientkey==null?null:currentYumRepo.sslclientkey.toString(), originalYumRepo.sslclientkey==null?null:originalYumRepo.sslclientkey.toString(), "There should NOT be a repo-override for repoId='"+repoId+"' name='"+name+"'.");}
			*/
        name = "metadata_expire";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.metadata_expire == null ? null : currentYumRepo.metadata_expire.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.metadata_expire == null ? null : currentYumRepo.metadata_expire.toString(), originalYumRepo.metadata_expire == null ? null : originalYumRepo.metadata_expire.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "metalink";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.metalink == null ? null : currentYumRepo.metalink.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.metalink == null ? null : currentYumRepo.metalink.toString(), originalYumRepo.metalink == null ? null : originalYumRepo.metalink.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "mirrorlist";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.mirrorlist == null ? null : currentYumRepo.mirrorlist.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.mirrorlist == null ? null : currentYumRepo.mirrorlist.toString(), originalYumRepo.mirrorlist == null ? null : originalYumRepo.mirrorlist.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "repo_gpgcheck";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.repo_gpgcheck == null ? null : currentYumRepo.repo_gpgcheck.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.repo_gpgcheck == null ? null : currentYumRepo.repo_gpgcheck.toString(), originalYumRepo.repo_gpgcheck == null ? null : originalYumRepo.repo_gpgcheck.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "gpgcakey";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.gpgcakey == null ? null : currentYumRepo.gpgcakey.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.gpgcakey == null ? null : currentYumRepo.gpgcakey.toString(), originalYumRepo.gpgcakey == null ? null : originalYumRepo.gpgcakey.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "exclude";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.exclude == null ? null : currentYumRepo.exclude.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.exclude == null ? null : currentYumRepo.exclude.toString(), originalYumRepo.exclude == null ? null : originalYumRepo.exclude.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "includepkgs";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.includepkgs == null ? null : currentYumRepo.includepkgs.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.includepkgs == null ? null : currentYumRepo.includepkgs.toString(), originalYumRepo.includepkgs == null ? null : originalYumRepo.includepkgs.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "enablegroups";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.enablegroups == null ? null : currentYumRepo.enablegroups.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.enablegroups == null ? null : currentYumRepo.enablegroups.toString(), originalYumRepo.enablegroups == null ? null : originalYumRepo.enablegroups.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "failovermethod";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.failovermethod == null ? null : currentYumRepo.failovermethod.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.failovermethod == null ? null : currentYumRepo.failovermethod.toString(), originalYumRepo.failovermethod == null ? null : originalYumRepo.failovermethod.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "keepalive";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.keepalive == null ? null : currentYumRepo.keepalive.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.keepalive == null ? null : currentYumRepo.keepalive.toString(), originalYumRepo.keepalive == null ? null : originalYumRepo.keepalive.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "timeout";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.timeout == null ? null : currentYumRepo.timeout.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.timeout == null ? null : currentYumRepo.timeout.toString(), originalYumRepo.timeout == null ? null : originalYumRepo.timeout.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "http_caching";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.http_caching == null ? null : currentYumRepo.http_caching.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.http_caching == null ? null : currentYumRepo.http_caching.toString(), originalYumRepo.http_caching == null ? null : originalYumRepo.http_caching.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "retries";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.retries == null ? null : currentYumRepo.retries.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.retries == null ? null : currentYumRepo.retries.toString(), originalYumRepo.retries == null ? null : originalYumRepo.retries.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "throttle";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.throttle == null ? null : currentYumRepo.throttle.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.throttle == null ? null : currentYumRepo.throttle.toString(), originalYumRepo.throttle == null ? null : originalYumRepo.throttle.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "bandwidth";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.bandwidth == null ? null : currentYumRepo.bandwidth.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.bandwidth == null ? null : currentYumRepo.bandwidth.toString(), originalYumRepo.bandwidth == null ? null : originalYumRepo.bandwidth.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "mirrorlist_expire";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.mirrorlist_expire == null ? null : currentYumRepo.mirrorlist_expire.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.mirrorlist_expire == null ? null : currentYumRepo.mirrorlist_expire.toString(), originalYumRepo.mirrorlist_expire == null ? null : originalYumRepo.mirrorlist_expire.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "proxy";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.proxy == null ? null : currentYumRepo.proxy.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.proxy == null ? null : currentYumRepo.proxy.toString(), originalYumRepo.proxy == null ? null : originalYumRepo.proxy.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "proxy_username";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.proxy_username == null ? null : currentYumRepo.proxy_username.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.proxy_username == null ? null : currentYumRepo.proxy_username.toString(), originalYumRepo.proxy_username == null ? null : originalYumRepo.proxy_username.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "proxy_password";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.proxy_password == null ? null : currentYumRepo.proxy_password.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.proxy_password == null ? null : currentYumRepo.proxy_password.toString(), originalYumRepo.proxy_password == null ? null : originalYumRepo.proxy_password.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "username";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.username == null ? null : currentYumRepo.username.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.username == null ? null : currentYumRepo.username.toString(), originalYumRepo.username == null ? null : originalYumRepo.username.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "password";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.password == null ? null : currentYumRepo.password.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.password == null ? null : currentYumRepo.password.toString(), originalYumRepo.password == null ? null : originalYumRepo.password.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "cost";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.cost == null ? null : currentYumRepo.cost.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.cost == null ? null : currentYumRepo.cost.toString(), originalYumRepo.cost == null ? null : originalYumRepo.cost.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "skip_if_unavailable";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.skip_if_unavailable == null ? null : currentYumRepo.skip_if_unavailable.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.skip_if_unavailable == null ? null : currentYumRepo.skip_if_unavailable.toString(), originalYumRepo.skip_if_unavailable == null ? null : originalYumRepo.skip_if_unavailable.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "ui_repoid_vars";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.ui_repoid_vars == null ? null : currentYumRepo.ui_repoid_vars.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.ui_repoid_vars == null ? null : currentYumRepo.ui_repoid_vars.toString(), originalYumRepo.ui_repoid_vars == null ? null : originalYumRepo.ui_repoid_vars.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "priority";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.priority == null ? null : currentYumRepo.priority.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            Assert.assertEquals(currentYumRepo.priority == null ? null : currentYumRepo.priority.toString(), originalYumRepo.priority == null ? null : originalYumRepo.priority.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "sslclientcert";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.sslclientcert == null ? null : currentYumRepo.sslclientcert.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            if (includeVerificationOfNames_sslclient)
                Assert.assertEquals(currentYumRepo.sslclientcert == null ? null : currentYumRepo.sslclientcert.toString(), originalYumRepo.sslclientcert == null ? null : originalYumRepo.sslclientcert.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
        name = "sslclientkey";
        if (repoOverridesMapOfMaps.containsKey(repoId) && repoOverridesMapOfMaps.get(repoId).containsKey(name)) {
            Assert.assertEquals(currentYumRepo.sslclientkey == null ? null : currentYumRepo.sslclientkey.toString(), repoOverridesMapOfMaps.get(repoId).get(name), "The repo-override for repoId='" + repoId + "' name='" + name + "'.");
        } else {
            if (includeVerificationOfNames_sslclient)
                Assert.assertEquals(currentYumRepo.sslclientkey == null ? null : currentYumRepo.sslclientkey.toString(), originalYumRepo.sslclientkey == null ? null : originalYumRepo.sslclientkey.toString(), "There should NOT be a repo-override for repoId='" + repoId + "' name='" + name + "'.");
        }
    }
}
Also used : YumRepo(rhsm.data.YumRepo)

Example 19 with YumRepo

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

the class RepoOverrideTests method testRhsmConfigurationForFullRefreshOnYum.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21860", "RHEL7-51708" }, 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 = "verify that the rhsm.full_refresh_on_yum is working properly", groups = { "Tier3Tests", "VerifyRhsmConfigurationForFullRefreshOnYum_Test" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRhsmConfigurationForFullRefreshOnYum() {
    // There is a new rhsm.conf parameter called full_refresh_on_yum = 0 (default) or 1 that is a boolean for
    // telling the subscription-manager yum plugin whether or not to use the repo overrides defined in
    // /var/lib/rhsm/cache/content_overrides.json (when full_refresh_on_yum=0) or if the subscription-manager
    // yum plugin should go to the candlepin server and fetch the latest overrides defined for this consumer
    // at the candlepin server and then complete the yum transaction.
    // We will test the functionality of this configuration by adding repo overrides, then deleting the cache
    // followed by a yum transaction to verify that the override is no longer present in the redhat.repo file.
    // Then by changing to full_refresh_on_yum=1, the overrides will re-appear in the redhat.repo file after
    // running a yum transaction
    // remember the original configured value for rhsm.full_refresh_on_yum so we can restore it after the test
    rhsmFullRefreshOnYumConfigured = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "full_refresh_on_yum");
    // assume we are starting with the default rhsm.full_refresh_on_yum=0
    Assert.assertEquals(clienttasks.getConfParameter("full_refresh_on_yum"), "0", "The expected default value for configuration parameter rhsm.full_refresh_on_yum.");
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, 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 one random repo
    YumRepo originalYumRepo = getRandomSubsetOfList(originalYumRepos, 1).get(0);
    YumRepo currentYumRepo;
    // add several repo overrides
    String repoId = originalYumRepo.id;
    String name;
    Map<String, Map<String, String>> repoOverridesMapOfMaps = new HashMap<String, Map<String, String>>();
    Map<String, String> repoOverrideNameValueMap = new HashMap<String, String>();
    repoOverrideNameValueMap.put("retries", "5");
    repoOverrideNameValueMap.put("timeout", "40");
    // put the opposite of originalYumRepo.enabled
    repoOverrideNameValueMap.put("enabled", originalYumRepo.enabled ? Boolean.FALSE.toString() : Boolean.TRUE.toString());
    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
    clienttasks.getYumRepolist("all");
    currentYumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repoId, clienttasks.getCurrentlySubscribedYumRepos());
    name = "retries";
    Assert.assertEquals(currentYumRepo.retries, repoOverrideNameValueMap.get(name), "After adding a repo-override for repoId '" + repoId + "' parameter '" + name + "' and running a yum transaction, the subscription-manager yum plugin should read the repo overrides from cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "' and apply them to '" + clienttasks.redhatRepoFile + "'.");
    name = "timeout";
    Assert.assertEquals(currentYumRepo.timeout, repoOverrideNameValueMap.get(name), "After adding a repo-override for repoId '" + repoId + "' parameter '" + name + "' and running a yum transaction, the subscription-manager yum plugin should read the repo overrides from cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "' and apply them to '" + clienttasks.redhatRepoFile + "'.");
    name = "enabled";
    Assert.assertEquals(currentYumRepo.enabled.toString(), repoOverrideNameValueMap.get(name), "After adding a repo-override for repoId '" + repoId + "' parameter '" + name + "' and running a yum transaction, the subscription-manager yum plugin should read the repo overrides from cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "' and apply them to '" + clienttasks.redhatRepoFile + "'.");
    // now let's delete the cache for /var/lib/rhsm/cache/content_overrides.json and verify that
    // after running a yum transaction, the override is no longer present (because full_refresh_on_yum=0)
    client.runCommandAndWait("rm -f " + clienttasks.rhsmCacheRepoOverridesFile);
    clienttasks.getYumRepolist("all");
    currentYumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repoId, clienttasks.getCurrentlySubscribedYumRepos());
    name = "retries";
    Assert.assertEquals(currentYumRepo.retries, originalYumRepo.retries, "After removing '" + clienttasks.rhsmCacheRepoOverridesFile + "' and running a yum transaction, the repo overrides in the '" + clienttasks.redhatRepoFile + "' should be gone; orginal values should be restored for repoId '" + repoId + "' parameter '" + name + "'.");
    name = "timeout";
    Assert.assertEquals(currentYumRepo.timeout, originalYumRepo.timeout, "After removing '" + clienttasks.rhsmCacheRepoOverridesFile + "' and running a yum transaction, the repo overrides in the '" + clienttasks.redhatRepoFile + "' should be gone; orginal values should be restored for repoId '" + repoId + "' parameter '" + name + "'.");
    name = "enabled";
    Assert.assertEquals(currentYumRepo.enabled, originalYumRepo.enabled, "After removing '" + clienttasks.rhsmCacheRepoOverridesFile + "' and running a yum transaction, the repo overrides in the '" + clienttasks.redhatRepoFile + "' should be gone; orginal values should be restored for repoId '" + repoId + "' parameter '" + name + "'.");
    Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.rhsmCacheRepoOverridesFile), "Re-asserting cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "' has been deleted.");
    // now let's set rhsm.full_refresh_on_yum to 1 and test...
    clienttasks.config(null, null, true, new String[] { "rhsm", "full_refresh_on_yum", "1" });
    clienttasks.getYumRepolist("all");
    currentYumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repoId, clienttasks.getCurrentlySubscribedYumRepos());
    name = "retries";
    Assert.assertEquals(currentYumRepo.retries, repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=1 and invoking a yum transaction, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
    name = "timeout";
    Assert.assertEquals(currentYumRepo.timeout, repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=1 and invoking a yum transaction, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
    name = "enabled";
    Assert.assertEquals(currentYumRepo.enabled.toString(), repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=1 and invoking a yum transaction, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
    Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.rhsmCacheRepoOverridesFile), "Testing for the restoration of cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "'.");
    // now let's test that a trigger of rhsmcertd will restore the cache even when rhsm.full_refresh_on_yum=0
    clienttasks.config(null, null, true, new String[] { "rhsm", "full_refresh_on_yum", "0" });
    client.runCommandAndWait("rm -f " + clienttasks.rhsmCacheRepoOverridesFile);
    Assert.assertFalse(RemoteFileTasks.testExists(client, clienttasks.rhsmCacheRepoOverridesFile));
    // clienttasks.restart_rhsmcertd(null, null, false, true);	// use run_rhsmcertd_worker as a faster alternative to restart_rhsmcertd
    clienttasks.run_rhsmcertd_worker(null);
    Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.rhsmCacheRepoOverridesFile), "Testing for the restoration of cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "' after running rhsmcertd_worker to trigger a certificates update.");
    clienttasks.getYumRepolist("all");
    currentYumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", repoId, clienttasks.getCurrentlySubscribedYumRepos());
    name = "retries";
    Assert.assertEquals(currentYumRepo.retries, repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=0, deleting the cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "', and restarting the rhsmcertd service, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
    name = "timeout";
    Assert.assertEquals(currentYumRepo.timeout, repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=0, deleting the cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "', and restarting the rhsmcertd service, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
    name = "enabled";
    Assert.assertEquals(currentYumRepo.enabled.toString(), repoOverrideNameValueMap.get(name), "After setting rhsm.full_refresh_on_yum=0, deleting the cache file '" + clienttasks.rhsmCacheRepoOverridesFile + "', and restarting the rhsmcertd service, repoId '" + repoId + "' override for parameter '" + name + "' should have been restorted in the '" + clienttasks.redhatRepoFile + "'.");
}
Also used : HashMap(java.util.HashMap) 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 20 with YumRepo

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

the class RepoOverrideTests method testAddAndRemoveRepoOverridesUsingMultipleRepos.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19977", "RHEL7-33077" }, 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 across multiple repo ids simultaneously (use multiple --repo args)", groups = { "Tier1Tests", "blockedByBug-1069230", "blockedByBug-1034396" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAddAndRemoveRepoOverridesUsingMultipleRepos() {
    // 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 (specifying all repos in multiplicity)
    Map<String, Map<String, String>> repoOverridesMapOfMaps = new HashMap<String, Map<String, String>>();
    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");
    for (YumRepo yumRepo : originalYumReposSubset) repoOverridesMapOfMaps.put(yumRepo.id, repoOverrideNameValueMap);
    List<String> repoIds = new ArrayList<String>(repoOverridesMapOfMaps.keySet());
    clienttasks.repo_override(null, null, repoIds, 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 multiple repos using repo-override and verify the list
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "name" }), null, null, null, null, null);
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "name", "enabled", "ui_repoid_vars" }), null, null, null, null, null);
    // clienttasks.repo_override(null,null,repoids,Arrays.asList(new String[]{"gpgcheck","exclude","retries"}),null,null,null,null);	// for test variability, let's not delete these
    clienttasks.repo_override(null, null, repoIds, Arrays.asList(new String[] { "sslverify", "sslcacert", "sslclientkey", "sslclientcert" }), null, null, null, null, null);
    for (String repoId : repoIds) {
        repoOverridesMapOfMaps.get(repoId).remove("name");
        repoOverridesMapOfMaps.get(repoId).remove("enabled");
        repoOverridesMapOfMaps.get(repoId).remove("ui_repoid_vars");
        // repoOverridesMapOfMaps.get(repoId).remove("gpgcheck");
        // repoOverridesMapOfMaps.get(repoId).remove("exclude");
        // repoOverridesMapOfMaps.get(repoId).remove("retries");
        repoOverridesMapOfMaps.get(repoId).remove("sslverify");
        repoOverridesMapOfMaps.get(repoId).remove("sslcacert");
        repoOverridesMapOfMaps.get(repoId).remove("sslclientkey");
        repoOverridesMapOfMaps.get(repoId).remove("sslclientcert");
    }
    // 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, (List<String>) null, (List<String>) null, null, null, null, null, null);
    repoOverridesMapOfMaps.clear();
    // 3/23/2015 ocassional workaround needed to remove stale repos from /etc/yum.repos.d/redhat.repo	// TODO figure out how to remove this
    clienttasks.getYumRepolist(null);
    // 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) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) YumRepo(rhsm.data.YumRepo) HashMap(java.util.HashMap) Map(java.util.Map) 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