public class BlobAccessTest extends JDBCPerfTestCase
These tests are intended to detect Blob performance regressions. Before committing a patch that might change the Blob performance characteristics, first run these tests on a clean build and then with the patch applied. The results can only be compared when both runs are done on the same machine.
The results are the time taken to execute the test. Lower duration is better
(improvement). Currently the results are printed to standard out. There is
one exception, which is testConcurrency
. For this test, the
throughput is printed and it will always run for a fixed amount of time.
The tests are written with two axis in mind: read-only vs update and small vs large. These axis were chosen based on the Blob implementation at the time. In the context of this test, small means the Blob is represented as a string by the Derby store and large means the Blob is represtend as a stream into the Derby store. When a Blob is modified, an in-memory or on disk temporary copy is created. The performance of these temporary representations are tested with the tests that modify the Blob content.
System properties controlling test behavior:
NOTE: Currently there are no tests for the client driver (network) or for encrypted Blobs.
Modifier and Type | Field and Description |
---|---|
private static boolean |
disableConcurrencyTest |
private static boolean |
disableLargeBlobs |
private static boolean |
disableSmallBlobs |
private static int |
FETCH_GETBINARYSTREAM |
private static int |
FETCH_GETBYTES |
private static int |
largeBlobSizeMB |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
BlobAccessTest(java.lang.String name,
int iterations,
int repeats)
Instantiates a new test that will be run the specified number of
iterations and repeated as specified.
|
Modifier and Type | Method and Description |
---|---|
private void |
fetchBlobPieceByPiece(boolean modifyBlob,
int fetchMode)
Fetches a "large" Blob piece by piece using getBytes.
|
private static void |
initializeBlobData(java.sql.Statement stmt)
Generates test data.
|
void |
initializeConnection(java.sql.Connection conn)
Set autocommit to false by default.
|
static junit.framework.Test |
suite()
Generates a suite of tests.
|
void |
testConcurrency()
Runs a test using multiple threads.
|
void |
testFetchLargeBlob()
Fetches a single Blob by reading it in chunks with
getBinaryStream . |
void |
testFetchLargeBlobModified()
Fetches a single Blob by reading it in chunks with
getBinaryStream . |
void |
testFetchLargeBlobOneByOneByte()
Fetches a single Blob and reads it byte by byte.
|
void |
testFetchLargeBlobOneByOneByteBaseline()
Fetches a single Blob and reads it byte by byte, but utilizing a
buffered stream to get a lower time bound on the read operation.
|
void |
testFetchLargeBlobOneByOneByteModified()
Fetches a single Blob and reads it byte by byte after it has first been
modified.
|
void |
testFetchLargeBlobPieceByPiece()
Fetches a single Blob by reading it piece by piece with
getBytes . |
void |
testFetchLargeBlobPieceByPieceModified()
Fetches a single Blob by reading it piece by piece with
getBytes . |
void |
testFetchLargeBlobs()
Fetches a number of Blobs using a rather large read buffer with
getBinaryStream . |
void |
testFetchSmallBlobs()
Fetches a number of small Blobs, getting the content using getBytes.
|
void |
testFetchSmallBlobsInaccurateLength()
Fetches a number of small Blobs, getting the content using getBytes.
|
void |
testLargeBlobGetLength()
Tests if the Blob length is cached.
|
void |
testLargeBlobGetLengthModified()
Tests if the Blob length is cached.
|
void |
testModifySmallBlobs()
Test fetching the content after adding a single byte at the end.
|
runBareOverridable, runTest
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, setName, setUp, toString
private static final boolean disableSmallBlobs
private static final boolean disableLargeBlobs
private static final boolean disableConcurrencyTest
private static final int largeBlobSizeMB
private static final int FETCH_GETBYTES
private static final int FETCH_GETBINARYSTREAM
public BlobAccessTest(java.lang.String name, int iterations, int repeats)
name
- name of the test to instantiateiterations
- number of iterations per repetitionrepeats
- number of repetitionspublic void initializeConnection(java.sql.Connection conn) throws java.sql.SQLException
initializeConnection
in class BaseJDBCTestCase
conn
- Connection to be intializedjava.sql.SQLException
- Error setting the initial state.public static junit.framework.Test suite()
The required test data will be generated. Note that a subset of the tests can be disabled by using a system property.
public void testFetchSmallBlobs() throws java.sql.SQLException
The exact length of the Blob is used when getting the bytes.
java.sql.SQLException
public void testFetchSmallBlobsInaccurateLength() throws java.sql.SQLException
A too long length of the Blob is used when getting the bytes.
java.sql.SQLException
public void testModifySmallBlobs() throws java.sql.SQLException, java.io.UnsupportedEncodingException
java.sql.SQLException
java.io.UnsupportedEncodingException
public void testFetchLargeBlobs() throws java.io.IOException, java.sql.SQLException
getBinaryStream
.java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobOneByOneByteBaseline() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobOneByOneByte() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobOneByOneByteModified() throws java.io.IOException, java.sql.SQLException
The point of modifiying the Blob is to make Derby use the writable Blob representation (different implementation).
java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobPieceByPiece() throws java.io.IOException, java.sql.SQLException
getBytes
.java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobPieceByPieceModified() throws java.io.IOException, java.sql.SQLException
getBytes
.java.io.IOException
java.sql.SQLException
public void testFetchLargeBlob() throws java.io.IOException, java.sql.SQLException
getBinaryStream
.java.io.IOException
java.sql.SQLException
public void testFetchLargeBlobModified() throws java.io.IOException, java.sql.SQLException
getBinaryStream
.java.io.IOException
java.sql.SQLException
private void fetchBlobPieceByPiece(boolean modifyBlob, int fetchMode) throws java.io.IOException, java.sql.SQLException
modifyBlob
- whether to modify the Blob before fetching it
(determines the internal Derby Blob representation)java.io.IOException
java.sql.SQLException
public void testLargeBlobGetLength() throws java.sql.SQLException
java.sql.SQLException
public void testLargeBlobGetLengthModified() throws java.sql.SQLException
java.sql.SQLException
public void testConcurrency() throws java.lang.InterruptedException, java.sql.SQLException
This test intends to detect problems with small Blobs and general problems with concurrency.
NOTE: To produce more reliable numbers, please run the performance client independently outside this JUnit test framework. Performance also suffers greatly with SANE builds.
java.lang.InterruptedException
java.sql.SQLException
private static void initializeBlobData(java.sql.Statement stmt) throws java.sql.SQLException, java.io.UnsupportedEncodingException
java.sql.SQLException
java.io.UnsupportedEncodingException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.