use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class TemporaryPoolTests method testAvailabilityOfUnmappedGuestsOnlySubpool.
// Test methods ***********************************************************************
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20093", "RHEL7-51735" }, 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 = "given an available unmapped_guests_only pool, assert that it is available only to virtual systems whose host consumer has not yet mapped its virt.uuid as a guestId onto the host consumer. Moreover, assert that once mapped, the pool is no longer available.", groups = { "Tier1Tests" }, dataProvider = "getAvailableUnmappedGuestsOnlySubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAvailabilityOfUnmappedGuestsOnlySubpool(Object bugzilla, SubscriptionPool unmappedGuestsOnlyPool) throws JSONException, Exception {
// system facts were overridden in dataProvider with factsMap to fake this system as a guest
// make sure we are freshly registered (to discard a consumer from a former data provided iteration that has mapped guests)
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);
// verify the unmapped_guests_only pool is available for consumption
List<SubscriptionPool> availableSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
Assert.assertNotNull(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, availableSubscriptionPools), "Temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' poolId='" + unmappedGuestsOnlyPool.poolId + "' (for virtual systems whose host consumer has not yet reported this system's virt.uuid as a guest) is available for consumption.");
// verify that it is for Virtual systems
Assert.assertEquals(unmappedGuestsOnlyPool.machineType, "Virtual", "Temporary pools intended for unmapped guests only should indicate that it is for machine type Virtual.");
// verify that the Subscription Type indicates it is temporary
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.9.47-1")) {
// commit dfd7e68ae83642f77c80590439353a0d66fe2961 // Bug 1201520 - [RFE] Usability suggestions to better identify a temporary (aka 24 hour) entitlement
String temporarySuffix = " (Temporary)";
Assert.assertTrue(unmappedGuestsOnlyPool.subscriptionType.endsWith(temporarySuffix), "The Subscription Type for a temporary pool intended for unmapped guests only should end in suffix '" + temporarySuffix + "' (actual='" + unmappedGuestsOnlyPool.subscriptionType + "').");
}
// verify that the corresponding Physical pool is also available (when not physical_only)
String parentPhysicalPoolId = getParentPoolIdCorrespondingToDerivedPoolId(sm_clientUsername, sm_clientPassword, sm_serverUrl, clienttasks.getCurrentlyRegisteredOwnerKey(), unmappedGuestsOnlyPool.poolId);
Assert.assertNotNull(parentPhysicalPoolId, "Found parent Physical poolId corresponding to temporary unmapped guests only poolId '" + unmappedGuestsOnlyPool.poolId + "'.");
SubscriptionPool parentPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", parentPhysicalPoolId, availableSubscriptionPools);
if (CandlepinTasks.isPoolRestrictedToPhysicalSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, parentPhysicalPoolId)) {
Assert.assertNull(parentPool, "Should NOT found parent pool corresponding to temporary unmapped guests only poolId '" + unmappedGuestsOnlyPool.poolId + "' among available pools since it is Physical only.");
} else {
Assert.assertNotNull(parentPool, "Found parent Physical pool corresponding to temporary unmapped guests only poolId '" + unmappedGuestsOnlyPool.poolId + "' among available pools.");
Assert.assertEquals(parentPool.machineType, "Physical", "The machine type for the parent pool corresponding to temporary unmapped guests only poolId '" + unmappedGuestsOnlyPool.poolId + "'.");
}
// simulate the actions of virt-who my mapping the virt.uuid as a guestID onto a host consumer
clienttasks.mapSystemAsAGuestOfItself();
// verify that the unmapped_guests_only pool is no longer available
Assert.assertNull(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyAvailableSubscriptionPools()), "Temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' poolId='" + unmappedGuestsOnlyPool.poolId + "' (for virtual systems whose host consumer has not yet reported this system's virt.uuid as a guest) is NO LONGER available for consumption after it's virt.uuid has been mapped to a consumer's guestId list.");
// assert that we are blocked from attempt to attach the temporary pool
// 201503191231:11.346 - FINE: ssh root@jsefler-os6.usersys.redhat.com subscription-manager subscribe --pool=8a9087e34c2f214a014c2f22a7d11ad0
// 201503191231:16.011 - FINE: Stdout: Pool is restricted to unmapped virtual guests: '8a9087e34c2f214a014c2f22a7d11ad0'
// 201503191231:16.014 - FINE: Stderr:
// 201503191231:16.016 - FINE: ExitCode: 1
SSHCommandResult result = clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
String expectedStdout = String.format("Pool is restricted to unmapped virtual guests: '%s'", unmappedGuestsOnlyPool.poolId);
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
// commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
expectedStdout = String.format("Pool is restricted to unmapped virtual guests: \"%s\".", unmappedGuestsOnlyPool.poolId);
}
String expectedStderr = "";
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout from an attempt to attach a temporary pool to a virtual guest that has already been mapped.");
Assert.assertEquals(result.getStderr().trim(), expectedStderr, "Stderr from an attempt to attach a temporary pool to a virtual guest that has already been mapped.");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exit code from an attempt to attach a temporary pool to a virtual guest that has already been mapped.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class TemporaryPoolTests method testExpirationOfUnmappedGuestsOnlySubpool.
@Test(description = "Consume a temporary pool entitlement and wait a day for it to expire, then assert its removal and assert the pool is not longer available to this consumer.", groups = { "Tier1Tests", "blockedByBug-1199078", "VerifyExpirationOfUnmappedGuestsOnlySubpool_Test" }, dataProvider = "getAvailableUnmappedGuestsOnlySubscriptionPoolsData", // TODO Temporarily disabling this test because changing the system clock during an automated test seems to knock the system off the network during runs on Jenkins thereby loosing ssh connection; service network restarts are needed
enabled = false)
public // @ImplementsNitrateTest(caseId=)
void testExpirationOfUnmappedGuestsOnlySubpool(Object bugzilla, SubscriptionPool unmappedGuestsOnlyPool) throws JSONException, Exception {
if (!CandlepinType.standalone.equals(sm_serverType))
throw new SkipException("This automated test should only be attempted on a standalone server.");
// system facts are overridden with factsMap to fake this system as a guest
// reset the date on the client and server
resetDatesAfterTestExpirationOfUnmappedGuestsOnlySubpool();
// make sure we are freshly registered (to discard a consumer from a former data provided iteration that has mapped guests)
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, /* autoheal defaults to true*/
null, null, null, null);
// attach the unmapped guests only pool
clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
ProductSubscription consumedUnmappedGuestsOnlyProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions());
Assert.assertNotNull(consumedUnmappedGuestsOnlyProductSubscription, "Successfully found the consumed product subscription after attaching temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' (poolId='" + unmappedGuestsOnlyPool.poolId + "').");
// advance the date on the client and server
RemoteFileTasks.runCommandAndAssert(client, String.format("date -s +%dhours", 24), 0);
clientHoursFastForwarded += 24;
RemoteFileTasks.runCommandAndAssert(server, String.format("date -s +%dhours", 24), 0);
serverHoursFastForwarded += 24;
// assert that the list of consumedUnmappedGuestsOnlyProductSubscription now appears expired (Active: False, Status Details: Subscription is expired)
ProductSubscription expiredUnmappedGuestsOnlyProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions());
Assert.assertFalse(expiredUnmappedGuestsOnlyProductSubscription.isActive, "The value of Active shown on the consumed temporary product subscription 24 hours after pool '" + unmappedGuestsOnlyPool.poolId + "' was attached.");
Assert.assertEquals(expiredUnmappedGuestsOnlyProductSubscription.statusDetails, Arrays.asList("Subscription is expired"), "The Status Details shown on the consumed temporary product subscription 24 hours after pool '" + unmappedGuestsOnlyPool.poolId + "' was attached.");
// catch Bug 1201727 - After the 24 hour pool is expired,consumed --list displays a value,even after attaching a subscription
// TODO
// assert the installed product appears expired (Active: False, Status Details: Subscription is expired)
// TODO
// trigger an autohealing rhsmcertd checkin (assumes that autoheal defaults to true on a newly registered consumer)
// must pass autoheal=true
clienttasks.run_rhsmcertd_worker(true);
// assert the expired entitlement is immediately removed when autohealing is run // Bug 1199078 - expired guest 24 hour subscription not removed on auto-attach
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.9.46-1")) {
// commit d24a59b3640aef1acb2b6067100d653fc76636f5 1199078: Remove expired unmapped guest pools on autoheal
Assert.assertNull(ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions()), "After an autohealing rhsmcertd checkin, the expired temporary product subscription should be immediately removed from the system.");
}
// verify that the temporary unmapped_guests_only pool is no longer available for consumption
Assert.assertNull(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyAvailableSubscriptionPools()), "Temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' poolId='" + unmappedGuestsOnlyPool.poolId + "' is NO LONGER available for consumption 24 hours after the unmapped guest consumer registered.");
// assert that we are blocked from an attempt to attach the temporary pool 24 hours after the consumer registered
// 201503191706:00.370 - FINE: ssh root@jsefler-os6.usersys.redhat.com subscription-manager subscribe --pool=8a9087e34c335894014c3359e22517fa
// 201503191706:03.965 - FINE: Stdout: Pool is restricted to virtual guests in their first day of existence: '8a9087e34c335894014c3359e22517fa'
// 201503191706:03.968 - FINE: Stderr:
// 201503191706:03.970 - FINE: ExitCode: 1
SSHCommandResult result = clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
String expectedStdout = String.format("Pool is restricted to virtual guests in their first day of existence: '%s'", unmappedGuestsOnlyPool.poolId);
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
// commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
expectedStdout = String.format("Pool is restricted to virtual guests in their first day of existence: \"%s\".", unmappedGuestsOnlyPool.poolId);
}
String expectedStderr = "";
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout from an attempt to attach a temporary pool to a virtual guest 24 hours after the guest registered.");
Assert.assertEquals(result.getStderr().trim(), expectedStderr, "Stderr from an attempt to attach a temporary pool to a virtual guest 24 hours after the guest registered.");
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exit code from an attempt to attach a temporary pool to a virtual guest 24 hours after the guest registered.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class TranslationTests method testPofilter_DEPRECATED.
@Test(description = "run pofilter translate tests on the translation file", groups = { "Tier2Tests" }, dataProvider = "getTranslationFilePofilterTestData", // 07/12/2012 this was the initial test created for the benefit of fsharath who further developed the test in PofilterTranslationTests.java; disabling this test in favor of his
enabled = false)
@Deprecated
public // @ImplementsNitrateTest(caseId=)
void testPofilter_DEPRECATED(Object bugzilla, String pofilterTest, File translationFile) {
log.info("For an explanation of pofilter test '" + pofilterTest + "', see: http://translate.sourceforge.net/wiki/toolkit/pofilter_tests");
File translationPoFile = new File(translationFile.getPath().replaceFirst(".mo$", ".po"));
// execute the pofilter test
String pofilterCommand = "pofilter --gnome -t " + pofilterTest;
SSHCommandResult pofilterResult = client.runCommandAndWait(pofilterCommand + " " + translationPoFile);
Assert.assertEquals(pofilterResult.getExitCode(), new Integer(0), "Successfully executed the pofilter tests.");
// convert the pofilter test results into a list of failed Translation objects for simplified handling of special cases
List<Translation> pofilterFailedTranslations = Translation.parse(pofilterResult.getStdout());
// remove the first translation which contains only meta data
if (!pofilterFailedTranslations.isEmpty() && pofilterFailedTranslations.get(0).msgid.equals(""))
pofilterFailedTranslations.remove(0);
// ignore the following special cases of acceptable results..........
List<String> ignorableMsgIds = Arrays.asList();
if (pofilterTest.equals("accelerators")) {
if (translationFile.getPath().contains("/hi/"))
ignorableMsgIds = Arrays.asList("proxy url in the form of proxy_hostname:proxy_port");
if (translationFile.getPath().contains("/ru/"))
ignorableMsgIds = Arrays.asList("proxy url in the form of proxy_hostname:proxy_port");
}
if (pofilterTest.equals("newlines")) {
ignorableMsgIds = Arrays.asList("Optional language to use for email notification when subscription redemption is complete. Examples: en-us, de-de", "\n" + "Unable to register.\n" + "For further assistance, please contact Red Hat Global Support Services.", "Tip: Forgot your login or password? Look it up at http://red.ht/lost_password", "Unable to perform refresh due to the following exception: %s", "" + "This migration script requires the system to be registered to RHN Classic.\n" + "However this system appears to be registered to '%s'.\n" + "Exiting.", "The tool you are using is attempting to re-register using RHN Certificate-Based technology. Red Hat recommends (except in a few cases) that customers only register with RHN once.", // bug 825388 ""+"We have detected that you have multiple service level\n"+"agreements on various products. Please select how you\n"+"want them assigned.", // bug 825388 or 825397 should fix this
"\n" + "This machine appears to be already registered to Certificate-based RHN. Exiting.", "\n" + "This machine appears to be already registered to Red Hat Subscription Management. Exiting.");
}
if (pofilterTest.equals("unchanged")) {
ignorableMsgIds = Arrays.asList("close_button", "facts_view", "register_button", "register_dialog_main_vbox", "registration_dialog_action_area\n", "prod 1, prod2, prod 3, prod 4, prod 5, prod 6, prod 7, prod 8");
}
// pluck out the ignorable pofilter test results
for (String msgid : ignorableMsgIds) {
Translation ignoreTranslation = Translation.findFirstInstanceWithMatchingFieldFromList("msgid", msgid, pofilterFailedTranslations);
if (ignoreTranslation != null) {
log.info("Ignoring result of pofiliter test '" + pofilterTest + "' for msgid: " + ignoreTranslation.msgid);
pofilterFailedTranslations.remove(ignoreTranslation);
}
}
// assert that there are no failed pofilter translation test results
Assert.assertEquals(pofilterFailedTranslations.size(), 0, "Discounting the ignored test results, the number of failed pofilter '" + pofilterTest + "' tests for translation file '" + translationFile + "'.");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method identity.
/**
* "subscription-manager-cli identity"
* @param username
* @param password
* @param regenerate
* @param force
* @param proxy
* @param proxyuser
* @param proxypassword
* @param noproxy TODO
* @return
*/
public SSHCommandResult identity(String username, String password, Boolean regenerate, Boolean force, String proxy, String proxyuser, String proxypassword, String noproxy) {
SSHCommandResult sshCommandResult = identity_(username, password, regenerate, force, proxy, proxyuser, proxypassword, noproxy);
// the non-null default value for regenerate is false
regenerate = regenerate == null ? false : regenerate;
// assert results for a successful identify
/* Example sshCommandResult.getStdout():
* Current identity is: 8f4dd91a-2c41-4045-a937-e3c8554a5701 name: testuser1
*/
Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "The exit code from the identity command indicates a success.");
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=719109 - jsefler 7/05/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "719109";
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) {
// skip the assertion of user feedback in stdout
return sshCommandResult;
}
if (regenerate) {
Assert.assertEquals(sshCommandResult.getStdout().trim(), "Identity certificate has been regenerated.");
}
// from the identity command
return sshCommandResult;
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method installSubscriptionManagerRPMs.
public void installSubscriptionManagerRPMs(List<String> rpmInstallUrls, List<String> rpmUpdateUrls, String installOptions, String jenkinsUsername, String jenkinsPassword) {
if (rpmInstallUrls == null)
rpmInstallUrls = new ArrayList<String>();
if (rpmUpdateUrls == null)
rpmUpdateUrls = new ArrayList<String>();
if (installOptions == null)
installOptions = "";
List<String> pkgsInstalled = new ArrayList<String>();
// redhat-release-atomic-host-7.1-20150113.0.atomic.el7.4.x86_64
if (redhatRelease.startsWith("Red Hat Atomic Host")) {
log.warning("Skipping setup procedure installSubscriptionManagerRPMs() on '" + redhatRelease + "'.");
return;
}
// make sure the client's time is accurate
if (Integer.valueOf(redhatReleaseX) >= 7) {
// the RHEL7 / F16+ way...
RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "systemctl stop ntpd.service && ntpdate clock.redhat.com && systemctl enable ntpd.service && systemctl start ntpd.service && systemctl is-active ntpd.service", Integer.valueOf(0), "^active$", null);
} else {
RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "service ntpd stop; ntpdate clock.redhat.com; service ntpd start; chkconfig ntpd on", /*Integer.valueOf(0) DON"T CHECK EXIT CODE SINCE IT RETURNS 1 WHEN STOP FAILS EVEN THOUGH START SUCCEEDS*/
null, "Starting ntpd:\\s+\\[ OK \\]", null);
}
// yum clean all
SSHCommandResult sshCommandResult = yumClean("all");
// this if block was written 2010-10-25 but I cannot remember why I did it - 01/26/2013 jsefler
if (sshCommandResult.getExitCode().equals(1)) {
sshCommandRunner.runCommandAndWait("rm -f " + redhatRepoFile);
}
// 6/15/2013 - including "--disablerepo=*" with yum installOptions to avoid these errors which happen a lot on rhel61 and rhel57
//
// 201306141731:15.632 - FINE: ssh root@rhsm-compat-rhel61.usersys.redhat.com yum remove -y subscription-manager-migration (com.redhat.qe.tools.SSHCommandRunner.run)
// 201306141731:28.980 - FINE: Stderr:
// This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
// file://var/cache/yum/x86_64/6Server/rhel-x86_64-server-6/repodata/repomd.xml: [Errno 14] Could not open/read file://var/cache/yum/x86_64/6Server/rhel-x86_64-server-6/repodata/repomd.xml
// Trying other mirror.
// Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhel-x86_64-server-6. Please verify its path and try again
//
// 201306141719:42.800 - FINE: ssh root@rhsm-compat-rhel57.usersys.redhat.com yum -y localinstall /tmp/python-rhsm.rpm --nogpgcheck (com.redhat.qe.tools.SSHCommandRunner.run)
// 201306141719:43.170 - FINE: Stderr:
// This system is not registered with RHN.
// RHN Satellite or RHN Classic support will be disabled.
// file://var/cache/yum/rhel-x86_64-server-5/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/cache/yum/rhel-x86_64-server-5/repodata/repomd.xml'
// Trying other mirror.
// Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhel-x86_64-server-5. Please verify its path and try again
installOptions = "--disablerepo=* " + installOptions;
// remove current rpms
// http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/python-rhsm.noarch.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-gnome.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-firstboot.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-migration.x86_64.rpm, http://gibson.usersys.redhat.com/latestrpm/?arch=noarch&version=1&rpmname=subscription-manager-migration-data
List<String> rpmUrlsReversed = new ArrayList<String>();
for (String rpmUrl : rpmInstallUrls) rpmUrlsReversed.add(0, rpmUrl);
for (String rpmUrl : rpmUrlsReversed) {
rpmUrl = rpmUrl.trim();
if (rpmUrl.isEmpty())
continue;
String rpm = Arrays.asList(rpmUrl.split("/|=")).get(rpmUrl.split("/|=").length - 1);
String pkg = rpm.replaceFirst("\\.rpm$", "");
String rpmPath = "/tmp/" + rpm;
if (!rpmPath.endsWith(".rpm"))
rpmPath += ".rpm";
// remove the existing package first
log.info("Removing existing package " + pkg + "...");
if (pkg.startsWith("katello-ca-consumer")) {
sshCommandRunner.runCommandAndWait("yum -y remove $(rpm -qa | grep katello-ca-consumer) " + installOptions);
continue;
}
// compatibility adjustment for python-rhsm* packages obsoleted by subscription-manager-rhsm* packages
if (pkg.startsWith("subscription-manager-rhsm")) {
// commit f445b6486a962d12185a5afe69e768d0a605e175 Move python-rhsm build into subscription-manager
String obsoletedPackage = pkg.replace("subscription-manager-rhsm", "python-rhsm");
sshCommandRunner.runCommandAndWait("yum -y remove " + obsoletedPackage + " " + installOptions);
}
// sshCommandRunner.runCommandAndWait("yum -y remove "+pkg+" "+installOptions); // inadvertently causes removal of cockpit-system which requires subscription-manager and then there is no way to get it back when subscription-manager-cockpit is installed; therefore let's use rpm --erase --no-deps
sshCommandRunner.runCommandAndWait("rpm --erase --nodeps " + pkg);
RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "rpm -q " + pkg, Integer.valueOf(1), "package " + pkg + " is not installed", null);
}
// http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/python-rhsm.noarch.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-gnome.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-firstboot.x86_64.rpm, http://hudson.rhq.lab.eng.bos.redhat.com:8080/hudson/view/Entitlement/job/subscription-manager_RHEL5.8/lastSuccessfulBuild/artifact/rpms/x86_64/subscription-manager-migration.x86_64.rpm, http://gibson.usersys.redhat.com/latestrpm/?arch=noarch&version=1&rpmname=subscription-manager-migration-data
for (String rpmUrl : rpmInstallUrls) {
rpmUrl = rpmUrl.trim();
if (rpmUrl.isEmpty())
continue;
String rpm = Arrays.asList(rpmUrl.split("/|=")).get(rpmUrl.split("/|=").length - 1);
String pkg = rpm.replaceFirst("\\.rpm$", "");
String rpmPath = "/tmp/" + rpm;
if (!rpmPath.endsWith(".rpm"))
rpmPath += ".rpm";
// exclude subscription-manager-plugin-ostree-1.15.9-5+ due to Bug 1185958: Make ostree plugin depend on ostree.
/* reverted commit e6a140d6d995887bd1f6488ef2549f913e4c3790 because https://bugzilla.redhat.com/show_bug.cgi?id=1185958#c7
if (rpmUrl.contains("subscription-manager-plugin-ostree") && !isPackageInstalled("ostree")) {
log.warning("Skipping install of '"+rpmUrl+"' due to missing ostree package dependency.");
continue;
}
*/
// install rpmUrl
log.info("Installing RPM from " + rpmUrl + "...");
RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "wget -nv -O " + rpmPath + " --no-check-certificate " + (jenkinsUsername.isEmpty() ? "" : "--http-user=" + jenkinsUsername) + " " + (jenkinsPassword.isEmpty() ? "" : "--http-password=" + jenkinsPassword) + " \"" + rpmUrl.trim() + "\"", Integer.valueOf(0), null, "-> \"" + rpmPath + "\"");
Assert.assertEquals(sshCommandRunner.runCommandAndWait("yum -y localinstall " + rpmPath + " " + installOptions).getExitCode(), Integer.valueOf(0), "ExitCode from yum installed local rpm: " + rpmPath);
// assert the local rpm is now installed
if (!pkg.startsWith("katello-ca-consumer")) {
// skip assertion of katello-ca-consumer
String rpmPackageVersion = sshCommandRunner.runCommandAndWait("rpm --query --package " + rpmPath).getStdout().trim();
String rpmInstalledVersion = sshCommandRunner.runCommandAndWait("rpm --query " + pkg).getStdout().trim();
Assert.assertEquals(rpmInstalledVersion, rpmPackageVersion, "Local rpm package '" + rpmPath + "' is currently installed.");
pkgsInstalled.add(pkg);
}
}
// update new rpms
// http://gibson.usersys.redhat.com/latestrpm/?arch=x86_64&basegrp=subscription-manager&version=0.98.15&rpmname=subscription-manager, http://gibson.usersys.redhat.com/latestrpm/?arch=x86_64&basegrp=subscription-manager&version=0.98.15&rpmname=subscription-manager-gnome, http://gibson.usersys.redhat.com/latestrpm/?arch=x86_64&basegrp=subscription-manager&version=0.98.15&rpmname=subscription-manager-firstboot, http://gibson.usersys.redhat.com/latestrpm/?arch=x86_64&basegrp=subscription-manager&version=0.98.15&rpmname=subscription-manager-migration, http://gibson.usersys.redhat.com/latestrpm/?arch=noarch&version=1.11&release=el5&rpmname=subscription-manager-migration-data
String rpmPaths = "";
for (String rpmUrl : rpmUpdateUrls) {
rpmUrl = rpmUrl.trim();
if (rpmUrl.isEmpty())
continue;
String rpm = Arrays.asList(rpmUrl.split("/|=")).get(rpmUrl.split("/|=").length - 1);
String pkg = rpm.replaceFirst("\\.rpm$", "");
String rpmPath = "/tmp/" + rpm;
if (!rpmPath.endsWith(".rpm"))
rpmPath += ".rpm";
// exclude subscription-manager-plugin-ostree-1.15.9-5+ due to Bug 1185958: Make ostree plugin depend on ostree.
/* reverted commit e6a140d6d995887bd1f6488ef2549f913e4c3790 because https://bugzilla.redhat.com/show_bug.cgi?id=1185958#c7
if (rpmUrl.contains("subscription-manager-plugin-ostree") && !isPackageInstalled("ostree")) {
log.warning("Skipping upgrade of '"+rpmUrl+"' due to missing ostree dependency.");
continue;
}
*/
// upgrade rpmUrl
log.info("Upgrading RPM from " + rpmUrl + "...");
RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "wget -nv -O " + rpmPath + " --no-check-certificate \"" + rpmUrl.trim() + "\"", Integer.valueOf(0), null, "-> \"" + rpmPath + "\"");
rpmPaths += rpmPath;
rpmPaths += " ";
}
if (!rpmUpdateUrls.isEmpty()) {
// TODO: using yum update may cause trouble for subscription-manager-gnome => subscription-manager-gui (Package subscription-manager-gui not installed, cannot update it. Run yum install to install it instead.)
// using yum to upgrade...
SSHCommandResult updateResult = sshCommandRunner.runCommandAndWait("yum -y localupdate " + rpmPaths + " " + installOptions);
if (updateResult.getStdout().contains("does not update installed package")) {
log.warning("The rpmUpdateUrls does not update installed package(s).");
}
Assert.assertEquals(updateResult.getExitCode(), Integer.valueOf(0), "ExitCode from attempt to upgrade packages: " + rpmPaths);
/* using rpm to upgrade...
SSHCommandResult updateResult = sshCommandRunner.runCommandAndWait("rpm -v --upgrade "+rpmPaths);
if (updateResult.getExitCode()==3 && updateResult.getStderr().contains("is already installed")) {
log.warning("The rpmUpdateUrls appear to already be installed.");
} else {
Assert.assertEquals(updateResult.getExitCode(), Integer.valueOf(0), "ExitCode from attempt to upgrade packages: "+rpmPaths);
}
*/
}
// remember the versions of the packages installed
for (String pkg : pkgsInstalled) {
// this will simply populate the cached Map<String,String> installedPackageVersionMap
isPackageVersion(pkg, "==", "0.0");
}
}
Aggregations