'Test for inserting wide rows with batching
test_wide_batch_rows tests inserting a wide row of data using batching. It will then attempt to query
that data and ensure that all of it has been inserted appropriately.
@expected_result all items should be inserted, and verified.
@test_category queries:batch'

def test_wide_batch_rows(self):

    table = 'wide_batch_rows'
    session = self.make_session_and_keyspace()
    session.execute(('CREATE    TABLE    %s    (k    INT,    i    INT,    PRIMARY    KEY(k,    i))' % table))
    statement = 'BEGIN    BATCH    '
    to_insert = 2000
    for i in range(to_insert):
        statement += ('INSERT    INTO    %s    (k,    i)    VALUES    (%s,    %s)    ' % (table, 0, i))
    statement += 'APPLY    BATCH'
    statement = SimpleStatement(statement, consistency_level=ConsistencyLevel.QUORUM)
    try:
        session.execute(statement, timeout=30.0)
    except OperationTimedOut:
        (ex_type, ex, tb) = sys.exc_info()
        log.warn('Batch    wide    row    insertion    timed    out,    this    may    require    additional    investigation')
        log.warn('{0}:    {1}    Backtrace:    {2}'.format(ex_type.__name__, ex, traceback.extract_tb(tb)))
        del tb
    results = session.execute(('SELECT    i    FROM    %s    WHERE    k=%s' % (table, 0)))
    lastvalue = 0
    for (j, row) in enumerate(results):
        lastValue = row['i']
        self.assertEqual(lastValue, j)
    index_value = (to_insert - 1)
    self.assertEqual(lastValue, index_value, 'Verification    failed    only    found    {0}    inserted    we    were    expecting    {1}'.format(j, index_value))
    session.cluster.shutdown()
