use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class BugzillaTests method testNewContentAvailability.
/**
* @author redakkan
* @throws Exception
* JSON Exception
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-38192", "RHEL7-77384" }, 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 the newly added content set is immediatly available on the client", groups = { "Tier3Tests", "VerifyNewContentAvailability", "blockedByBug-1360909" }, enabled = true)
public void testNewContentAvailability() throws JSONException, Exception {
String resourcePath = null;
String requestBody = null;
String ProductId = "32060";
String contentId = "1234";
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();
// checking subscribed repos
List<Repo> subscribedRepo = clienttasks.getCurrentlySubscribedRepos();
if (subscribedRepo.isEmpty())
throw new SkipException("There are no entitled yum repos available for this test.");
// getting the list of all enabled repos
// SSHCommandResult sshCommandResult = clienttasks.repos(null, true, false, (String) null, (String) null, null,
// null, null);
// in test data verifying that already enabled repos are not available
// List<Repo> listEnabledRepos = Repo.parse(sshCommandResult.getStdout());
// Assert.assertTrue(listEnabledRepos.isEmpty(), "No attached subscriptions provides a enabled repos .");
// Create a new content "Newcontent_foo"
requestBody = CandlepinTasks.createContentRequestBody("Newcontent_foo", contentId, "Newcontent_foo", "yum", "Foo Vendor", "/foo/path", "/foo/path/gpg", null, null, null, null).toString();
resourcePath = "/content";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
resourcePath = "/owners/" + sm_clientOrg + resourcePath;
CandlepinTasks.postResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath, requestBody);
// Link the newly created content to product id , by default the repo is enabled
CandlepinTasks.addContentToProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, ProductId, contentId, true);
CandlepinTasks.postResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath, requestBody);
// any newly added content to the product should be immediately
// available when using server > 2.0
List<Repo> listEnabledRepos;
SSHCommandResult sshCommandResult;
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0")) {
// look for the newly added content available in repo list-enabled
// by getting the list of currently enabled repos
sshCommandResult = clienttasks.repos(null, true, null, (String) null, (String) null, null, null, null, null);
listEnabledRepos = Repo.parse(sshCommandResult.getStdout());
for (Repo repo : listEnabledRepos) {
if (repo.repoId.matches("Newcontent_foo")) {
Assert.assertTrue(repo.repoId.matches("Newcontent_foo"), "contains newly added repos Newcontent_foo");
Assert.assertNotNull(listEnabledRepos, "Enabled yum repo [" + repo.repoId + "] is included in the report of repos --list-enabled.");
}
}
} else if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.0.0") && (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.10-1"))) {
// commit
// c38ae2c2e2f0e59674aa670d8ff3264d66737ede // Bug // 1360909 // -// Clients unable to access newly released content (Satellite 6.2 GA)
// remember the currently consumed product subscriptions
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
// refresh to update the entitlement certs on the client
log.info("Refresh...");
clienttasks.refresh(null, null, null, null);
sshCommandResult = clienttasks.repos(null, true, null, (String) null, (String) null, null, null, null, null);
listEnabledRepos = Repo.parse(sshCommandResult.getStdout());
for (Repo repo : listEnabledRepos) {
if (repo.repoId.equals("Newcontent_foo")) {
Assert.assertTrue(repo.repoId.matches("Newcontent_foo"), "contains newly added repos Newcontent_foo");
Assert.assertNotNull(listEnabledRepos, "Enabled yum repo [" + repo.repoId + "] is included in the report of repos --list-enabled.");
}
}
// Assert the entitlement certs are restored after the refresh
log.info("After running refresh, assert that the entitlement certs are restored...");
Assert.assertEquals(clienttasks.getCurrentlyConsumedProductSubscriptions().size(), consumedProductSubscriptions.size(), "all the consumed product subscriptions have been restored.");
} else {
throw new SkipException("Bugzilla 1360909 was not fixed in this old version of subscription-manager.");
}
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class BugzillaTests method getVerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists.
protected List<List<Object>> getVerifyEUSRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists() throws JSONException, Exception {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
if (clienttasks == null)
return ll;
String eusProductId = null;
if ((clienttasks.arch.equals("ppc64")) && (clienttasks.variant.equals("Server")))
eusProductId = "75";
else if ((clienttasks.arch.equals("x86_64")) && (clienttasks.variant.equals("Server")))
eusProductId = "70";
else if ((clienttasks.arch.equals("x86_64")) && clienttasks.variant.equals("ComputeNode"))
eusProductId = "217";
else if ((clienttasks.arch.equals("s390x")) && (clienttasks.variant.equals("Server")))
eusProductId = "73";
if (eusProductId == null) {
log.warning("This test does not yet cover variant '" + clienttasks.variant + "' on arch '" + clienttasks.arch + "'.");
// return no rows and no test will be run
return ll;
}
// unregister
clienttasks.unregister(null, null, null, null);
// register
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
// get current product cert and verify that rhelproduct is installed on
// the system
ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
SubscriptionPool pool = null;
for (SubscriptionPool eusSubscriptionPool : SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, null, "*Extended*", null, null, null, null, null).getStdout())) {
if ((CandlepinTasks.getPoolProvidedProductIds(sm_client1Username, sm_client1Password, sm_serverUrl, eusSubscriptionPool.poolId).contains(eusProductId))) {
// and attach eus subscription
clienttasks.subscribe(null, null, eusSubscriptionPool.poolId, null, null, null, null, null, null, null, null, null, null);
pool = eusSubscriptionPool;
break;
}
}
if (pool == null) {
log.warning("Could not find an available EUS subscription that covers EUS product '" + eusProductId + "'.");
// return no rows and no test will be run
return ll;
}
// find the entitlement that provides access to RHEL and EUS
EntitlementCert eusEntitlementCerts = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
if (eusEntitlementCerts == null) {
return ll;
}
// if eus repo is not enabled , enable it
String rhelRepoUrl = null;
for (Repo disabledRepo : Repo.parse(clienttasks.repos(null, false, true, (String) null, (String) null, null, null, null, null).getStdout())) {
String variant = null;
if (clienttasks.arch.equals("x86_64")) {
if (clienttasks.variant.equals("ComputeNode"))
variant = "hpc-node";
if (clienttasks.variant.equals("Server"))
variant = "server";
} else if (clienttasks.arch.equals("ppc64") || (clienttasks.arch.equals("ppc64le"))) {
variant = "for-power";
} else if (clienttasks.arch.equals("s390x"))
variant = "for-system-z";
// add repos for eus-source rpms and debug rpms
if ((disabledRepo.repoId.matches("rhel-[0-9]+-" + variant + "-eus-rpms"))) {
clienttasks.repos(null, null, null, disabledRepo.repoId, (String) null, null, null, null, null);
}
}
for (// if eus repo is enabled then add it to the data provider
Repo enabledRepo : Repo.parse(clienttasks.repos(null, true, false, (String) null, (String) null, null, null, null, null).getStdout())) {
if (enabledRepo.enabled) {
String variant = null;
if (clienttasks.arch.equals("x86_64")) {
if (clienttasks.variant.equals("ComputeNode"))
variant = "hpc-node";
if (clienttasks.variant.equals("Server"))
variant = "server";
} else if (clienttasks.arch.equals("ppc64") || (clienttasks.arch.equals("ppc64le"))) {
variant = "for-power";
} else if (clienttasks.arch.equals("s390x"))
variant = "for-system-z";
if (enabledRepo.repoId.matches("rhel-[0-9]+-" + variant + "-eus-rpms")) {
rhelRepoUrl = enabledRepo.repoUrl;
}
}
}
// against ppc64le
for (String release : clienttasks.getCurrentlyAvailableReleases(null, null, null, null)) {
// skip the latest releases; e.g. 6Server
if (!isFloat(release))
continue;
List<String> bugIds = new ArrayList<String>();
if (release.startsWith("6")) {
if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c16
bugIds.add("1357574");
if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("i386"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c18
bugIds.add("1357574");
if (release.matches("6.5") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c19
bugIds.add("1357574");
if (release.matches("6.6") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64"))
// https://bugzilla.redhat.com/show_bug.cgi?id=1357574#c19
bugIds.add("1357574");
if (release.matches("6.7") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64"))
bugIds.add("1352162");
}
if (release.startsWith("7")) {
if (// && clienttasks.variant.equals("Server"))
release.matches("7.1"))
bugIds.add("1369920");
}
BlockedByBzBug blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
ll.add(Arrays.asList(new Object[] { blockedByBzBug, release, rhelRepoUrl, eusEntitlementCerts.file }));
}
return ll;
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class GoldenTicketTests method testRepoOverridePreference.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47904", "RHEL7-96742" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : Org/Environment Level Content Access
workitemId = "RHEL6-47900", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : Org/Environment Level Content Access
workitemId = "RHEL7-85127", 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.POSITIVE, importance = DefTypes.Importance.MEDIUM, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "Verify SKU level contentOverride is given priority over default golden ticket one", groups = { "Tier3Tests", "blockedByBug-1427069" }, enabled = true)
public void testRepoOverridePreference() throws Exception {
List<Repo> availableRepos = new ArrayList<Repo>();
List<String> repoIdsDisabledByDefault = new ArrayList<String>();
Map<String, String> attributesMap = new HashMap<String, String>();
String resourcePath = null;
String ExpectedRepoMsg = "There were no available repositories matching the specified criteria.";
CandlepinTasks.setAttributeForOrg(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, org, attributeName, attributeValue);
String consumerId = clienttasks.getCurrentConsumerId(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));
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId);
for (SubscriptionPool availsubscriptions : clienttasks.getAvailableSubscriptionsMatchingInstalledProducts()) {
subscriptionPoolProductId = availsubscriptions.productId;
subscriptionPoolId = availsubscriptions.poolId;
clienttasks.subscribe(null, null, subscriptionPoolId, null, null, null, null, null, null, null, null, null, null);
SSHCommandResult repoResult = clienttasks.repos(true, false, false, (String) null, null, null, null, null, null);
if (!(repoResult.getStdout().trim().equals("This system has no repositories available through subscriptions."))) {
break;
}
}
// clienttasks.subscribe(null, null,subscriptionPoolId, null, null, null, null, null, null, null, null, null, null);
// List<Repo>
availableRepos = clienttasks.getCurrentlySubscribedRepos();
SSHCommandResult repoResult = clienttasks.repos(false, false, true, (String) null, null, null, null, null, null);
Assert.assertNotEquals(repoResult.getStdout().toString().trim(), ExpectedRepoMsg);
SSHCommandResult enabledResult = clienttasks.repos(false, true, false, (String) null, null, null, null, null, null);
Assert.assertEquals(enabledResult.getStdout().toString().trim(), ExpectedRepoMsg);
// entitled by the subscriptionpool
for (Repo repo : availableRepos) {
if (!(repo.enabled)) {
repoIdsDisabledByDefault.add(repo.repoId);
}
}
String repoIdToEnable = repoIdsDisabledByDefault.get(randomGenerator.nextInt(repoIdsDisabledByDefault.size()));
String contentIdToEnable = getContent(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, repoIdToEnable);
resourcePath = "/owners/" + ownerKey + "/products/" + subscriptionPoolProductId + "?exclude=id&exclude=name&exclude=multiplier&exclude=productContent&exclude=dependentProductIds&exclude=href&exclude=created&exclude=updated&exclude=attributes.created&exclude=attributes.updated";
JSONObject jsonPoolToEnable = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath));
resourcePath = "/owners/" + ownerKey + "/products/" + subscriptionPoolProductId;
JSONArray jsonProductAttributesToEnable = jsonPoolToEnable.getJSONArray("attributes");
JSONObject jsonDataToEnable = new JSONObject();
attributesMap.clear();
attributesMap.put("name", "content_override_enabled");
attributesMap.put("value", contentIdToEnable);
// WARNING: if jsonProductAttributesToEnable already contains an
// attribute(s) with the name "content_override_enabled", then duplicate
// attributes will get PUT on the SKU. That's bad. Candlepin should not
// allow this, but it does. Avoid this by calling
// purgeJSONObjectNamesFromJSONArray(...)
jsonProductAttributesToEnable = purgeJSONObjectNamesFromJSONArray(jsonProductAttributesToEnable, "content_override_enabled");
jsonProductAttributesToEnable.put(attributesMap);
jsonDataToEnable.put("attributes", jsonProductAttributesToEnable);
CandlepinTasks.putResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath, jsonDataToEnable);
CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
clienttasks.subscribe(null, null, subscriptionPoolId, null, null, null, null, null, null, null, null, null, null);
Assert.assertTrue(clienttasks.repos_(null, true, null, (String) null, null, null, null, null, null).getStdout().contains(repoIdToEnable), "After subscribing to SKU '" + subscriptionPoolProductId + "' which contains a content_override_enabled for repoId '" + repoIdToEnable + "' (contentid='" + contentIdToEnable + "'), it now appears in the list of enabled subscription-manager repos.");
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testFixForBug1223038.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20398", "RHEL7-51696" }, 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 RepoActionInvoker.is_managed('some_repo') returns False when 'some_repo' does not exist and True when it is entitled", groups = { "Tier3Tests", "blockedByBug-1223038" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testFixForBug1223038() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.14.9-1"))
throw new SkipException("The fix for this bug was not implemented until version subscription-manager-1.14.9-1");
// copy the ismanagedtest.py script to the client
File ismanagedtestFile = new File(System.getProperty("automation.dir", null) + "/scripts/ismanagedtest.py");
if (!ismanagedtestFile.exists())
Assert.fail("Failed to find expected script: " + ismanagedtestFile);
RemoteFileTasks.putFile(client, ismanagedtestFile.toString(), "/usr/local/bin/", "0755");
RemoteFileTasks.runCommandAndAssert(client, "ismanagedtest.py some_repo", 0, "False", null);
// while registered and subscribed to a repo (either enabled or disabled), call ismanagedtest.py repo should be true
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<Repo> repos = clienttasks.getCurrentlySubscribedRepos();
// for (Repo repo : repos) {
for (Repo repo : getRandomSubsetOfList(repos, 5)) {
RemoteFileTasks.runCommandAndAssert(client, "ismanagedtest.py " + repo.repoId, 0, "True", null);
}
}
use of rhsm.data.Repo in project rhsm-qe by RedHatQE.
the class ReposTests method testReposListDisabledReportsNoMatchesFoundWhenNoThereAreNoDisabledRepos.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20300", "RHEL7-51683" }, 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-disabled should give feedback when there are no disabled repos", groups = { "Tier3Tests", "blockedByBug-1151925" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReposListDisabledReportsNoMatchesFoundWhenNoThereAreNoDisabledRepos() 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.");
// use a wildcard to enable 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, false, true, (String) null, (String) null, null, null, null, null);
List<Repo> listDisabledRepos = Repo.parse(sshCommandResult.getStdout());
Assert.assertTrue(listDisabledRepos.isEmpty(), "After using a wildcard to enable all repos, the repos --list-disabled should be empty.");
// assert the feedback when no repos are enabled
String expectedStdout = "There were no available repositories matching the specified criteria.";
Assert.assertEquals(sshCommandResult.getStdout().trim(), expectedStdout, "After using a wildcard to enable all repos, the repos --list-disabled should report feedback indicating no matches.");
}
Aggregations