Exemplo n.º 1
0
    def test_db_open_connected(self):

        connection = OrientSocket("localhost", 2424)
        conn_msg = ConnectMessage(connection)

        print("%r" % conn_msg.get_protocol())
        assert conn_msg.get_protocol() != -1

        session_id = conn_msg.prepare( ("admin", "admin") )\
            .send().fetch_response()

        print("Sid: %s" % session_id)
        assert session_id == connection.session_id
        assert session_id != -1
        # ##################

        msg = DbOpenMessage(connection)

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT,
             "")).send().fetch_response()

        print("Cluster: %s" % cluster_info)
        assert len(cluster_info) != 0
Exemplo n.º 2
0
    def test_db_open_connected(self):

        connection = OrientSocket( "localhost", 2424 )
        conn_msg = ConnectMessage( connection )

        print("%r" % conn_msg.get_protocol())
        assert conn_msg.get_protocol() != -1

        session_id = conn_msg.prepare( ("admin", "admin") )\
            .send().fetch_response()

        print("Sid: %s" % session_id)
        assert session_id == connection.session_id
        assert session_id != -1
        # ##################

        msg = DbOpenMessage( connection )

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT, "")
        ).send().fetch_response()

        print("Cluster: %s" % cluster_info)
        assert len(cluster_info) != 0
Exemplo n.º 3
0
    def test_gremlin(self):
        connection = OrientSocket( "localhost", 2424 )

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage( connection )

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT, "")
        ).send().fetch_response()
        assert len(cluster_info) != 0

        req_msg = CommandMessage( connection )

        res = req_msg.prepare( [ QUERY_GREMLIN, "g.V.outE('followed_by')[0]" ] ) \
            .send().fetch_response()

        assert len(res) == 1
        assert res[0]._rid == '#11:0'
        assert res[0]._class == 'followed_by'
        assert res[0]._version == 1

        print("%r" % res[0]._rid)
        print("%r" % res[0]._class)
        print("%r" % res[0]._version)
Exemplo n.º 4
0
    def test_gremlin(self):
        connection = OrientSocket("localhost", 2424)

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage(connection)

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT,
             "")).send().fetch_response()
        assert len(cluster_info) != 0

        req_msg = CommandMessage(connection)

        res = req_msg.prepare( [ QUERY_GREMLIN, "g.V.outE('followed_by')[0]" ] ) \
            .send().fetch_response()

        assert len(res) == 1
        assert res[0]._rid == '#11:0'
        assert res[0]._class == 'followed_by'
        assert res[0]._version == 1

        print("%r" % res[0]._rid)
        print("%r" % res[0]._class)
        print("%r" % res[0]._version)
Exemplo n.º 5
0
    def test_db_open_not_connected(self):

        connection = OrientSocket( "localhost", 2424 )

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage( connection )

        db_name = "GratefulDeadConcerts"
        _, clusters, _ = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT, "")
        ).send().fetch_response()

        assert len(clusters) != 0
        return connection, clusters
Exemplo n.º 6
0
    def test_db_open_not_connected(self):

        connection = OrientSocket("localhost", 2424)

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage(connection)

        db_name = "GratefulDeadConcerts"
        _, clusters, _ = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT,
             "")).send().fetch_response()

        assert len(clusters) != 0
        return connection, clusters
Exemplo n.º 7
0
    def test_command(self):
        connection = OrientSocket( "localhost", 2424 )

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage( connection )

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT, "")
        ).send().fetch_response()
        assert len(cluster_info) != 0

        req_msg = CommandMessage( connection )

        res = req_msg.prepare( [ QUERY_SYNC, "select * from followed_by limit 1" ] ) \
            .send().fetch_response()

        print("%r" % res[0].rid)
        print("%r" % res[0].o_class)
        print("%r" % res[0].version)
Exemplo n.º 8
0
    def test_command(self):
        connection = OrientSocket("localhost", 2424)

        print("Sid, should be -1 : %s" % connection.session_id)
        assert connection.session_id == -1

        # ##################

        msg = DbOpenMessage(connection)

        db_name = "GratefulDeadConcerts"
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", DB_TYPE_DOCUMENT,
             "")).send().fetch_response()
        assert len(cluster_info) != 0

        req_msg = CommandMessage(connection)

        res = req_msg.prepare( [ QUERY_SYNC, "select * from followed_by limit 1" ] ) \
            .send().fetch_response()

        print("%r" % res[0].rid)
        print("%r" % res[0].o_class)
        print("%r" % res[0].version)
