view src/org/thermostat/qa2/tests/DBCommandsHeapDumpTest.java @ 204:1b447165fbd0

enabled collection where missing
author Zdenek Zambersky <zzambers@redhat.com>
date Mon, 07 Dec 2015 18:31:50 +0100
parents 67f1ec14b9cd
children
line wrap: on
line source

/*
 ThermostatQA - test framework for Thermostat Monitoring Tool

 Copyright 2015 Red Hat, Inc.

 This file is part of ThermostatQA

 ThermostatQA is distributed under the GNU General Public License,
 version 2 or any later version (with a special exception described
 below, commonly known as the "Classpath Exception").

 A copy of GNU General Public License (GPL) is included in this
 distribution, in the file COPYING.

 Linking ThermostatQA code with other modules is making a combined work
 based on ThermostatQA.  Thus, the terms and conditions of the GPL
 cover the whole combination.

 As a special exception, the copyright holders of ThermostatQA give you
 permission to link this code with independent modules to produce an
 executable, regardless of the license terms of these independent
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on ThermostatQA code.  If you modify ThermostatQA, you may
 extend this exception to your version of the software, but you are
 not obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.
 */
package org.thermostat.qa2.tests;

import java.io.File;
import java.util.List;
import static org.thermostat.qa2.framework.Assert.*;
import org.thermostat.qa2.framework.Shell;
import org.thermostat.qa2.framework.ThermostatQAConfig;
import org.thermostat.qa2.framework.annotations.*;
import org.thermostat.qa2.framework.utils.ProcessUtilities;
import org.thermostat.qa2.framework.utils.ThermostatUtilities;

/**
 * Test class ported from old framework
 *
 * @author Zdeněk Žamberský
 */
public class DBCommandsHeapDumpTest {

    List<String> scriptOutput;

    @Before
    @SetupStorage(type = "mongo")
    @RunStorage
    @RunAgent
    @RunGnomeKeyring
    public void setUp() throws Exception {
        List<String> vmsLines = ThermostatUtilities.getListVmsOutput();
        String vmLine = ThermostatUtilities.getRunningVmLine();

        assertTrue(vmLine != null, "Problem finding a running vm!");
        String[] lineParts = vmLine.split(" ");
        String hostId = lineParts[0];
        String vmId = lineParts[2];

        ThermostatUtilities.dumpHeap(hostId, vmId);

        String script = "." + File.separator + "scripts" + File.separator + "check-collections-heap-dump.js";
        String[] commands = new String[]{"mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script};
        commands = ProcessUtilities.getCommandLine(commands);
        scriptOutput = ProcessUtilities.runGetOutput(commands);
    }

    public static String errMessage = "problems running auxiliary script";

    @Test
    public void hostInfo() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for host-info is OK");
    }

    @Test
    public void memoryStats() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for memory-stats is OK");
    }

    @Test
    public void networkInfo() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for network-info is OK");
    }

    @Test
    public void numaHostInfo() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for numa-host-info is OK");
    }

    @Test
    public void numaStat() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for numa-stat is OK");
    }

    @Test
    public void vmClassStats() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-class-stats is OK");
    }

    @Test
    public void vmCpuStats() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-cpu-stats is OK");
    }

    @Test
    public void vmGcStats() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-gc-stats is OK");
    }

    @Test
    public void vmHeapInfo() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-heap-info is OK");
    }

    @Test
    public void vmInfo() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-info is OK");
    }

    @Test
    public void vmMemoryStats() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-memory-stats is OK");
    }

    @Test
    public void vmThreadHarvesting() {
        assertNotNull(scriptOutput, errMessage);
        assertContainsPattern(scriptOutput, "schema for vm-thread-harvesting is OK");
    }

}