use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class BugzillaTests method testUnsubscribeAllForExpiredSubscription.
/**
* @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-21974", "RHEL7-51836" }, 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 unsubscribe --all on expired subscriptions removes certs from entitlement folder", groups = { "Tier3Tests", "VerifyUnsubscribeAllForExpiredSubscription", "blockedByBug-852630", "blockedByBug-906550", "blockedByBug-1555582" }, enabled = true)
public void testUnsubscribeAllForExpiredSubscription() throws JSONException, Exception {
clienttasks.clean();
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);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
String expiringPoolId = createTestPool(-60 * 24, 1, false);
Calendar c1 = new GregorianCalendar();
clienttasks.subscribe(null, null, expiringPoolId, null, null, null, null, null, null, null, null, null, null);
Calendar c2 = new GregorianCalendar();
// wait for the pool to expire
// sleep(endingMinutesFromNow*60*1000);
// trying to reduce the wait time for the expiration by subtracting off
// some expensive test time
sleep(1 * 60 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
List<ProductSubscription> activeProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.TRUE, consumedProductSubscriptions);
Set<BigInteger> activeProductSubscriptionSerials = new HashSet<BigInteger>();
for (ProductSubscription activeProductSubscription : activeProductSubscriptions) activeProductSubscriptionSerials.add(activeProductSubscription.serialNumber);
List<ProductSubscription> expiredProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.FALSE, consumedProductSubscriptions);
Assert.assertEquals(expiredProductSubscriptions.size(), 1, "Found one expired entitlement (indicated by Active:False) among the list of consumed subscriptions.");
SSHCommandResult result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
String expected = String.format("%d subscriptions removed at the server.\n%d local certificates have been deleted.", activeProductSubscriptionSerials.size(), activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size());
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
// commit d88d09c7060a17fba34a138313e7efd21cc79d02 D-Bus service for removing entitlements (all/ID/serial num.)
expected = String.format("%d local certificates have been deleted." + "\n" + "%d subscriptions removed at the server.", activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size(), activeProductSubscriptionSerials.size());
}
if (activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size() == 1)
expected = expected.replace("local certificates have been", "local certificate has been");
Assert.assertEquals(result.getStdout().trim(), expected);
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class BugzillaTests method testSubscribingWithIncorrectFormatForPoolId.
/**
* @author skallesh
* @throws IOException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21958", "RHEL7-51820" }, 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.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: subscribe multiple pools in incorrect format", groups = { "Tier3Tests", "MysubscribeTest", "blockedByBug-772218" }, enabled = true)
public void testSubscribingWithIncorrectFormatForPoolId() throws IOException {
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);
List<String> poolid = new ArrayList<String>();
for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
poolid.add(pool.poolId);
}
if (poolid.isEmpty())
throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
int i = randomGenerator.nextInt(poolid.size());
int j = randomGenerator.nextInt(poolid.size());
if (i == j) {
j = randomGenerator.nextInt(poolid.size());
}
SSHCommandResult subscribeResult = subscribeInvalidFormat_(null, null, poolid.get(i), poolid.get(j), null, null, null, null, null, null, null, null);
Assert.assertEquals(subscribeResult.getStdout().trim(), "cannot parse argument: " + poolid.get(j));
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class BugzillaTests method testFactsWithIncorrectProxy_Test.
/**
* @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-21950", "RHEL7-51812" }, 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.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "Verify facts update with incorrect proxy url produces traceback.", groups = { "Tier3Tests", "VerifyFactsWithIncorrectProxy_Test", "blockedByBug-744504" }, enabled = true)
public void testFactsWithIncorrectProxy_Test() throws JSONException, Exception {
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 basicauthproxyUrl = String.format("%s:%s", "testmachine.com", sm_basicauthproxyPort);
basicauthproxyUrl = basicauthproxyUrl.replaceAll(":$", "");
SSHCommandResult factsResult = clienttasks.facts_(null, true, basicauthproxyUrl, null, null, null);
String factsResultExpected = clienttasks.msg_NetworkErrorUnableToConnect;
factsResultExpected = "Error updating system data on the server, see /var/log/rhsm/rhsm.log for more details.";
factsResultExpected = clienttasks.msg_ProxyConnectionFailed;
Assert.assertEquals(factsResult.getStdout().trim() + factsResult.getStderr().trim(), factsResultExpected);
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class BugzillaTests method testImportedCertGetsDeletedByRepoCommand.
/**
* @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-21957", "RHEL7-51819" }, 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 subscription-manager repos --list does not delete an imported entitlement certificate on a system", groups = { "Tier3Tests", "VerifyImportedCertgetsDeletedByRepoCommand", "blockedByBug-1160150" }, enabled = true)
public void testImportedCertGetsDeletedByRepoCommand() throws Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
// disable
clienttasks.autoheal(null, null, true, null, null, null, null);
SubscriptionPool pool = getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 1).get(0);
File importEntitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_clientUsername, sm_clientPassword, sm_serverUrl);
File importEntitlementKeyFile = clienttasks.getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(importEntitlementCertFile);
File importCertificateFile = new File(importCertificatesDir1 + File.separator + importEntitlementCertFile.getName());
List<Repo> subscribedReposBefore = clienttasks.getCurrentlySubscribedRepos();
client.runCommandAndWait("mkdir -p " + importCertificatesDir1);
client.runCommandAndWait("cat " + importEntitlementCertFile + " " + importEntitlementKeyFile + " > " + importCertificateFile);
String path = importCertificateFile.getPath();
clienttasks.clean();
clienttasks.importCertificate(path);
int Ceritificate_countBeforeRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
SSHCommandResult Result = clienttasks.repos_(true, null, null, (String) null, null, null, null, null, null);
int Ceritificate_countAfterRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
List<Repo> subscribedReposAfter = clienttasks.getCurrentlySubscribedRepos();
Assert.assertEquals(Ceritificate_countBeforeRepoCommand, Ceritificate_countAfterRepoCommand);
Assert.assertEquals(Result.getExitCode(), new Integer(0));
Assert.assertTrue(subscribedReposBefore.containsAll(subscribedReposAfter) && subscribedReposAfter.containsAll(subscribedReposBefore), "The list of subscribed repos is the same before and after importing the entitlement certificate.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class BugzillaTests method testRegisterAttemptsWithVariousConsumerNames.
/**
* @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-21942", "RHEL7-51804" }, 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 if CLI lets you set consumer name to empty string and defaults to sm_clientUsername", groups = { "Tier3Tests", "VerifyConsumerNameTest", "blockedByBug-669395", "blockedByBug-1451003" }, enabled = true)
public void testRegisterAttemptsWithVariousConsumerNames() throws JSONException, Exception {
String consumerName = "tester";
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);
SSHCommandResult result = clienttasks.identity(null, null, null, null, null, null, null, null);
Assert.assertContainsMatch(result.getStdout(), "name: " + clienttasks.hostname);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, consumerName, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
result = clienttasks.identity(null, null, null, null, null, null, null, null);
String expected = "name: " + consumerName;
Assert.assertContainsMatch(result.getStdout(), expected);
String consumerId = clienttasks.getCurrentConsumerId();
clienttasks.clean();
consumerName = "consumer";
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, consumerName, consumerId, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
result = clienttasks.identity(null, null, null, null, null, null, null, null);
Assert.assertContainsMatch(result.getStdout(), expected);
clienttasks.clean();
result = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, "", consumerId, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post
// commit
// df95529a5edd0be456b3528b74344be283c4d258
Assert.assertEquals(result.getStderr().trim(), "Error: system name can not be empty.", "stderr");
} else {
Assert.assertEquals(result.getStdout().trim(), "Error: system name can not be empty.", "stdout");
}
result = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, "", null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post
// commit
// df95529a5edd0be456b3528b74344be283c4d258
Assert.assertEquals(result.getStderr().trim(), "Error: system name can not be empty.", "stderr");
} else {
Assert.assertEquals(result.getStdout().trim(), "Error: system name can not be empty.", "stdout");
}
}
Aggregations