Search in sources :

Example 21 with BeforeSuite

use of org.testng.annotations.BeforeSuite in project helix by apache.

the class ZkIntegrationTestBase method beforeSuite.

@BeforeSuite
public void beforeSuite() throws Exception {
    // TODO: use logging.properties file to config java.util.logging.Logger levels
    java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
    topJavaLogger.setLevel(Level.WARNING);
    // Due to ZOOKEEPER-2693 fix, we need to specify whitelist for execute zk commends
    System.setProperty("zookeeper.4lw.commands.whitelist", "*");
    _zkServer = TestHelper.startZkServer(ZK_ADDR);
    AssertJUnit.assertTrue(_zkServer != null);
    ZKClientPool.reset();
    _gZkClient = new ZkClient(ZK_ADDR);
    _gZkClient.setZkSerializer(new ZNRecordSerializer());
    _gSetupTool = new ClusterSetup(_gZkClient);
    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) ClusterSetup(org.apache.helix.tools.ClusterSetup) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 22 with BeforeSuite

use of org.testng.annotations.BeforeSuite in project rhsm-qe by RedHatQE.

the class SubscriptionManagerCLITestScript method ensureSELinuxIsEnforcingBeforeSuite.

@BeforeSuite(groups = { "setup" }, dependsOnMethods = { "setupBeforeSuite" }, description = "Ensure SELinux is Enforcing before running the test suite.")
public void ensureSELinuxIsEnforcingBeforeSuite() {
    for (SubscriptionManagerTasks clienttasks : Arrays.asList(client1tasks, client2tasks)) {
        if (clienttasks != null) {
            // mark the audit.log file so it can be asserted for denials in verifyNoSELinuxDenialsWereLoggedAfterClass()
            RemoteFileTasks.markFile(clienttasks.sshCommandRunner, clienttasks.auditLogFile, selinuxSuiteMarker);
            // TEMPORARY WORKAROUND
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1257940 - systemd-hwdb should be confined
            String bugId = "1257940";
            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("Skipping BeforeSuite assertion that selinux is Enforcing while bug " + bugId + " is open.");
                continue;
            }
            // END OF WORKAROUND
            // TEMPORARY WORKAROUND
            invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1342401 - Allow NetworkManager to create temporary /etc/resolv.conf.XXXXXX file
            bugId = "1342401";
            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("Skipping BeforeSuite assertion that selinux is Enforcing while bug " + bugId + " is open.");
                continue;
            }
            // END OF WORKAROUND
            // TEMPORARY WORKAROUND
            invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1343648 - SELinux label for /etc/udev/hwdb.bin is etc_t instead of systemd_hwdb_etc_t after "#systemd-hwdb update"
            bugId = "1343648";
            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("Skipping BeforeSuite assertion that selinux is Enforcing while bug " + bugId + " is open.");
                continue;
            }
            // END OF WORKAROUND
            // TEMPORARY WORKAROUND
            invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1350756 - SELinux label for /etc/udev/hwdb.bin is etc_t instead of systemd_hwdb_etc_t after "#systemd-hwdb update"
            bugId = "1350756";
            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("Skipping BeforeSuite assertion that selinux is Enforcing while bug " + bugId + " is open.");
                continue;
            }
            // END OF WORKAROUND
            // assert selinux is Enforcing
            Assert.assertEquals(clienttasks.sshCommandRunner.runCommandAndWait("getenforce").getStdout().trim(), "Enforcing", "SELinux mode is set to enforcing on client " + clienttasks.sshCommandRunner.getConnection().getRemoteHostname());
        }
    }
}
Also used : SubscriptionManagerTasks(rhsm.cli.tasks.SubscriptionManagerTasks) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 23 with BeforeSuite

use of org.testng.annotations.BeforeSuite in project rhsm-qe by RedHatQE.

the class SubscriptionManagerCLITestScript method dumpHardwareInfoBeforeSuite.

