Search in sources :

Example 81 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testListingReposWithBadProxy.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL7-55663" }, 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 Status Cache not used when listing repos with a bad proxy ", groups = { "Tier3Tests", "ListingReposWithBadProxy", "blockedByBug-1298327", "blockedByBug-1345962", "blockedByBug-1389794" }, enabled = false)
public void testListingReposWithBadProxy() throws Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    SSHCommandResult result = clienttasks.repos(true, null, null, (String) null, null, null, null, null, null);
    String logMessage = "Unable to reach server, using cached status";
    String rhsmLogMarker = System.currentTimeMillis() + " Testing **********************************************";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
    clienttasks.repos(true, null, null, (String) null, null, sm_basicauthproxyHostname + ":" + sm_basicauthproxyPort, sm_basicauthproxyUsername, "badproxy", null);
    String tailFromRhsmlogFile = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, "cached");
    Assert.assertContainsNoMatch(result.getStderr(), "Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.", "   Validated that no network is thrown");
    Assert.assertTrue(result.getStdout().contains("Available Repositories in /etc/yum.repos.d/redhat.repo"), "Verified that the repo commands succeeds by using the cached status ");
    Assert.assertTrue(tailFromRhsmlogFile.contains(logMessage), "verified that rhsm.log has the message : " + logMessage + "indicating proxy connection has failed and cached status is being used");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 82 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class CandlepinTasks method getCurrentlyRevokedCerts.

