def test_call(cluster, module_tmpdir, helpers):
    """ RPC calls must work properly right after synchronous join"""
    srv = Server(
        binary_port = 33002,
        http_port = 8082,
    )
    srv.start(
        workdir="{}/localhost-{}".format(module_tmpdir, srv.binary_port)
    )

    try:
        helpers.wait_for(srv.ping_udp, timeout=5)

        obj = cluster['master'].graphql("""
            mutation {
                join_server(
                    uri: "localhost:33002"
                    instance_uuid: "bbbbbbbb-bbbb-4000-b000-000000000001"
                    replicaset_uuid: "bbbbbbbb-0000-4000-b000-000000000000"
                    roles: ["myrole"]
                    timeout: 5
                )
            }
        """)
        assert 'errors' not in obj, obj['errors'][0]['message']
        assert obj['data']['join_server'] == True

        srv.connect()
        assert rpc_call(cluster['master'], 'myrole', 'get_state') == \
            ('initialized', None)

    finally:
        srv.kill()
Exemplo n.º 2
0
def test_uninitialized(module_tmpdir, helpers):
    srv = Server(binary_port=33401, http_port=8401, alias='dummy')
    srv.start(workdir="{}/localhost-{}".format(module_tmpdir, srv.binary_port),
              env={'TARANTOOL_AUTH_ENABLED': 'true'})

    try:
        helpers.wait_for(srv.ping_udp, timeout=5)

        resp = _login(srv, 'admin', 'cluster-cookies-for-the-cluster-monster')
        print('login successful')
        assert resp.status_code == 200, resp.content
        assert 'lsid' in resp.cookies

        lsid = resp.cookies['lsid']
        check_401(srv, cookies={'lsid': None})
        check_200(srv, cookies={'lsid': lsid})

    finally:
        srv.kill()
Exemplo n.º 3
0
#!/usr/bin/env python3

import pytest
import logging
from conftest import Server
from test_multisharding_one import edit_vshard_group, get_vshard_groups

init_script = 'srv_multisharding.lua'

cluster = [
    Server(alias='storage-hot',
           instance_uuid='bbbbbbbb-bbbb-4000-b000-000000000002',
           replicaset_uuid='bbbbbbbb-0000-4000-b000-000000000000',
           roles=['vshard-storage'],
           vshard_group='hot',
           binary_port=33002,
           http_port=8082),
    Server(alias='storage-cold',
           instance_uuid='cccccccc-cccc-4000-b000-000000000002',
           replicaset_uuid='cccccccc-0000-4000-b000-000000000000',
           roles=['vshard-storage'],
           vshard_group='cold',
           binary_port=33004,
           http_port=8084),
    Server(alias='router',
           instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
           replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
           roles=['vshard-router'],
           binary_port=33001,
           http_port=8081)
]
Exemplo n.º 4
0
#!/usr/bin/env python3

import os
import json
import yaml
import pytest
import logging
from conftest import Server

cluster = [
    Server(
        alias='master',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=[],
        binary_port=33001,
        http_port=8081,
    )
]


def test_upload_good(cluster):
    srv = cluster['master']
    srv.conn.eval(
        """
        local auth = require('cartridge.auth')
        local res, err = auth.add_user(...)
        assert(res, tostring(err))
    """, ('guest', 'guest'))

    def upload(cfg):
Exemplo n.º 5
0
#!/usr/bin/env python3

import pytest
import logging
from conftest import Server

cluster = [
    Server(
        alias='firstling',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=[],
        binary_port=33001,
        http_port=8081,
    )
]