Exemplo n.º 9
0
    def test_data_cluster_add_drop(self):
        import random

        connection = OrientSocket('localhost', 2424)

        db_name = 'GratefulDeadConcerts'
        db_open = DbOpenMessage(connection)
        clusters = db_open.prepare( ( db_name, 'admin', 'admin' ) ) \
            .send().fetch_response()

        _created_clusters = []
        for _rng in range(0, 5):
            data_cadd = DataClusterAddMessage(connection)
            new_cluster_id = data_cadd.prepare([
                'my_cluster_' + str(random.randint(0, 999999999)),
                CLUSTER_TYPE_PHYSICAL  # 'PHYSICAL'
            ]).send().fetch_response()
            _created_clusters.append(new_cluster_id)
            print("New cluster ID: %u" % new_cluster_id)

        os.environ['DEBUG'] = '0'  # silence debug

        _reload = DbReloadMessage(connection)
        new_cluster_list = _reload.prepare().send().fetch_response()

        new_cluster_list.dataClusters.sort(key=lambda cluster: cluster['id'])

        _list = []
        for cluster in new_cluster_list:
            datarange = DataClusterDataRangeMessage(connection)
            value = datarange.prepare(cluster['id']).send().fetch_response()
            print("Cluster Name: %s, ID: %u: %s " \
                  % ( cluster['name'], cluster['id'], value ))
            _list.append(cluster['id'])
            assert value is not []
            assert value is not None

        # check for new cluster in database
        try:
            for _cl in _created_clusters:
                _list.index(_cl)
                print("New cluster found in reload.")
                assert True
        except ValueError:
            assert False

        # now drop all and repeat check
        for _cid in _created_clusters:
            drop_c = DataClusterDropMessage(connection)
            print("Drop cluster %u" % _cid)
            res = drop_c.prepare(_cid).send().fetch_response()
            if res is True:
                print("Done")
            else:
                raise Exception("Cluster " + str(_cid) + " failed")

        _reload = DbReloadMessage(connection)
        new_cluster_list = _reload.prepare().send().fetch_response()
        new_cluster_list.dataClusters.sort(key=lambda cluster: cluster['id'])

        _list = []
        for cluster in new_cluster_list:
            datarange = DataClusterDataRangeMessage(connection)
            value = datarange.prepare(cluster['id']).send().fetch_response()
            print("Cluster Name: %s, ID: %u: %s " \
                  % ( cluster['name'], cluster['id'], value ))
            _list.append(cluster['id'])
            assert value is not []
            assert value is not None

        # check for removed cluster in database
        for _cl in _created_clusters:

            try:
                _list.index(_cl)
                assert False
            except ValueError:
                assert True
                print("Cluster %u deleted." % _cl)
Exemplo n.º 10
0
    def test_data_cluster_add_drop(self):
        import random

        connection = OrientSocket('localhost', 2424)

        db_name = 'GratefulDeadConcerts'
        db_open = DbOpenMessage( connection )
        clusters = db_open.prepare( ( db_name, 'admin', 'admin' ) ) \
            .send().fetch_response()

        _created_clusters = []
        for _rng in range(0, 5):
            data_cadd = DataClusterAddMessage( connection )
            new_cluster_id = data_cadd.prepare(
                [
                    'my_cluster_' + str( random.randint( 0, 999999999 ) ),
                    CLUSTER_TYPE_PHYSICAL    # 'PHYSICAL'
                ]
            ).send().fetch_response()
            _created_clusters.append( new_cluster_id )
            print("New cluster ID: %u" % new_cluster_id)

        os.environ['DEBUG'] = '0'  # silence debug

        _reload = DbReloadMessage(connection)
        new_cluster_list =_reload.prepare().send().fetch_response()

        new_cluster_list.sort(key=lambda cluster: cluster.id)

        _list = []
        for cluster in new_cluster_list:
            datarange = DataClusterDataRangeMessage(connection)
            value = datarange.prepare(cluster.id).send().fetch_response()
            print("Cluster Name: %s, ID: %u: %s " \
                  % (cluster.name, cluster.id, value))
            _list.append(cluster.id)
            assert value is not []
            assert value is not None

        # check for new cluster in database
        try:
            for _cl in _created_clusters:
                _list.index( _cl )
                print("New cluster found in reload.")
                assert True
        except ValueError:
            assert False

        # now drop all and repeat check
        for _cid in _created_clusters:
            drop_c = DataClusterDropMessage( connection )
            print("Drop cluster %u" % _cid)
            res = drop_c.prepare( ( _cid, ) ).send().fetch_response()
            if res is True:
                print("Done")
            else:
                raise Exception( "Cluster " + str(_cid) + " failed")

        _reload = DbReloadMessage(connection)
        new_cluster_list = _reload.prepare().send().fetch_response()
        new_cluster_list.sort(key=lambda cluster: cluster.id)

        _list = []
        for cluster in new_cluster_list:
            datarange = DataClusterDataRangeMessage(connection)
            value = datarange.prepare(cluster.id).send().fetch_response()
            print("Cluster Name: %s, ID: %u: %s "\
                  % (cluster.name, cluster.id, value))
            _list.append( cluster.id)
            assert value is not []
            assert value is not None

        # check for removed cluster in database
        for _cl in _created_clusters:

            try:
                _list.index( _cl )
                assert False
            except ValueError:
                assert True
                print("Cluster %u deleted." % _cl)