public List<RevokedCert> getCurrentlyRevokedCerts() {
    SSHCommandResult result = sshCommandRunner.runCommandAndWaitWithoutLogging("openssl crl -noout -text -in " + candlepinCRLFile);
    if (result.getExitCode() != 0)
        log.warning(result.getStderr());
    String crls = result.getStdout();
    return RevokedCert.parse(crls);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 83 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class CandlepinTasks method redeploy.

/**
 * redeploy the candlepin server with new TESTDATA<br>
 * Note: Existing clients will need to install the new server CA Cert File, otherwise they will encounter: Unable to verify server's identity: [SSL: CERTIFICATE_VERIFY_FAILED]<br>
 * clienttasks.installRepoCaCert(fetchServerCaCertFile(), sm_serverHostname.split("\\.")[0]+".pem");<br>
 * You may also want to deleteSomeSecondarySubscriptionsBeforeSuite();
 * @throws IOException
 */
public void redeploy() throws IOException {
    String hostname = sshCommandRunner.getConnection().getRemoteHostname();
    // kill all runaway instances of tomcat6
    SSHCommandResult tomcatProcesses = sshCommandRunner.runCommandAndWait("ps u -U tomcat | grep tomcat6");
    if (tomcatProcesses.getStdout().trim().split("\\n").length > 1) {
        log.warning("Detected multiple instances of tomcat6 running.  Killing the pids...");
        for (String tomcatProcess : tomcatProcesses.getStdout().trim().split("\\n")) {
            // tomcat   26523  1.9 17.4 1953316 178396 ?      Sl   06:35   6:43 /usr/lib/jvm/java-1.6.0/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
            String pid = tomcatProcess.trim().split("\\s+")[1];
            sshCommandRunner.runCommandAndWait("sudo " + "kill -9 " + pid);
        }
    }
    // clear out the tomcat6 log file (catalina.out)
    File tomcatLogFile = getTomcatLogFile();
    if (tomcatLogFile != null) {
        // [root@jsefler-f14-7candlepin ~]# ls -hl  /var/log/tomcat6/catalina.out*
        // -rw-r--r--. 1 tomcat tomcat 3.6G May 15 11:56 /var/log/tomcat6/catalina.out
        // -rw-r--r--. 1 tomcat tomcat 7.1K May 12 03:40 /var/log/tomcat6/catalina.out-20130512.gz
        // 
        // [root@jsefler-f14-5candlepin ~]# ls -l  /var/log/tomcat6/catalina.out*
        // -rw-r--r--. 1 tomcat tomcat     102646 May 15 11:56 /var/log/tomcat6/catalina.out
        // -rw-r--r--. 1 tomcat tomcat 1813770240 May 12 03:10 /var/log/tomcat6/catalina.out-20130512
        // "echo \"\" > "+tomcat6LogFile
        RemoteFileTasks.runCommandAndWait(sshCommandRunner, "truncate --size=0 --no-create " + tomcatLogFile.getPath(), TestRecords.action());
    // NOT REALLY NEEDED RemoteFileTasks.runCommandAndWait(sshCommandRunner, "rm -f "+tomcatLogFile.getPath()+"-*", TestRecords.action());
    }
    // deploy.sh: /usr/lib64/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:48:in `return!': 404 Resource Not Found (RestClient::ResourceNotFound)
    if (RemoteFileTasks.testExists(sshCommandRunner, "/var/lib/candlepin/hornetq/")) {
        RemoteFileTasks.runCommandAndWait(sshCommandRunner, "sudo " + "rm -rf /var/lib/candlepin/hornetq/", TestRecords.action());
    }
    // copy the patch file used to enable testing the redeem module to the candlepin proxy dir
    if (false) {
        // 06/15/2015: DefaultSubscriptionServiceAdapter.java has been removed from candlepin-2.0+ with the introduction of per-org product stuff
        File candlepinRedeemTestsMasterPatchFile = new File(System.getProperty("automation.dir", null) + "/scripts/candlepin-RedeemTests-branch-master.patch");
        File candlepinRedeemTestsPatchFile = new File(System.getProperty("automation.dir", null) + "/scripts/candlepin-RedeemTests-branch-" + branch + ".patch");
        if (!candlepinRedeemTestsPatchFile.exists()) {
            log.warning("Failed to find a suitable candlepin patch file for RedeemTests: " + candlepinRedeemTestsPatchFile);
            log.warning("Attempting to substitute the master candlepin patch file for RedeemTests: " + candlepinRedeemTestsMasterPatchFile);
            candlepinRedeemTestsPatchFile = candlepinRedeemTestsMasterPatchFile;
        }
        // RemoteFileTasks.putFile(sshCommandRunner, candlepinRedeemTestsPatchFile.toString(), serverInstallDir+"/proxy/", "0644");
        // RemoteFileTasks.putFile(sshCommandRunner, candlepinRedeemTestsPatchFile.toString(), serverInstallDir+"/", "0644");
        RemoteFileTasks.putFile(sshCommandRunner, candlepinRedeemTestsPatchFile.toString(), serverInstallDir + "/server/", "0644");
        // Stdout: patching file src/main/java/org/fedoraproject/candlepin/service/impl/DefaultSubscriptionServiceAdapter.java
        // Stdout: patching file src/main/java/org/candlepin/service/impl/DefaultSubscriptionServiceAdapter.java
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+"/proxy; patch -p2 < "+candlepinRedeemTestsPatchFile.getName(), Integer.valueOf(0), "patching file .*/DefaultSubscriptionServiceAdapter.java", null);
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+" && patch -p2 < "+candlepinRedeemTestsPatchFile.getName(), Integer.valueOf(0), "patching file .*/DefaultSubscriptionServiceAdapter.java", null);
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd " + serverInstallDir + "/server && patch -p2 < " + candlepinRedeemTestsPatchFile.getName(), Integer.valueOf(0), "patching file .*/DefaultSubscriptionServiceAdapter.java", null);
    }
    // modify the gen-certs file so the candlepin cert is valid for more than one year (make it 20 years)
    // RemoteFileTasks.searchReplaceFile(sshCommandRunner, serverInstallDir+"/proxy/buildconf/scripts/gen-certs", "\\-days 365 ", "\\-days 7300 ");
    // Assert.assertEquals(RemoteFileTasks.searchReplaceFile(sshCommandRunner, serverInstallDir+"/buildconf/scripts/gen-certs", "\\-days 365 ", "\\-days 7300 "),0,"ExitCode from attempt to modify the gen-certs file so the candlepin cert is valid for more than one year (make it 20 years).");
    Assert.assertEquals(RemoteFileTasks.searchReplaceFile(sshCommandRunner, serverInstallDir + "/server/bin/gen-certs", "\\-days 365 ", "\\-days 7300 "), 0, "ExitCode from attempt to modify the gen-certs file so the candlepin cert is valid for more than one year (make it 20 years).");
    // TODO ALTERNATIVE vritant altered candlepin-2.0.11-1 to pass CA_CERT_DAYS during deploy to change the validity end date of the candlepin-ca.crt
    /* TODO: RE-INSTALL GEMS HELPS WHEN THERE ARE DEPLOY ERRORS
		RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "for item in $(for gem in $(gem list | grep -v \"\\*\"); do echo $gem; done | grep -v \"(\" | grep -v \")\"); do echo 'Y' | gem uninstall $item -a; done", Integer.valueOf(0), "Successfully uninstalled", null);	// probably only needs to be run once  // for item in $(for gem in $(gem list | grep -v "\*"); do echo $gem; done | grep -v "(" | grep -v ")"); do echo 'Y' | gem uninstall $item -a; done
		RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+"; gem install bundler", Integer.valueOf(0), "installed", null);	// probably only needs to be run once
		RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+"; gem install buildr", Integer.valueOf(0), "1 gem installed", null);	// probably only needs to be run once
		*/
    /* 3/14/2016: Gem::InstallError: byebug requires Ruby version >= 2.0.0.
		 *     [root@jsefler-f22-candlepin ~]# ruby --version
		 *     ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
		 * Solution:
		 *     [root@jsefler-f22-candlepin ~]# rvm install ruby-2.2.1
		 *     [root@jsefler-f22-candlepin ~]# rvm --default use ruby-2.2.1
		 *     [root@jsefler-f22-candlepin ~]# rvm list
		 *     [root@jsefler-f22-candlepin ~]# gem install bundler
		 *     [root@jsefler-f22-candlepin ~]# cd candlepin/
		 *     [root@jsefler-f22-candlepin candlepin]# bundle install
		 */
    // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+"/proxy && bundle install", Integer.valueOf(0), "Your bundle is complete!", null);	// Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+" && bundle install", Integer.valueOf(0), "Your bundle is complete!", null);	// Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd "+serverInstallDir+" && bundle install", Integer.valueOf(0), "Your bundle is complete!|Bundle complete!", null);	// Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    // Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "cd " + serverInstallDir + " && bundle install --without=proton", Integer.valueOf(0), "Your bundle is complete!|Bundle complete!", null);
    // TODO You may encounter this error on Fedora 23
    // An error occurred while installing rjb (1.4.8), and Bundler cannot continue.
    // Make sure that `gem install -v '1.4.8' succeeds before bundling
    // Note: This error was manually solved by:   dnf -y install redhat-rpm-config
    // delete the keystore to avoid...
    // [root@jsefler-5 ~]# subscription-manager register --username=testuser1 --password=password --org=admin
    // Unable to verify server's identity: certificate verify failed
    // manual fix...
    // [root@jsefler-f14-candlepin candlepin]# rm -rf /etc/tomcat6/keystore
    // [root@jsefler-f14-candlepin candlepin]# service tomcat6 restart
    RemoteFileTasks.runCommandAndWait(sshCommandRunner, "sudo " + "rm -rf /etc/tomcat6/keystore", TestRecords.action());
    // TODO fix this logic for candlepin running on rhel7 which is based on f18
    if (redhatReleaseX >= 7 || fedoraReleaseX >= 16) {
        // the Fedora 16+ way...
        // Stdout: 24 May 17:53:28 ntpdate[20993]: adjust time server 66.187.233.4 offset -0.000287 sec
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "systemctl stop ntpd.service && " + "sudo " + "ntpdate clock.redhat.com && " + "sudo " + "systemctl start ntpd.service && " + "sudo " + "systemctl is-active ntpd.service", Integer.valueOf(0), "^active$", null);
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "systemctl stop postgresql.service && " + "sudo " + "systemctl start postgresql.service && " + "sudo " + "systemctl is-active postgresql.service", Integer.valueOf(0), "^active$", null);
        // avoid java.net.NoRouteToHostException: No route to host
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "systemctl stop firewalld.service && " + "sudo " + "systemctl disable firewalld.service && " + "sudo " + "systemctl is-active firewalld.service", null, "^unknown$", null);
    } else {
        // the old Fedora way...
        // Starting ntpd:  [  OK  ]		// Starting ntpd (via systemctl):  [  OK  ]
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "service ntpd stop && " + "sudo " + "ntpdate clock.redhat.com && " + "sudo " + "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);
        // Starting postgresql service: [  OK  ]	// Starting postgresql (via systemctl):  [  OK  ]
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "service postgresql stop && " + "sudo " + "service postgresql start", /*Integer.valueOf(0) DON"T CHECK EXIT CODE SINCE IT RETURNS 1 WHEN STOP FAILS EVEN THOUGH START SUCCEEDS*/
        null, "Starting postgresql(.*?):\\s+\\[  OK  \\]", null);
        // TODO Untested
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "sudo " + "service iptables stop && " + "sudo " + "chkconfig iptables off", Integer.valueOf(0));
    }
    if (redhatReleaseX >= 7 || fedoraReleaseX >= 19) {
        // the Fedora 19+ way...
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+" && buildconf/scripts/deploy", Integer.valueOf(0), "Initialized!", null);
        // path changes caused by commit cddba55bda2cc1b89821a80e6ff23694296f2079 Fix scripts dir for server build.    before candlepin-0.9.22-1
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+"/server && bin/deploy", Integer.valueOf(0), "Initialized!", null);
        // started throwing... Stderr: tput: No value for $TERM and no -T specified
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TERM=xterm && export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTEDTEST=\"hostedtest\" && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+"/server && bin/deploy", Integer.valueOf(0), "Initialized!", null);
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TERM=xterm && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+"/server && bin/deploy -fHgt", Integer.valueOf(0), "Initialized!", null);
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TERM=xterm && export HOSTNAME=" + hostname + " && export IMPORTDIR=" + serverImportDir + " && cd " + serverInstallDir + "/server && bundle exec bin/deploy -fHgt", Integer.valueOf(0), "Initialized!", null);
    } else {
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+"/proxy && buildconf/scripts/deploy", Integer.valueOf(0), "Initialized!", null);
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+" && buildconf/scripts/deploy", Integer.valueOf(0), "Initialized!", null);
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+" && bundle exec buildconf/scripts/deploy", Integer.valueOf(0), "Initialized!", null);	// prepended "bundle exec" to avoid: You have already activated rjb 1.4.8, but your Gemfile requires rjb 1.4.0. Prepending `bundle exec` to your command may solve this.
        // ^^^^^^ TESTDATA is new for master branch                                                            ^^^^^^^^^ IMPORTDIR applies to branches <= BETA
        // path changes caused by commit cddba55bda2cc1b89821a80e6ff23694296f2079 Fix scripts dir for server build.    before candlepin-0.9.22-1
        // RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME="+hostname+" && export IMPORTDIR="+serverImportDir+" && cd "+serverInstallDir+"/server && bundle exec bin/deploy", Integer.valueOf(0), "Initialized!", null);	// prepended "bundle exec" to avoid: You have already activated rjb 1.4.8, but your Gemfile requires rjb 1.4.0. Prepending `bundle exec` to your command may solve this.
        // started throwing... Stderr: tput: No value for $TERM and no -T specified
        // prepended "bundle exec" to avoid: You have already activated rjb 1.4.8, but your Gemfile requires rjb 1.4.0. Prepending `bundle exec` to your command may solve this.
        RemoteFileTasks.runCommandAndAssert(sshCommandRunner, "export TERM=xterm && export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTEDTEST=\"hostedtest\" && export HOSTNAME=" + hostname + " && export IMPORTDIR=" + serverImportDir + " && cd " + serverInstallDir + "/server && bundle exec bin/deploy", Integer.valueOf(0), "Initialized!", null);
    }
    /* attempt to use live logging
		SSHCommandResult sshCommandResult = sshCommandRunner.runCommandAndWait("cd "+serverInstallDir+"/proxy; buildconf/scripts/deploy", true);
			Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0));
			Assert.assertContainsMatch(sshCommandResult.getStdout(), "Initialized!");
		*/
    /* Note: if getting error on install from master branch:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- oauth (LoadError)
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from ../client/ruby/candlepin_api.rb:9
	from buildconf/scripts/import_products.rb:3:in `require'
	from buildconf/scripts/import_products.rb:3

		 * 
		 * Solution:
		 * # gem install oauth
		 */
    /* Note: if getting error on install from branch:
ssh root@mgmt5.rhq.lab.eng.bos.redhat.com export TESTDATA=1; export FORCECERT=1; export GENDB=1; export HOSTNAME=mgmt5.rhq.lab.eng.bos.redhat.com; export IMPORTDIR=/root/cp_product_utils; cd /root/candlepin/proxy; buildconf/scripts/deploy (com.redhat.qe.tools.SSHCommandRunner.run)
201105121112:39.195 - FINE: Stdout: 
Stopping tomcat6: [  OK  ]
using NO logdriver
============ generating a new db ==============
schema generation failed
 (com.redhat.qe.tools.SSHCommandRunner.runCommandAndWait)
201105121112:39.196 - FINE: Stderr: 
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate rspec (= 2.1.0, runtime) for ["buildr-1.4.5"], already activated rspec-1.3.1 for [] (Gem::LoadError)
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
	from /usr/bin/buildr:18
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate rspec (= 2.1.0, runtime) for ["buildr-1.4.5"], already activated rspec-1.3.1 for [] (Gem::LoadError)
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
	from /usr/bin/buildr:18
		 * 
		 * 
		 * Solution: remove all gems...
		 * # for item in $(for gem in $(gem list | grep -v "\*"); do echo $gem; done | grep -v "("); do echo 'Y' | gem uninstall $item -a; done
		 * 
		 * Then install fresh...
		 * # gem install bundler
		 * # gem install buildr
		 * # bundle install  (in the proxy dir)
		 */
    /*
		Note: if getting an error on...
		Stopping tomcat6: [FAILED]
		...                
		dropdb: database removal failed: ERROR:  database "candlepin" is being accessed by other users
		DETAIL:  There are 3 other session(s) using the database.
		createdb: database creation failed: ERROR:  database "candlepin" already exists

		[root@jsefler-f14-5candlepin candlepin]# service postgresql stop
		Stopping postgresql service:                               [  OK  ]
		[root@jsefler-f14-5candlepin candlepin]# service tomcat6 status
		PID file exists, but process is not running                [WARNING]
		tomcat6 lockfile exists but process is not running         [FAILED]
		ps -ef | grep tomcat6  and then kill -9 the pid                                                          
		[root@jsefler-f14-5candlepin candlepin]# rm /var/run/tomcat6.pid 
		[root@jsefler-f14-5candlepin candlepin]# export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME=jsefler-f14-5candlepin.usersys.redhat.com && export IMPORTDIR= && cd /root/candlepin && bundle exec buildconf/scripts/deploy
		*/
    /* Note: If you encounter this NoMethodError during a deploy, then your installed ruby package is probably older than 1.9.  Solution....
		bin/import_products.rb:3: undefined method `require_relative' for main:Object (NoMethodError)
		
		cd ~/candlepin
		git reset --hard HEAD
		git pull
		\curl -sSL https://get.rvm.io | bash -s stable --ruby=1.9.3
		source /usr/local/rvm/scripts/rvm
		cd ~/candlepin/server
		bundle install
		export TESTDATA=1 && export FORCECERT=1 && export GENDB=1 && export HOSTNAME=jsefler-f14-candlepin.usersys.redhat.com && export IMPORTDIR= && cd /root/candlepin/server && bundle exec bin/deploy
		 */
    // also connect to the candlepin server database
    // do this after the call to deploy since deploy will restart postgresql
    dbConnection = connectToDatabase(dbSqlDriver, dbHostname, dbPort, dbName, dbUsername, dbPassword);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 84 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class CandlepinTasks method createSubscriptionUsingCPC.