unconfigured = [
    Server(
        alias='twin-1',
        instance_uuid="bbbbbbbb-bbbb-4000-b000-000000000001",
        replicaset_uuid="bbbbbbbb-0000-4000-b000-000000000000",
        roles=[],
        binary_port=33011,
        http_port=8181,
    ),
    Server(
        alias='twin-2',
        instance_uuid="bbbbbbbb-bbbb-4000-b000-000000000002",
        replicaset_uuid="bbbbbbbb-0000-4000-b000-000000000000",
        roles=[],
Exemplo n.º 6
0
#!/usr/bin/env python3

import pytest
import logging
from conftest import Server

cluster = [
    Server(alias='master',
           instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
           replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
           roles=[],
           binary_port=33001,
           http_port=8081,
           labels=[{
               "name": "dc",
               "value": "msk"
           }]),
    Server(
        alias='slave',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000002',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=[],
        binary_port=33002,
        http_port=8082,
    )
]

unconfigured = [
    Server(
        alias='spare',
        instance_uuid="dddddddd-dddd-4000-b000-000000000001",
Exemplo n.º 7
0
#!/usr/bin/env python3

import os
import time
import yaml
import pytest
import signal
import logging
from conftest import Server

cluster = [
    Server(
        alias='A1',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=[],
        binary_port=33001,
        http_port=8081,
    ),
    Server(
        alias='B1',
        instance_uuid='bbbbbbbb-bbbb-4000-b000-000000000001',
        replicaset_uuid='bbbbbbbb-0000-4000-b000-000000000000',
        roles=['myrole'],
        binary_port=33002,
        http_port=8082,
    ),
    Server(
        alias='B2',
        instance_uuid='bbbbbbbb-bbbb-4000-b000-000000000002',
        replicaset_uuid='bbbbbbbb-0000-4000-b000-000000000000',
Exemplo n.º 8
0
#!/usr/bin/env python3

import pytest
import logging
from conftest import Server

cluster = [
    Server(
        alias='router',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=['vshard-router'],
        binary_port=33001,
        http_port=8081,
    ),
    Server(
        alias='storage-1',
        instance_uuid="bbbbbbbb-bbbb-4000-b000-000000000001",
        replicaset_uuid="bbbbbbbb-0000-4000-b000-000000000000",
        roles=['vshard-storage'],
        binary_port=33011,
        http_port=8181,
    ),
    Server(
        alias='storage-2',
        instance_uuid="cccccccc-cccc-4000-b000-000000000001",
        replicaset_uuid="cccccccc-0000-4000-b000-000000000000",
        roles=['vshard-storage'],
        binary_port=33012,
        http_port=8182,
    )
Exemplo n.º 9
0
#!/usr/bin/env python3

import pytest
import logging
from conftest import Server

cluster = [
    Server(alias='router',
           instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
           replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
           roles=['vshard-router', 'vshard-storage'],
           binary_port=33001,
           http_port=8081)
]

unconfigured = [
    Server(alias='spare',
           instance_uuid='dddddddd-dddd-4000-b000-000000000001',
           replicaset_uuid='dddddddd-0000-4000-b000-000000000000',
           roles=[],
           vshard_group=None,
           binary_port=33005,
           http_port=8085)
]


def test_api(cluster):
    req = """
        {
            cluster {
                self { uuid }
Exemplo n.º 10
0
#!/usr/bin/env python3

import json
import time
import pytest
import logging
from conftest import Server

cluster = [
    Server(
        alias = 'survivor',
        instance_uuid = 'aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid = 'aaaaaaaa-0000-4000-b000-000000000000',
        roles = ['vshard-router'],
        binary_port = 33001,
        http_port = 8081,
    ),
    Server(
        alias = 'victim',
        instance_uuid = 'bbbbbbbb-bbbb-4000-b000-000000000001',
        replicaset_uuid = 'bbbbbbbb-0000-4000-b000-000000000000',
        roles = ['vshard-storage'],
        binary_port = 33002,
        http_port = 8082,
    )
]

def test_api_disable(cluster):
    # 1. Kill victim
    cluster['victim'].kill()
Exemplo n.º 11
0
def test_uninitialized(module_tmpdir, helpers):
    srv = Server(binary_port=33101, http_port=8181, alias='dummy')
    srv.start(workdir="{}/localhost-{}".format(module_tmpdir,
                                               srv.binary_port), )

    try:
        helpers.wait_for(srv.ping_udp, timeout=5)

        obj = srv.graphql("""
            {
                servers {
                    uri
                    replicaset { roles }
                }
                replicasets {
                    status
                }
                cluster {
                    self {
                        uri
                        uuid
                        alias
                    }
                    can_bootstrap_vshard
                    vshard_bucket_count
                }
            }
        """)
        assert 'errors' not in obj, obj['errors'][0]['message']

        servers = obj['data']['servers']
        assert len(servers) == 1
        assert servers[0] == {'uri': 'localhost:33101', 'replicaset': None}

        replicasets = obj['data']['replicasets']
        assert len(replicasets) == 0

        assert obj['data']['cluster']['self'] == {
            'uri': 'localhost:33101',
            'alias': 'dummy',
            'uuid': None,
        }
        assert obj['data']['cluster']['can_bootstrap_vshard'] == False
        assert obj['data']['cluster']['vshard_bucket_count'] == 3000

        obj = srv.graphql("""
            mutation {
                join_server(uri: "127.0.0.1:33101")
            }
        """)
        assert obj['errors'][0]['message'] == \
            'Invalid attempt to call join_server().' + \
            ' This instance isn\'t bootstrapped yet' + \
            ' and advertises uri="localhost:33101"' + \
            ' while you are joining uri="127.0.0.1:33101".'

        obj = srv.graphql("""
            {
                cluster { failover }
            }
        """)
        assert 'errors' not in obj, obj['errors'][0]['message']
        assert obj['data']['cluster']['failover'] == False

        obj = srv.graphql("""
            mutation {
                cluster { failover(enabled: false) }
            }
        """)
        assert obj['errors'][0]['message'] == 'Not bootstrapped yet'
    finally:
        srv.kill()
Exemplo n.º 12
0
#!/usr/bin/env python3

import json
import time
import pytest
import logging
from conftest import Server

cluster = [
    Server(
        alias='router',
        instance_uuid='aaaaaaaa-aaaa-4000-b000-000000000001',
        replicaset_uuid='aaaaaaaa-0000-4000-b000-000000000000',
        roles=['vshard-router'],
        binary_port=33001,
        http_port=8081,
    ),
    Server(
        alias='storage',
        instance_uuid='bbbbbbbb-bbbb-4000-b000-000000000001',
        replicaset_uuid='bbbbbbbb-0000-4000-b000-000000000000',
        roles=['vshard-storage'],
        binary_port=33002,
        http_port=8082,
    ),
    Server(
        alias='storage-2',
        instance_uuid='bbbbbbbb-bbbb-4000-b000-000000000002',
        replicaset_uuid='bbbbbbbb-0000-4000-b000-000000000000',
        roles=['vshard-storage'],
        binary_port=33004,