Exemplo n.º 1
0
from rackattack import api
from rackattack.tcp import transport
from rackattack.tcp import subscribe


SIMPLE_USE_CASE = os.path.join(os.path.dirname(test.__file__), "simpleusecase.py")
HINT = 'rootfs-basic'
LABEL = subprocess.check_output([
    "solvent", "printlabel", "--product", "rootfs", "--repositoryBasename",
    "rootfs-basic"]).strip()
TCPSERVER_SENDMESSAGE = os.path.join(os.path.dirname(__file__), "tcpserver_sendmessage.py")
TCPSERVER_READEVERYTHING = os.path.join(os.path.dirname(__file__), "tcpserver_readeverything.py")


logging.getLogger('pika').setLevel(logging.INFO)
connection.discardParamikoLogs()


class Test(unittest.TestCase):
    def test_singleNodeAllocation(self):
        popen = subprocess.Popen(["python", SIMPLE_USE_CASE], stdin=subprocess.PIPE)
        popen.stdin.write("c\n")
        popen.stdin.close()
        result = popen.wait()
        if result != 0:
            raise Exception("simpleusecase.py failed %d" % result)

    def test_singleNodeAllocation_PDBDoesNotCauseAllocationToDie(self):
        popen = subprocess.Popen(["python", SIMPLE_USE_CASE], stdin=subprocess.PIPE)
        print "Sleeping for 180 seconds, to make sure heartbeat timeout occours, if pdb stops"
        time.sleep(180)
Exemplo n.º 2
0
import unittest
from tests import uservirtualrackattack
from tests import testlib
import rackattack
from rackattack.ssh import connection
connection.discardParamikoLogs()
connection.discardSSHDebugMessages()


class Test(unittest.TestCase):
    def setUp(self):
        self.assertTrue('/usr/' not in rackattack.__file__)
        self.server = uservirtualrackattack.UserVirtualRackAttack()

    def tearDown(self):
        self.server.done()

    def test_it(self):
        self.client = self.server.createClient()
        self.assertEquals(self.server.MAXIMUM_VMS, 4)
        allocation = self.client.allocate(
            requirements={'node': testlib.defaultRequirement()},
            allocationInfo=testlib.whiteboxAllocationInfo())
        allocation.wait(timeout=5 * 60)
        self.assertFalse(allocation.dead())
        self.assertTrue(allocation.done())
        nodes = allocation.nodes()
        self.assertEquals(len(nodes), 1)
        node = nodes['node']
        ssh = connection.Connection(**node.rootSSHCredentials())
        ssh.waitForTCPServer()