예제 #1
0
    def test_db_reload(self):

        connection, clusters = self.test_db_open_not_connected()

        reload_msg = DbReloadMessage( connection )
        cluster_reload = reload_msg.prepare().send().fetch_response()

        assert clusters == cluster_reload
예제 #2
0
    def test_db_reload(self):

        connection, clusters = self.test_db_open_not_connected()

        reload_msg = DbReloadMessage(connection)
        cluster_reload = reload_msg.prepare().send().fetch_response()

        assert clusters == cluster_reload
예제 #3
0
    def test_db_reload(self):

        connection, cluster_info = self.test_db_open_not_connected()

        reload_msg = DbReloadMessage( connection )
        cluster_reload = reload_msg.prepare().send().fetch_response()

        print("Cluster: %s" % cluster_info)
        assert cluster_info.dataClusters == cluster_reload.dataClusters
예제 #4
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)
예제 #5
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)