@BeforeSuite(groups = { "setup" }, dependsOnMethods = { "setupBeforeSuite" }, description = "Dump the system's hardware info to a tar file and upload it for archival review.")
public void dumpHardwareInfoBeforeSuite() throws IOException {
    if (client != null) {
        // dump hardware info from dmidecode...
        if (clienttasks.isPackageInstalled("dmidecode")) {
            File remoteFile = new File("/root/hw_info_dump.tar");
            // [root@jsefler-5 ~]# dmidecode --dump-bin dmi_dump.bin; TMPDIR=`mktemp -d` && mkdir $TMPDIR/proc; cp /proc/cpuinfo $TMPDIR/proc/; cp /proc/sysinfo $TMPDIR/proc/; mkdir -p $TMPDIR/sys/devices/system/cpu; cp -r /sys/devices/system/cpu $TMPDIR/sys/devices/system/; tar -cf hw_info_dump.tar --ignore-failed-read --sparse dmi_dump.bin $TMPDIR  && tar -tvf hw_info_dump.tar && rm -rf $TMPDIR
            client.runCommandAndWait("dmidecode --dump-bin dmi_dump.bin; TMPDIR=`mktemp -d`; mkdir $TMPDIR/proc; cp /proc/cpuinfo $TMPDIR/proc/; cp /proc/sysinfo $TMPDIR/proc/; mkdir -p $TMPDIR/sys/devices/system/cpu; cp -r /sys/devices/system/cpu $TMPDIR/sys/devices/system/; tar -cf " + remoteFile.getName() + " --ignore-failed-read --sparse dmi_dump.bin $TMPDIR  && tar -tvf " + remoteFile.getName() + " && rm -rf $TMPDIR");
            if (!RemoteFileTasks.testExists(client, remoteFile.getPath()))
                client.runCommandAndWait("touch " + remoteFile.getPath());
            File localFile = new File((getProperty("automation.dir", "/tmp") + "/test-output/" + remoteFile.getName()));
            RemoteFileTasks.getFile(client, localFile.getParent(), remoteFile.getPath());
        }
        // dump hardware info from sosreport...
        if (clienttasks.isPackageInstalled("sos")) {
            String plugins = "hardware";
            if (Integer.valueOf(clienttasks.redhatReleaseX) >= 5)
                plugins = "hardware";
            if (Integer.valueOf(clienttasks.redhatReleaseX) >= 6)
                plugins = "hardware,powerpc";
            if (Integer.valueOf(clienttasks.redhatReleaseX) >= 7)
                plugins = "hardware,powerpc,processor,ceph";
            // [root@jsefler-os7 ~]# sosreport --batch --only-plugins=processor,powerpc  --tmp-dir=/var/tmp
            // 
            // sosreport (version 3.2)
            // 
            // This command will collect diagnostic and configuration information from
            // this Red Hat Enterprise Linux system and installed applications.
            // 
            // An archive containing the collected information will be generated in
            // /var/tmp and may be provided to a Red Hat support representative.
            // 
            // Any information provided to Red Hat will be treated in accordance with
            // the published support policies at:
            // 
            // https://access.redhat.com/support/
            // 
            // The generated archive may contain data considered sensitive and its
            // content should be reviewed by the originating organization before being
            // passed to any third party.
            // 
            // No changes will be made to system configuration.
            // 
            // 
            // Setting up archive ...
            // Setting up plugins ...
            // Running plugins. Please wait ...
            // 
            // Running 1/2: powerpc...
            // Running 2/2: processor...
            // 
            // Creating compressed archive...
            // 
            // Your sosreport has been generated and saved in:
            // /var/tmp/sosreport-jsefler-os7.usersys.redhat.com-20141013121912.tar.xz
            // 
            // The checksum is: 262a4a74df6c84e9d3dcd556dcd4abf0
            // 
            // Please send this file to your support representative.
            // 
            // [root@jsefler-os7 ~]# ls -l /var/tmp/sosreport-jsefler-os7.usersys.redhat.com-20141013121912.tar.xz
            // -rw-r--r--. 1 root root 5444 Oct 13 12:19 /var/tmp/sosreport-jsefler-os7.usersys.redhat.com-20141013121912.tar.xz
            // [root@jsefler-os7 ~]#
            SSHCommandResult sosResult = client.runCommandAndWait("sosreport --batch --tmp-dir=/var/tmp --only-plugins=" + plugins);
            // /var/tmp/sosreport-jsefler-os7.usersys.redhat.com-20141013121912.tar.xz	// /var/tmp/sosreport-jsefler-5.usersys.redhat.com.tar.bz2
            File remoteFile = new File(getSubstringMatches(sosResult.getStdout(), "/var/tmp/sosreport-.+\\.tar\\.(xz|bz2)").get(0));
            if (RemoteFileTasks.testExists(client, remoteFile.getPath())) {
                File localFile = new File((getProperty("automation.dir", "/tmp") + "/test-output/" + remoteFile.getName()));
                RemoteFileTasks.getFile(client, localFile.getParent(), remoteFile.getPath());
                // strip out -20141013121912
                localFile.renameTo(new File(localFile.getPath().replaceFirst("-\\d{14}", "")));
            }
        }
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) File(java.io.File) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 24 with BeforeSuite

use of org.testng.annotations.BeforeSuite in project rhsm-qe by RedHatQE.

the class SubscriptionManagerCLITestScript method prepareRegisteredConsumerCertsDirectoryBeforeSuite.

@BeforeSuite(groups = { "setup" }, dependsOnMethods = { "setupBeforeSuite" }, description = "Prepare a temporary consumer cert directory where we can track all of the consumers created so we can return their entitlements after the suite.")
public void prepareRegisteredConsumerCertsDirectoryBeforeSuite() {
    for (SubscriptionManagerTasks clienttasks : Arrays.asList(client1tasks, client2tasks)) {
        if (clienttasks != null) {
            // /*debugTestSSL*/ if (false)
            clienttasks.sshCommandRunner.runCommandAndWait("rm -rf " + allRegisteredConsumerCertsDir);
            clienttasks.sshCommandRunner.runCommandAndWait("mkdir -p " + allRegisteredConsumerCertsDir);
        }
    }
}
Also used : SubscriptionManagerTasks(rhsm.cli.tasks.SubscriptionManagerTasks) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 25 with BeforeSuite

use of org.testng.annotations.BeforeSuite 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;
}
Also used : SSHCommandRunner(com.redhat.qe.tools.SSHCommandRunner) FileWriter(java.io.FileWriter) SubscriptionManagerTasks(rhsm.cli.tasks.SubscriptionManagerTasks) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) BufferedWriter(java.io.BufferedWriter) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) CandlepinTasks(rhsm.cli.tasks.CandlepinTasks) File(java.io.File) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) BeforeSuite(org.testng.annotations.BeforeSuite)

Aggregations

BeforeSuite (org.testng.annotations.BeforeSuite)65 PrismInternalTestUtil (com.evolveum.midpoint.prism.PrismInternalTestUtil)12 HashMap (java.util.HashMap)12 File (java.io.File)11 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)6 FileInputStream (java.io.FileInputStream)5 Properties (java.util.Properties)5 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)5 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)5 ZNRecordSerializer (org.apache.helix.manager.zk.ZNRecordSerializer)4 ZkClient (org.apache.helix.manager.zk.ZkClient)4 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)4 Actions (org.openqa.selenium.interactions.Actions)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 SubscriptionManagerTasks (rhsm.cli.tasks.SubscriptionManagerTasks)3 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)2 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)2 InputStream (java.io.InputStream)2