Beispiel #1
0
def _main():
    obj = CloudI()
    assert (obj.nodes_add('["foobar1@hostX", "foobar2@hostY"]') ==
            '{"success":true}')
    assert (obj.nodes_remove('["foobar1@hostX", "foobar2@hostY"]') ==
            '{"success":true}')
    assert (obj.nodes_remove('["foobar1@hostX", "foobar2@hostY"]') ==
            '{"success":false,"error":"{node_not_found,foobar1@hostX}"}')

    assert obj.acl_remove('["all"]') == '{"success":true}'
    assert (obj.acl_add('{"\'all\'": ["\'database\'", "\'tests\'"]}') ==
            '{"success":true}')

    # start extra instances of the http_req test
    services_added = obj.services_add("""\
[{"prefix": "/json_rpc/1/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/2/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/3/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/4/",
  "module": "'cloudi_service_test_http_req'"}]
""")
    if sys.version_info[0] >= 3:
        assert isinstance(services_added, str)
    else:
        assert isinstance(services_added, unicode)
    response = json.loads(services_added)
    assert response['success']
    assert len(response['services_add']) == 4

    url = 'http://localhost:6464'
    assert (urlopen(url + '/json_rpc/1/erlang.xml?value=5').read() ==
            b'<http_test><value>5</value></http_test>')
    assert (urlopen(url + '/json_rpc/2/erlang.xml?value=6').read() ==
            b'<http_test><value>6</value></http_test>')
    assert (urlopen(url + '/json_rpc/3/erlang.xml?value=7').read() ==
            b'<http_test><value>7</value></http_test>')
    assert (urlopen(url + '/json_rpc/4/erlang.xml?value=8').read() ==
            b'<http_test><value>8</value></http_test>')

    # remove the extra instances of the http_req test
    assert (obj.services_remove(
        '["%s", "%s", "%s", "%s"]' %
        tuple(response['services_add'])) == '{"success":true}')
Beispiel #2
0
sys.path.append(
    os.path.sep.join(
        os.path.dirname(os.path.abspath(__file__)).split(os.path.sep)[:-2] +
        ['service_api', 'python']))

import time, urllib2

if __name__ == '__main__':
    from cloudi_service_api import CloudI
    obj = CloudI()
    assert (obj.nodes_add('[foobar1@hostX, foobar2@hostY]') == 'ok')
    assert (obj.nodes_remove('[foobar1@hostX, foobar2@hostY]') == 'ok')
    assert (obj.nodes_remove('[foobar1@hostX, foobar2@hostY]') ==
            '{error,{node_not_found,foobar1@hostX}}')

    assert (obj.acl_remove('[all]') == 'ok')
    assert (obj.acl_add('[{all, [database, tests]}]') == 'ok')

    # start extra instances of the http_req test
    services_added = obj.services_add("""\
[[{prefix, "/json_rpc/1/"},
  {module, cloudi_service_test_http_req}],
 [{prefix, "/json_rpc/2/"},
  {module, cloudi_service_test_http_req}],
 [{prefix, "/json_rpc/3/"},
  {module, cloudi_service_test_http_req}],
 [{prefix, "/json_rpc/4/"},
  {module, cloudi_service_test_http_req}]]
""")
    assert (type(services_added) == list)  # returns the list of new ServiceIds
    assert (len(services_added) == 4)
Beispiel #3
0
               .split(os.path.sep)[:-2] + ['service_api', 'python']
    )
)

import time

if __name__ == '__main__':
    from cloudi_service_api import CloudI
    obj = CloudI()
    assert obj.nodes_add('[foobar1@hostX, foobar2@hostY]') == 'ok'
    assert obj.nodes_remove('[foobar1@hostX, foobar2@hostY]') == 'ok'
    # removing entries that do not exist, does not fail,
    # since the request is valid (despite the fact it is pointless)
    assert obj.nodes_remove('[foobar1@hostX, foobar2@hostY]') == 'ok'

    assert obj.acl_remove('[all]') == 'ok'
    assert obj.acl_add('[{all, [database, tests]}]') == 'ok'

    # remove the hexpi services
    services = obj.services()
    assert obj.services_remove('[%s, %s]' % (
        str(services[1][0]), str(services[4][0]),
    )) == 'ok'

    # start the C flood test
    assert obj.services_add("""\
[{external,
    "/tests/flood/",
    "tests/flood/service/flood", "1 tcp 16384",
    [{"LD_LIBRARY_PATH", "api/c/lib/"},
    {"DYLD_LIBRARY_PATH", "api/c/lib/"}],
Beispiel #4
0
def _main():
    obj = CloudI()
    assert (
        obj.nodes_add('["foobar1@hostX", "foobar2@hostY"]') ==
        '{"success":true}'
    )
    assert (
        obj.nodes_remove('["foobar1@hostX", "foobar2@hostY"]') ==
        '{"success":true}'
    )
    assert (
        obj.nodes_remove('["foobar1@hostX", "foobar2@hostY"]') ==
        '{"success":false,"error":"{node_not_found,foobar1@hostX}"}'
    )

    assert obj.acl_remove('["all"]') == '{"success":true}'
    assert (
        obj.acl_add('{"\'all\'": ["\'database\'", "\'tests\'"]}') ==
        '{"success":true}'
    )

    # start extra instances of the http_req test
    services_added = obj.services_add("""\
[{"prefix": "/json_rpc/1/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/2/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/3/",
  "module": "'cloudi_service_test_http_req'"},
 {"prefix": "/json_rpc/4/",
  "module": "'cloudi_service_test_http_req'"}]
""")
    if sys.version_info[0] >= 3:
        assert isinstance(services_added, str)
    else:
        assert isinstance(services_added, unicode)
    response = json.loads(services_added)
    assert response['success']
    assert len(response['services_add']) == 4

    url = 'http://localhost:6464'
    assert (
        urlopen(url + '/json_rpc/1/erlang.xml?value=5').read() ==
        b'<http_test><value>5</value></http_test>'
    )
    assert (
        urlopen(url + '/json_rpc/2/erlang.xml?value=6').read() ==
        b'<http_test><value>6</value></http_test>'
    )
    assert (
        urlopen(url + '/json_rpc/3/erlang.xml?value=7').read() ==
        b'<http_test><value>7</value></http_test>'
    )
    assert (
        urlopen(url + '/json_rpc/4/erlang.xml?value=8').read() ==
        b'<http_test><value>8</value></http_test>'
    )

    # remove the extra instances of the http_req test
    assert (
        obj.services_remove(
            '["%s", "%s", "%s", "%s"]' % tuple(response['services_add'])
        ) == '{"success":true}'
    )