Ejemplo n.º 1
0
 def test_set_read_var(self):
     init()
     context.port = 2030
     task = Task()
     cmd = task.command('echo $port')
     task.assert_that(cmd.stdout.content, contains_string('2030'))
     commit()
Ejemplo n.º 2
0
 def test_vv_implies_nocapture(self):
     task = Task()
     cmd = task.command(
         prego_cmd %
         '-vv test/fixtures/output.py:OutputFixture.test_print_text')
     task.assert_that(cmd.stdout.content,
                      contains_string('OutputFixture printed this'))
Ejemplo n.º 3
0
 def test_env(self):
     init()
     context.env = {'PREGO_SAMPLE': 'hello'}
     task = Task()
     task.command('echo $PREGO_SAMPLE')
     task.assert_that(task.lastcmd.stdout.content, contains_string('hello'))
     commit()
Ejemplo n.º 4
0
 def test_escape_linebreaks_on_log(self):
     task = Task()
     task.command(
         prego_cmd %
         '-v test/integration/cases.py:multiline_commands.test_writing_out')
     task.assert_that(task.lastcmd.stderr.content,
                      contains_string("hi\\nbye\\nagain"))
Ejemplo n.º 5
0
 def test_default_cwd(self):
     init()
     context.cwd = '/tmp'
     task = Task()
     task.command('pwd')
     task.assert_that(task.lastcmd.stdout.content, contains_string('/tmp'))
     commit()
Ejemplo n.º 6
0
 def test_default_env(self):
     init()
     context.env = {'MY_ENV_VAR': '42'}
     task = Task()
     task.command('echo $MY_ENV_VAR')
     task.assert_that(task.lastcmd.stdout.content, contains_string('42'))
     commit()
Ejemplo n.º 7
0
 def test_old_config(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config test/fixtures/deprecated.conf create gh:ripio-test/foo',
         expected=1)
     ripio.assert_that(
         ripio.lastcmd.stdout.content,
         hamcrest.contains_string('AccessDenied: github:ripio-test/foo'))
Ejemplo n.º 8
0
Archivo: test.py Proyecto: Rizoss/upper
    def run_server(self, prog):
        server = Task('server', detach=True)
        server.assert_that(localhost,
                           is_not(listen_port(context.port, proto='tcp')))
        server.command("./{0} $port".format(prog), expected=None)

        clients = self.run_clients()
        wait_clients(clients)
Ejemplo n.º 9
0
Archivo: test.py Proyecto: Rizoss/upper
    def run_server(self, prog):
        server = Task(detach=True)
        server.assert_that(localhost,
                           is_not(listen_port(context.port, proto='udp')))
        server.command('./{0} $port'.format(prog), timeout=15, expected=None)

        clients = self.run_clients()
        wait_clients(clients)
Ejemplo n.º 10
0
    def test_print_outs_on_fail(self):
        task = Task()
        task.command(prego_cmd % '-peo examples/examples.py:Test.test_cmd_fail_with_outs', expected=1)
        task.assert_that(task.lastcmd.stderr.content,
                         contains_string("A.0.out| STDOUT"))

        task.assert_that(task.lastcmd.stderr.content,
                         contains_string("A.3.err| STDERR"))
Ejemplo n.º 11
0
 def test_bitbucket_private_no_creds(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config /dev/null clone bb:ripio-test/private',
         expected=1,
         timeout=10)
     ripio.assert_that(ripio.lastcmd.stdout.content,
                       hamcrest.contains_string('AccessDenied'))
Ejemplo n.º 12
0
Archivo: test.py Proyecto: Rizoss/upper
    def test_help(self):
        for fname in glob.glob('*.py'):
            if 'stress' in fname or 'client' in fname:
                continue

            app = Task()
            app.command('./{}'.format(fname), expected=1)
            app.assert_that(
                app.lastcmd.stdout.content,
                contains_string('Usage: ./{} <port>'.format(fname)))
Ejemplo n.º 13
0
 def test_install(self):
     task = Task()
     task.assert_that(Package('python3-virtualenv'), installed())
     task.assert_that(Package('virtualenv'), installed())
     task.command('rm dist/*', expected=None)
     task.command('python setup.py sdist', timeout=20)
     task.command('virtualenv --clear venv', timeout=10)
     task.command(
         '. venv/bin/activate; pip install dist/prego*; echo y | pip uninstall prego; deactivate',
         timeout=50)
Ejemplo n.º 14
0
 def test_github_private_no_creds(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config /dev/null clone gh:ripio-test/private',
         expected=1,
         timeout=10)
     ripio.assert_that(
         ripio.lastcmd.stdout.content,
         hamcrest.contains_string(
             'RepositoryNotFound: github:ripio-test/private'))
Ejemplo n.º 15
0
    def test_client_server(self):
        context.cwd = '$testdir'
        servertask = Task('server', detach=True)
        server = servertask.command('%s Server --Ice.Config=Server.config' % java,
                                    signal=2, expected=130)
        servertask.assert_that(server.stdout.content, contains_string('Hello World!'))

        clientside = Task('client')
        clientside.wait_that(server, running())
        clientside.wait_that(server.stdout.content, contains_string('printer1'))
        clientside.command('%s Client "$(head -1 %s)"' % (java, server.stdout.path))
Ejemplo n.º 16
0
    def make_client_server(self, client, server):
        servertask = Task('server', detach=True)
        server = servertask.command('{} --Ice.Config=Server.config'.format(server),
                                    cwd='$testdir', signal=2)
        servertask.assert_that(server.stdout.content, contains_string('Hello World!'))

        clientside = Task('client')
        clientside.wait_that(server, running())
        clientside.wait_that(server.stdout.content, contains_string('printer1'))
        clientside.command('{} "$(head -1 {})"'.format(client, server.stdout.path),
                           cwd='$testdir')
