Skip to content
Permalink
Browse files
fix: test allowed a too old staleness (#214)
  • Loading branch information
olavloite committed Jun 5, 2020
1 parent 1ec0f34 commit f4fa6bfca4bb821cbda426c4cb7bf32f091a2913
Showing with 22 additions and 4 deletions.
  1. +22 −4 ...le-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ITReadOnlySpannerTest.sql
@@ -20,9 +20,11 @@ NEW_CONNECTION;
@EXPECT RESULT_SET 'READONLY',true
SHOW VARIABLE READONLY;

-- Check initial contents.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

-- Check initial contents.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -72,12 +74,14 @@ SELECT CURRENT_TIMESTAMP();

SET READ_ONLY_STALENESS = 'READ_TIMESTAMP %%CURRENT_TIMESTAMP%%';

-- Check SELECT with READ_TIMESTAMP
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@PUT 'READ_TIMESTAMP1'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with READ_TIMESTAMP
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -95,12 +99,14 @@ SELECT CURRENT_TIMESTAMP();

SET READ_ONLY_STALENESS = 'MIN_READ_TIMESTAMP %%CURRENT_TIMESTAMP%%';

-- Check SELECT with MIN_READ_TIMESTAMP
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@EXPECT RESULT_SET 'READ_TIMESTAMP'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with MIN_READ_TIMESTAMP
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -113,12 +119,14 @@ NEW_CONNECTION;

SET READ_ONLY_STALENESS = 'EXACT_STALENESS 1ms';

-- Check SELECT with EXACT_STALENESS
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@EXPECT RESULT_SET 'READ_TIMESTAMP'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with EXACT_STALENESS
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -127,16 +135,18 @@ SHOW VARIABLE READ_TIMESTAMP;


NEW_CONNECTION;
--TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS)
--TimestampBound.ofMaxStaleness(100, TimeUnit.MILLISECONDS)

SET READ_ONLY_STALENESS = 'MAX_STALENESS 10s';
SET READ_ONLY_STALENESS = 'MAX_STALENESS 100ms';

-- Check SELECT with MAX_STALENESS
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@EXPECT RESULT_SET 'READ_TIMESTAMP'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with MAX_STALENESS
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -149,12 +159,14 @@ NEW_CONNECTION;

SET READ_ONLY_STALENESS = 'STRONG';

-- Check SELECT with STRONG
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@EXPECT RESULT_SET 'READ_TIMESTAMP'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with STRONG
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -178,12 +190,14 @@ SET AUTOCOMMIT = FALSE;

SET READ_ONLY_STALENESS = 'READ_TIMESTAMP %%CURRENT_TIMESTAMP%%';

-- Check SELECT with READ_TIMESTAMP in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@PUT 'READ_TIMESTAMP1'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with READ_TIMESTAMP in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -213,12 +227,14 @@ SET AUTOCOMMIT = FALSE;

SET READ_ONLY_STALENESS = 'EXACT_STALENESS 100ms';

-- Check SELECT with EXACT_STALENESS in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@PUT 'READ_TIMESTAMP1'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with EXACT_STALENESS in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

@@ -231,11 +247,11 @@ COMMIT;


NEW_CONNECTION;
--TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS)
--TimestampBound.ofMaxStaleness(100, TimeUnit.MILLISECONDS)
SET AUTOCOMMIT = FALSE;

@EXPECT EXCEPTION FAILED_PRECONDITION
SET READ_ONLY_STALENESS = 'MAX_STALENESS 10s';
SET READ_ONLY_STALENESS = 'MAX_STALENESS 100ms';


NEW_CONNECTION;
@@ -244,12 +260,14 @@ SET AUTOCOMMIT = FALSE;

SET READ_ONLY_STALENESS = 'STRONG';

-- Check SELECT with STRONG in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS;

@PUT 'READ_TIMESTAMP1'
SHOW VARIABLE READ_TIMESTAMP;

-- Check SELECT with STRONG in a transaction.
@EXPECT RESULT_SET
SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS;

0 comments on commit f4fa6bf

Please sign in to comment.