Skip to content

Commit

Permalink
Add StatementPagesTest
Browse files Browse the repository at this point in the history
Adds a simple test that checks if empty pages are correctly
skipped through and all rows are being returned.
Covers scylladb#254.
  • Loading branch information
Bouncheck authored and avelanarius committed Jan 4, 2024
1 parent 8815b20 commit 41b94a4
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.datastax.driver.core;

import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class StatementPagesTest extends CCMTestsSupport{
@Override
public void onTestContextInitialized() {
execute("CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}");
execute("CREATE TABLE IF NOT EXISTS ks.t (pk int, ck int, v int, PRIMARY KEY(pk, ck))");

for (int i = 0; i < 50; i++) {
//System.out.println("Insert " + i);
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 15);
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 32);
}

session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 8, 8, 14);
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 11, 11, 14);
session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 14, 14, 14);
}

@Test(groups = "short")
public void should_not_get_stuck_on_empty_pages(){
SimpleStatement st = new SimpleStatement("SELECT * FROM ks.t WHERE v = 14 ALLOW FILTERING");
st.setFetchSize(1);
ResultSet rs = session().execute(st);
assertThat(rs.all().size()).isEqualTo(3);
}
}

0 comments on commit 41b94a4

Please sign in to comment.