Ejemplo n.º 17
0
    def test_factorial(self):
        Task().command('make clean all')

        server = Task('server', detach=True)
        server.command('./factorial_server', expected=-15)

        client = Task('client')
        client.assert_that(server, running())
        client.command('./factorial_client localhost 8')
        client.assert_that(client.lastcmd.stdout.content,
                           hamcrest.contains_string('factorial(8): 40320'))
Ejemplo n.º 18
0
    def test_show_log_on_fail_command(self):
        task = Task(desc='fail')
        cmd = task.command(nose +
                           'examples/examples.py:Test.test_cmd_false_true',
                           expected=1)
        strings = [
            "TestFailed: assert that command A.0 expected returncode 0, but was 1",
            ">> begin captured logging <<", "[FAIL]   A   Task end - elapsed:"
        ]

        for s in strings:
            task.assert_that(cmd.stderr.content, contains_string(s))
Ejemplo n.º 19
0
    def test_netcat(self):
        context.port = 2000
        server = Task(desc='netcat server', detach=True)
        server.assert_that(Package('nmap'), installed())
        server.assert_that(localhost,
                           hamcrest.is_not(listen_port(context.port)))
        cmd = server.command('ncat -l -p $port')
        server.wait_that(cmd.stdout.content, hamcrest.contains_string('bye'))

        client = Task(desc='netcat client')
        client.wait_that(server, running())
        client.wait_that(localhost, listen_port(context.port))
        client.command('echo bye | ncat localhost $port')
Ejemplo n.º 20
0
Archivo: test.py Proyecto: Rizoss/upper
    def run_clients(self):
        Task().wait_that(localhost, listen_port(context.port, proto='tcp'))

        clients = []
        for i in range(10):
            req = 'hello-%s' % i
            client = Task('client', detach=True)
            client.command('echo %s | ./TCP_client.py localhost $port' % req)
            client.assert_that(client.lastcmd.stdout.content,
                               contains_string("Reply is '" + req.upper()))
            clients.append(client)

        return clients
Ejemplo n.º 21
0
    def test_keep_going_off(self):
        task = Task()
        cmd = task.command(
            prego_cmd % 'examples/examples.py:Test.test_cmd_wrong_true_and_ls',
            expected=1)

        strings = [
            "[ ok ]   A.0 Command 'wrong' code (0:127)",
            "assert that command A.0 expected returncode 0, but was 127",
            "[ -- ]   A.3 Command 'true'",
            "[ -- ]   A.5 assert that command A.3 returncode 0",
        ]

        for s in strings:
            task.assert_that(cmd.stderr.content, contains_string(s))
Ejemplo n.º 22
0
    def test_is_reachable(self):
        link = Task(desc="Is interface link up?")
        link.command('ip link | grep eth0 | grep "state UP"')

        router = Task(desc="Is the local router reachable?")
        router.command("ping -c2 $(ip route | grep ^default | cut -d' ' -f 3)")

        for line in open('/etc/resolv.conf'):
            if line.startswith('nameserver'):
                server = line.split()[1]
                test = Task(desc="Is DNS server {0} reachable?".format(server))
                test.command('ping -c 2 {0}'.format(server))

        resolve = Task(desc="may google name be resolved?")
        resolve.command('host www.google.com')

        ping = Task(desc="Is google reachable?")
        ping.command('ping -c 1 www.google.com')
        ping.assert_that(Host('www.google.com'), reachable())
        ping.assert_that(Host('www.googlewrong.com'), hamcrest.is_not(reachable()))

        web = Task(desc="get index.html")
        cmd = web.command('wget http://www.google.com/webhp?hl=en -O-')
        web.assert_that(cmd.stdout.content,
                        hamcrest.contains_string('value="I\'m Feeling Lucky"'))
Ejemplo n.º 23
0
    def test_pre_post(self):
        task = Task()
        task.assert_that(Variable('SHELL'), exists())
        task.assert_that(File('/etc/fstab'), exists())
        task.command('cp /etc/fstab /tmp/')
        task.generate_files('/tmp/fstab')

        task.command('ls / > /tmp/kk')  # shell=True)
        task.generate_files('/tmp/kk')

        task.assert_that(
            File('/tmp/kk').content,
            all_of(contains_string('sbin'), contains_string('home'),
                   contains_string('boot')))
Ejemplo n.º 24
0
 def test_installed_version(self):
     depends = Task()
     depends.assert_that(Package('bash'), installed(min_version='3.0'))
Ejemplo n.º 25
0
 def test_noauto_log_stderr_when_stderr_flag(self):
     task = Task()
     cmd = task.command(prego_cmd %
                        '-ve examples/command-outs.py:OK.test_ls_stderr')
     task.assert_that(cmd.stderr.content,
                      contains_string('A.0.err| /etc/passwd'))
Ejemplo n.º 26
0
 def test_auto_log_stdout(self):
     task = Task()
     cmd = task.command(
         prego_cmd % '-vo examples/command-outs.py:OK.test_ls_stdout_auto')
     task.assert_that(cmd.stderr.content,
                      contains_string('A.0.out| /etc/passwd'))
Ejemplo n.º 27
0
 def test_installed(self):
     depends = Task()
     depends.assert_that(Package('bash'), installed())
     depends.assert_that(Package('never-installed'), is_not(installed()))
Ejemplo n.º 28
0
 def test_z_read_missing(self):
     init()
     task = Task()
     cmd = task.command('echo $port')
     task.assert_that(cmd.stdout.content, is_not(contains_string('2030')))
     commit()