use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method getCurrentlyExpectedReleases.
/**
* @return list of the expected releases currently available based on the currently enabled repo content and this major RHEL release
*/
public List<String> getCurrentlyExpectedReleases() {
HashSet<String> expectedReleaseSet = new HashSet<String>();
String baseurl = getConfFileParameter(rhsmConfFile, "rhsm", "baseurl");
List<ProductCert> productCerts = getCurrentProductCerts();
// loop through all of the currently entitled repo urls
for (EntitlementCert entitlementCert : getCurrentEntitlementCerts()) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (contentNamespace.type.equalsIgnoreCase("yum")) {
if (contentNamespace.enabled) {
// Bug 820639 - subscription-manager release --list should exclude listings from disabled repos
if (areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, productCerts)) {
// Bug 861151 - subscription-manager release doesn't take variant into account
if (contentNamespace.downloadUrl.contains("$releasever")) {
if (contentNamespace.downloadUrl.contains("/" + redhatReleaseX + "/")) {
// Bug 818298 - subscription-manager release --list should not display releasever applicable to rhel-5 when only rhel-6 product is installed
// example contentNamespace.downloadUrl: /content/dist/rhel/server/5/$releasever/$basearch/iso
String listingUrl = contentNamespace.downloadUrl.startsWith("http") ? "" : baseurl;
listingUrl += contentNamespace.downloadUrl.split("/\\$releasever/")[0];
listingUrl += "/listing";
String command = String.format("curl --stderr /dev/null --insecure --tlsv1 --cert %s --key %s %s", entitlementCert.file.getPath(), getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(entitlementCert.file).getPath(), listingUrl);
SSHCommandResult result = sshCommandRunner.runCommandAndWaitWithoutLogging(command);
// process exceptional results...
if (result.getStdout().toUpperCase().contains("<HTML>")) {
// [root@jsefler-6 ~]# curl --stderr /dev/null --insecure --tlsv1 --cert /etc/pki/entitlement/3360706382464344965.pem --key /etc/pki/entitlement/3360706382464344965-key.pem https://cdn.redhat.com/content/dist/rhel/server/6/listing
// <HTML><HEAD>
// <TITLE>Access Denied</TITLE>
// </HEAD><BODY>
// <H1>Access Denied</H1>
// or should this be a failure?
log.warning("curl result: " + result);
Assert.fail("Expected to retrieve a list of available release versions. (Example: 6.1, 6.2, 6Server)");
} else if (result.getStdout().trim().startsWith("Unable to locate content")) {
// [root@jsefler-5 ~]# curl --stderr /dev/null --insecure --tlsv1 --cert /etc/pki/entitlement/6653190787244398414.pem --key /etc/pki/entitlement/6653190787244398414-key.pem https://cdn.qa.redhat.com/content/aus/rhel/server/5/listing
// Unable to locate content /content/aus/rhel/server/5/listing
// or should this be a failure?
log.warning("curl result: " + result);
log.warning("Query failed to get an expected release listing from ContentNamespace: \n" + contentNamespace);
log.warning("After setting an older release, a yum repolist of this content set will likely yield: [Errno 14] HTTP Error 404: Not Found");
} else {
expectedReleaseSet.addAll(Arrays.asList(result.getStdout().trim().split("\\s*\\n\\s*")));
}
}
}
}
}
}
}
}
return new ArrayList<String>(expectedReleaseSet);
// ^^ TODO On second thought, it would technically be more correct to loop over the current YumRepo object rather than the Entitlement Certs since a repo enablement could have been manually overridden
// TODO work in progress
// for (YumRepo yumRepo : getCurrentlySubscribedYumRepos()()) {
// if (yumRepo.enabled) { // Bug 820639 - subscription-manager release --list should exclude listings from disabled repos
// if (yumRepo.baseurl.contains("$releasever")) {
// if (yumRepo.baseurl.contains("/"+redhatReleaseX+"/")) { // Bug 818298 - subscription-manager release --list should not display releasever applicable to rhel-5 when only rhel-6 product is installed
// // example contentNamespace.downloadUrl: /content/dist/rhel/server/5/$releasever/$basearch/iso
// String listingUrl = yumRepo.baseurl.startsWith("http")? "":baseurl;
// listingUrl += yumRepo.baseurl.split("/\\$releasever/")[0];
// listingUrl += "/listing";
// String command = String.format("curl --stderr /dev/null --insecure --cert %s --key %s %s" , entitlementCert.file.getPath(), getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(entitlementCert.file).getPath(), listingUrl);
// SSHCommandResult result = sshCommandRunner.runCommandAndWaitWithoutLogging(command);
// // [root@qe-blade-13 ~]# curl --stderr /dev/null --insecure --cert /etc/pki/entitlement/2013167262444796312.pem --key /etc/pki/entitlement/2013167262444796312-key.pem https://cdn.rcm-qa.redhat.com/content/dist/rhel/server/6/listing
// // 6.1
// // 6.2
// // 6Server
// expectedReleaseSet.addAll(Arrays.asList(result.getStdout().trim().split("\\s*\\n\\s*")));
// }
// }
// }
// }
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method setupBeforeSuite.
// Configuration Methods ***********************************************************************
@BeforeSuite(groups = { "setup" }, description = "subscription manager set up")
public void setupBeforeSuite() throws IOException, JSONException {
if (isSetupBeforeSuiteComplete)
return;
// create SSHCommandRunners to connect to the subscription-manager clients
File sshKeyPrivateKeyFile = new File(System.getProperty("automation.dir", null) + "/" + sm_sshKeyPrivate);
if (!sshKeyPrivateKeyFile.exists())
Assert.fail("Expected to find the private ssh key for automation testing at '" + sshKeyPrivateKeyFile + "'. Ask the RHSM Automation Administrator for a copy.");
client1 = new SSHCommandRunner(sm_client1Hostname, sm_client1SSHUser, new File(sm_sshKeyPrivate), sm_sshkeyPassphrase, null);
if (sm_sshEmergenecyTimeoutMS != null)
client1.setEmergencyTimeout(Long.valueOf(sm_sshEmergenecyTimeoutMS));
client1tasks = new SubscriptionManagerTasks(client1);
client = client1;
clienttasks = client1tasks;
// will we be testing multiple clients?
if (!(sm_client2Hostname.equals(""))) {
client2 = new SSHCommandRunner(sm_client2Hostname, sm_client2SSHUser, new File(sm_sshKeyPrivate), sm_sshkeyPassphrase, null);
if (sm_sshEmergenecyTimeoutMS != null)
client2.setEmergencyTimeout(Long.valueOf(sm_sshEmergenecyTimeoutMS));
client2tasks = new SubscriptionManagerTasks(client2);
} else {
log.info("Multi-client testing will be skipped.");
}
// unregister clients in case they are still registered from prior run (DO THIS BEFORE SETTING UP A NEW CANDLEPIN)
unregisterClientsAfterSuite();
// Beaker test_log-Setup.log :: [ FAIL ] :: FIPS on s390 on RHEL <7.1 is not supported (Assert: expected 0, got 1)
if (client1 != null) {
Assert.assertEquals(client1.runCommandAndWait("sysctl crypto.fips_enabled").getStdout().trim(), "crypto.fips_enabled = " + (sm_clientFips ? "1" : "0"), "Asserting the expected enablement of FIPS on client '" + sm_client1Hostname + "' before running any tests.");
}
if (client2 != null) {
Assert.assertEquals(client2.runCommandAndWait("sysctl crypto.fips_enabled").getStdout().trim(), "crypto.fips_enabled = " + (sm_clientFips ? "1" : "0"), "Asserting the expected enablement of FIPS on client '" + sm_client2Hostname + "' before running any tests.");
}
List<File> generatedProductCertFiles = new ArrayList<File>();
// can we create an SSHCommandRunner to connect to the candlepin server ?
if (!sm_serverHostname.equals("") && sm_serverType.equals(CandlepinType.standalone)) {
server = new SSHCommandRunner(sm_serverHostname, sm_serverSSHUser, new File(sm_sshKeyPrivate), sm_sshkeyPassphrase, null);
if (sm_sshEmergenecyTimeoutMS != null)
server.setEmergencyTimeout(Long.valueOf(sm_sshEmergenecyTimeoutMS));
servertasks = new rhsm.cli.tasks.CandlepinTasks(server, sm_serverInstallDir, sm_serverImportDir, sm_serverType, sm_serverBranch, sm_dbSqlDriver, sm_dbHostname, sm_dbPort, sm_dbName, sm_dbUsername, sm_dbPassword);
} else {
log.info("Assuming the server is already setup and running.");
servertasks = new rhsm.cli.tasks.CandlepinTasks(null, null, null, sm_serverType, sm_serverBranch, sm_dbSqlDriver, sm_dbHostname, sm_dbPort, sm_dbName, sm_dbUsername, sm_dbPassword);
}
// setup the candlepin server (only when the candlepin server is standalone)
if (server != null && sm_serverType.equals(CandlepinType.standalone)) {
// I suggest manually setting this on hosted and asking calfanso to restart
if (servertasks.getConfFileParameter("pinsetter.org.fedoraproject.candlepin.pinsetter.tasks.CertificateRevocationListTask.schedule") == null) {
servertasks.addConfFileParameter("\n# purge the CRL list every 2 min\npinsetter.org.fedoraproject.candlepin.pinsetter.tasks.CertificateRevocationListTask.schedule", "0 0/2 * * * ?");
} else {
// every 2 minutes
servertasks.updateConfFileParameter("pinsetter.org.fedoraproject.candlepin.pinsetter.tasks.CertificateRevocationListTask.schedule", "0 0\\/2 * * * ?");
}
servertasks.cleanOutCRL();
servertasks.deploy();
server.runCommandAndWait("df -h");
// log candlepin's starting disk usage (for debugging information only)
server.runCommandAndWait("sudo " + "ls -Slh " + servertasks.getTomcatLogFile().getParent() + " | head");
servertasks.setupTranslateToolkitFromTarUrl(sm_translateToolkitTarUrl);
servertasks.reportAPI();
// install packages
SSHCommandResult yumInstallResult = server.runCommandAndWait("sudo " + "yum install -y --quiet hunspell");
Assert.assertEquals(yumInstallResult.getExitCode(), Integer.valueOf(0), "ExitCode from yum install of packages on server '" + server.getConnection().getRemoteHostname() + "'.");
// fetch the generated Product Certs
if (Boolean.valueOf(getProperty("sm.debug.fetchProductCerts", "true"))) {
log.info("Fetching the generated product certs...");
// SSHCommandResult result = RemoteFileTasks.runCommandAndAssert(server, "find "+serverInstallDir+servertasks.generatedProductsDir+" -name '*.pem'", 0);
// SSHCommandResult result = server.runCommandAndWait("find "+sm_serverInstallDir+servertasks.generatedProductsDir+" -name '*.pem'"); // find /root/candlepin/server/generated_certs -name '*.pem'
// find /home/candlepin/candlepin -name '*.pem' | grep generated_certs
SSHCommandResult result = server.runCommandAndWait("find " + sm_serverInstallDir + " -name '*.pem' | grep generated_certs");
String[] remoteFilesAsString = result.getStdout().trim().split("\\n");
if (remoteFilesAsString.length == 1 && remoteFilesAsString[0].equals(""))
remoteFilesAsString = new String[] {};
if (remoteFilesAsString.length == 0)
log.warning("No generated product certs were found on the candlpin server for use in testing.");
for (String remoteFileAsString : remoteFilesAsString) {
File remoteFile = new File(remoteFileAsString);
File localFile = new File((getProperty("automation.dir", "/tmp") + "/tmp/" + remoteFile.getName()).replace("tmp/tmp", "tmp"));
// rename the generated productCertFile to help distinguish it from a true RHEL productCertFiles
File localFileRenamed = new File(localFile.getPath().replace(".pem", "_.pem"));
RemoteFileTasks.getFile(server, localFile.getParent(), remoteFile.getPath());
localFile.renameTo(localFileRenamed);
generatedProductCertFiles.add(localFileRenamed);
}
}
}
// fetch the candlepin CA Cert
File serverCaCertFile = serverCaCertFile = fetchServerCaCertFile();
// setup the client(s) (with the fetched candlepin CA Cert and the generated product certs)
for (SubscriptionManagerTasks smt : new SubscriptionManagerTasks[] { client2tasks, client1tasks }) {
if (smt != null)
setupClient(smt, serverCaCertFile, generatedProductCertFiles);
}
// initialize various servertasks instance variables for future reference
servertasks.initialize(clienttasks.candlepinAdminUsername, clienttasks.candlepinAdminPassword, clienttasks.candlepinUrl);
// create an artifact to log all the package versions being tested
// this will be in the automation.dir directory on hudson (workspace/automatjon/sm)
File file = new File("test-output/version.txt");
Writer output = new BufferedWriter(new FileWriter(file));
String infoMsg;
if (client1 != null) {
infoMsg = "Client1 System Hostname: " + sm_client1Hostname + "\n";
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "Beaker Compose: " + client1tasks.compose + "\n";
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "Installed Packages:";
log.info(infoMsg);
output.write(infoMsg + "\n");
// subscription-manager-0.63-1.el6.i686
infoMsg = client1.runCommandAndWait("rpm -qa | egrep ^subscription-manager").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
// python-rhsm-0.63-1.el6.i686
infoMsg = client1.runCommandAndWait("rpm -qa | egrep ^python-rhsm").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client1.runCommandAndWait("rpm -q --whatprovides /etc/redhat-release").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# cat /etc/redhat-release";
log.info(infoMsg);
output.write(infoMsg + "\n");
// Red Hat Enterprise Linux Server release 6.1 Beta (Santiago)
infoMsg = client1.runCommandAndWait("cat /etc/redhat-release").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# uname -a";
log.info(infoMsg);
output.write(infoMsg + "\n");
// Linux jsefler-onprem-server.usersys.redhat.com 2.6.32-122.el6.x86_64 #1 SMP Wed Mar 9 23:54:34 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
infoMsg = client1.runCommandAndWait("uname -a").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# " + client1tasks.listCommand(null, null, null, true, null, null, null, null, null, null, null, null, null, null);
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client1.runCommandAndWait(client1tasks.listCommand(null, null, null, true, null, null, null, null, null, null, null, null, null, null)).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
for (ProductCert productCert : client1tasks.getCurrentProductCerts()) {
infoMsg = "# rpm -q --whatprovides " + productCert.file;
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client1.runCommandAndWait("rpm -q --whatprovides " + productCert.file).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n\n");
}
infoMsg = "# cat " + client1tasks.productIdJsonFile;
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client1.runCommandAndWait("cat " + client1tasks.productIdJsonFile).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n\n");
}
if (client2 != null) {
infoMsg = "Client2 System Hostname: " + sm_client2Hostname + "\n";
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "Beaker Compose: " + client2tasks.compose + "\n";
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "Installed Packages:";
log.info(infoMsg);
output.write(infoMsg + "\n");
// subscription-manager-0.63-1.el6.i686
infoMsg = client2.runCommandAndWait("rpm -qa | egrep ^subscription-manager").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
// python-rhsm-0.63-1.el6.i686
infoMsg = client2.runCommandAndWait("rpm -qa | egrep ^python-rhsm").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client2.runCommandAndWait("rpm -q --whatprovides /etc/redhat-release").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# cat /etc/redhat-release";
log.info(infoMsg);
output.write(infoMsg + "\n");
// Red Hat Enterprise Linux Server release 6.1 Beta (Santiago)
infoMsg = client2.runCommandAndWait("cat /etc/redhat-release").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# uname -a";
log.info(infoMsg);
output.write(infoMsg + "\n");
// Linux jsefler-onprem-server.usersys.redhat.com 2.6.32-122.el6.x86_64 #1 SMP Wed Mar 9 23:54:34 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
infoMsg = client2.runCommandAndWait("uname -a").getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = "# " + client2tasks.listCommand(null, null, null, true, null, null, null, null, null, null, null, null, null, null);
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client2.runCommandAndWait(client2tasks.listCommand(null, null, null, true, null, null, null, null, null, null, null, null, null, null)).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n");
for (ProductCert productCert : client2tasks.getCurrentProductCerts()) {
infoMsg = "# rpm -q --whatprovides " + productCert.file;
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client2.runCommandAndWait("rpm -q --whatprovides " + productCert.file).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n\n");
}
infoMsg = "# cat " + client2tasks.productIdJsonFile;
log.info(infoMsg);
output.write(infoMsg + "\n");
infoMsg = client2.runCommandAndWait("cat " + client2tasks.productIdJsonFile).getStdout();
log.info(infoMsg);
output.write(infoMsg + "\n\n");
}
output.close();
// create an artifact containing package versions that can be uploaded to Polarion Group ID
String groupId = "";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "0") != null) {
groupId += " " + clienttasks.installedPackageVersionMap.get("subscription-manager");
}
/* exclude for now since the Polarion Group ID should really be a multi-entry field
* RHEL Projects: Use of Group ID and Component for Test Runs
* https://projects.engineering.redhat.com/browse/POLARION-1201
if (clienttasks.isPackageVersion("python-rhsm",">=","0")!=null) {
groupId += " "+clienttasks.installedPackageVersionMap.get("python-rhsm");
}
if (clienttasks.isPackageVersion("subscription-manager-migration-data",">=","0")!=null) {
groupId += " "+clienttasks.installedPackageVersionMap.get("subscription-manager-migration-data");
}
*/
// strip off .el5
groupId = groupId.replaceAll("\\.el" + clienttasks.redhatReleaseX, "");
// strip off .arch
groupId = groupId.replaceAll("\\." + clienttasks.arch + "|\\.noarch", "");
groupId = groupId.trim();
/*File*/
// this will be in the automation.dir directory on hudson (workspace/automatjon/sm)
file = new File("test-output/group-id.txt");
/*Writer*/
output = new BufferedWriter(new FileWriter(file));
output.write(groupId);
output.close();
isSetupBeforeSuiteComplete = true;
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method restoreProductCertsAfterThisTest.
@AfterGroups(groups = { "setup" }, value = { // list of individual tests that could cause the product-id yum plugin to install a productid from the CDN repodata that you want to remove after the test
"testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingYesResponses", "testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesYesNoResponses", "testInstallAndRemoveAnyPackageFromEnabledRepoAfterSubscribingToPool", "testInstallAndRemoveYumGroupFromEnabledRepoAfterSubscribingToPool", "testYumInstallSucceedsWhenServiceRsyslogIsStopped" }, alwaysRun = true)
public void restoreProductCertsAfterThisTest() {
if (clienttasks == null)
return;
List<ProductCert> productCertsAfterThisTest = clienttasks.getCurrentProductCerts();
// Extraneous RHEL product certs are easily possible especially on a HTB installation as explained in https://bugzilla.redhat.com/show_bug.cgi?id=1538957#c5
for (ProductCert productCertAfterThisTest : productCertsAfterThisTest) {
for (ProductCert productCertBeforeThisTest : productCertsBeforeThisTest) {
// do nothing when this productCertAfterTest was also present BeforeTest
if (productCertBeforeThisTest.file.equals(productCertAfterThisTest.file))
continue;
// do nothing if this productCertAfterTest is located in the default directory
if (productCertAfterThisTest.file.getPath().startsWith(clienttasks.productCertDefaultDir))
continue;
// TEMPORARY WORKAROUND
if (doesStringContainMatches(productCertAfterThisTest.productNamespace.providedTags, "rhel-" + clienttasks.redhatReleaseX + "(,|$)")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1525238 - yum plugin for productid neglects to remove HTB product cert from /etc/pki/product/ because it is tagged as a provider of "rhel-7"
String bugId = "1525238";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("Removing product cert '" + productCertAfterThisTest.productName + " " + productCertAfterThisTest.file + "' from restoreProductCertsAfterThisTest() while bug '" + bugId + "' is open.");
}
}
// END OF WORKAROUND
// remove the product cert
log.info("Removing product cert '" + productCertAfterThisTest.productName + " " + productCertAfterThisTest.file + "' from restoreProductCertsAfterThisTest().");
client.runCommandAndWait("rm -f " + productCertAfterThisTest.file);
}
}
// clear the protected variable
productCertsBeforeThisTest.clear();
productCertsBeforeThisTest = null;
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class GuestLimitingTests method testComplianceOfHostWithtwoGuestsAndGuestLimitOfFour.
/**
* @author skallesh
* @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-37723", "RHEL7-51950" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : Guest-limited Subscriptions
workitemId = "RHEL6-30331", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : Guest-limited Subscriptions
workitemId = "RHEL7-84959", 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.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Verify the compliance status on the server when the host has more than 2 guests", groups = { "Tier2Tests" }, enabled = true)
public void testComplianceOfHostWithtwoGuestsAndGuestLimitOfFour() throws JSONException, Exception {
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));
if (clienttasks.getFactValue("virt.is_guest").equals("True")) {
Map<String, String> factsMap = new HashMap<String, String>();
factsMap.put("virt.is_guest", "False");
factsMap.put(" virt.uuid", "");
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
}
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId);
// call Candlepin API to PUT some guestIds onto the host consumer
JSONObject jsonData = new JSONObject();
Map<String, String> attributes = new HashMap<String, String>();
attributes.clear();
attributes.put("virtWhoType", "libvirt");
attributes.put("active", "1");
int guestLimit = 4;
List<JSONObject> expectedGuestIds = new ArrayList<JSONObject>();
for (int k = 0; k <= guestLimit - 1; k++) {
expectedGuestIds.add(createGuestIdRequestBody("test-guestId" + k, attributes));
}
jsonData.put("guestIds", expectedGuestIds);
CandlepinTasks.putResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId, jsonData);
String pool = getGuestlimitPool(String.valueOf(guestLimit));
ProductCert installedProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", providedProductIds.get(randomGenerator.nextInt(providedProductIds.size())), clienttasks.getCurrentProductCerts());
Assert.assertNotNull(installedProductCert, "Found installed product cert needed for this test.");
clienttasks.subscribe(null, null, pool, null, null, "1", null, null, null, null, null, null, null);
String compliance = clienttasks.getFactValue(factname);
// Assert the system compliance
Assert.assertEquals(compliance, factValueForSystemCompliance);
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class GuestLimitingTests method testComplianceOfHostWithOneOftheGuestReportedInactive.
/**
* @author skallesh
* @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-37722", "RHEL7-51949" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : Guest-limited Subscriptions
workitemId = "RHEL6-30331", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : Guest-limited Subscriptions
workitemId = "RHEL7-84959", 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.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Verify the compliance status on the server when the host has more than 5 guests and one of the guest is reported to be inactive by virt-who", groups = { "Tier2Tests" }, enabled = true)
public void testComplianceOfHostWithOneOftheGuestReportedInactive() throws JSONException, Exception {
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));
clienttasks.autoheal(null, null, true, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
if (clienttasks.getFactValue("virt.is_guest").equals("True")) {
Map<String, String> factsMap = new HashMap<String, String>();
factsMap.put("virt.is_guest", "False");
factsMap.put(" virt.uuid", "");
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
}
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId);
// call Candlepin API to PUT some guestIds onto the host consumer
JSONObject jsonData = new JSONObject();
Map<String, String> attributes = new HashMap<String, String>();
attributes.clear();
attributes.put("virtWhoType", "libvirt");
attributes.put("active", "1");
int guestLimit = 4;
List<JSONObject> expectedGuestIds = new ArrayList<JSONObject>();
for (int k = 0; k <= guestLimit - 1; k++) {
if (k == 3) {
attributes.put("active", "0");
}
expectedGuestIds.add(createGuestIdRequestBody("test-guestId" + k, attributes));
}
jsonData.put("guestIds", expectedGuestIds);
CandlepinTasks.putResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId, jsonData);
String pool = getGuestlimitPool(String.valueOf(guestLimit));
ProductCert installedProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", providedProductIds.get(randomGenerator.nextInt(providedProductIds.size())), clienttasks.getCurrentProductCerts());
Assert.assertNotNull(installedProductCert, "Found installed product cert needed for this test.");
clienttasks.subscribe(null, null, pool, null, null, "1", null, null, null, null, null, null, null);
String compliance = clienttasks.getFactValue(factname);
// Assert the system compliance
Assert.assertEquals(compliance, factValueForSystemCompliance);
}
Aggregations