public JSONObject createSubscriptionUsingCPC(String ownerKey, String productId) throws JSONException {
    log.info("Using the ruby client to create_subscription ownerKey='" + ownerKey + "' productId='" + productId + "'...");
    if (serverInstallDir.isEmpty())
        log.warning("serverInstallDir is empty.  Check the value of the sm.server.installDir in your automation.properties file.");
    // call the ruby client
    String command = String.format("cd %s; ./cpc create_subscription \"%s\" \"%s\"", serverInstallDir + rubyClientDir, ownerKey, productId);
    SSHCommandResult sshCommandResult = RemoteFileTasks.runCommandAndAssert(sshCommandRunner, command, 0);
    return new JSONObject(sshCommandResult.getStdout().replaceAll("=>", ":"));
}
Also used : JSONObject(org.json.JSONObject) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Example 85 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class CandlepinTasks method createOwnerUsingCPC.

// DELETEME
// /**
// * @param fieldName
// * @param fieldValue
// * @param revokedCerts - usually getCurrentlyRevokedCerts()
// * @return - the RevokedCert from revokedCerts that has a matching field (if not found, null is returned)
// */
// public RevokedCert findRevokedCertWithMatchingFieldFromList(String fieldName, Object fieldValue, List<RevokedCert> revokedCerts) {
// 
// RevokedCert revokedCertWithMatchingField = null;
// for (RevokedCert revokedCert : revokedCerts) {
// try {
// if (RevokedCert.class.getField(fieldName).get(revokedCert).equals(fieldValue)) {
// revokedCertWithMatchingField = revokedCert;
// }
// } catch (IllegalArgumentException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (SecurityException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (NoSuchFieldException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// return revokedCertWithMatchingField;
// }
public JSONObject createOwnerUsingCPC(String owner_name) throws JSONException {
    log.info("Using the ruby client to create_owner owner_name='" + owner_name + "'...");
    if (serverInstallDir.isEmpty())
        log.warning("serverInstallDir is empty.  Check the value of the sm.server.installDir in your automation.properties file.");
    // call the ruby client
    String command = String.format("cd %s; ./cpc create_owner \"%s\"", serverInstallDir + rubyClientDir, owner_name);
    SSHCommandResult sshCommandResult = RemoteFileTasks.runCommandAndAssert(sshCommandRunner, command, 0);
    return new JSONObject(sshCommandResult.getStdout().replaceAll("=>", ":"));
// REMINDER: DateFormat used in JSON objects is...
// protected static String simpleDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";	// "2010-09-01T15:45:12.068+0000"
}
Also used : JSONObject(org.json.JSONObject) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult)

Aggregations

SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)553 Test (org.testng.annotations.Test)416 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)401 SkipException (org.testng.SkipException)219 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)201 ArrayList (java.util.ArrayList)101 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)79 BigInteger (java.math.BigInteger)68 File (java.io.File)58 SubscriptionPool (rhsm.data.SubscriptionPool)53 JSONObject (org.json.JSONObject)47 HashMap (java.util.HashMap)42 ProductSubscription (rhsm.data.ProductSubscription)31 EntitlementCert (rhsm.data.EntitlementCert)30 List (java.util.List)21 YumRepo (rhsm.data.YumRepo)18 ProductCert (rhsm.data.ProductCert)17 Repo (rhsm.data.Repo)16 InstalledProduct (rhsm.data.InstalledProduct)15 Calendar (java.util.Calendar)13