square/keywhiz

Postgresql unit test are failing

sureshg opened this issue · 2 comments

Seems like these tests are not idompotent and failing all the times.

Steps to reproduce the error,

1 . Install new postgresql server (i used 9.2)
2 . Install JDK & unlimited strength JCE crypt policy files
3 . Clone keywhiz
4 . Run mvn -e install -P postgres

INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ keywhiz-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 17 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ keywhiz-server ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ keywhiz-server ---
[INFO] Surefire report directory: /root/keywhiz/server/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running keywhiz.service.daos.SecretDAOTest
WARN  [2017-01-08 06:39:28,789] io.netty.util.internal.ThreadLocalRandom: Failed to generate a seed from SecureRandom within 3 seconds. Not enough entrophy?
Tests run: 19, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 9.867 sec <<< FAILURE!
createSecretSucceedsIfCurrentVersionIsNull(keywhiz.service.daos.SecretDAOTest)  Time elapsed: 0.088 sec  <<< ERROR!
org.jooq.exception.DataAccessException: SQL [insert into secrets (name, createdat, updatedat, description, createdby, updatedby, type, options) values (?, cast(? as timestamp), cast(? as timestamp), ?, ?, ?, ?, ?) returning secrets.id]; duplicate key value violates unique constraint "secrets_pkey"
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:154)
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:136)
	at com.impossibl.postgres.jdbc.PGConnectionImpl.execute(PGConnectionImpl.java:438)
	at com.impossibl.postgres.jdbc.PGStatement.executeStatement(PGStatement.java:375)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.execute(PGPreparedStatement.java:261)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:277)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:92)
	at org.jooq.tools.jdbc.DefaultPreparedStatement.executeQuery(DefaultPreparedStatement.java:83)
	at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:376)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:342)
	at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:176)
	at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:142)
	at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:123)
	at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:138)
	at org.jooq.impl.UpdatableRecordImpl.store0(UpdatableRecordImpl.java:185)
	at org.jooq.impl.UpdatableRecordImpl.access$000(UpdatableRecordImpl.java:85)
	at org.jooq.impl.UpdatableRecordImpl$1.operate(UpdatableRecordImpl.java:135)
	at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:123)
	at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:131)
	at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:123)
	at keywhiz.service.daos.SecretSeriesDAO.createSecretSeries(SecretSeriesDAO.java:91)
	at keywhiz.service.daos.SecretDAO.lambda$createSecret$17(SecretDAO.java:93)
	at org.jooq.impl.DefaultDSLContext.transactionResult(DefaultDSLContext.java:318)
	at keywhiz.service.daos.SecretDAO.createSecret(SecretDAO.java:79)
	at keywhiz.service.daos.SecretDAOTest.createSecretSucceedsIfCurrentVersionIsNull(SecretDAOTest.java:200)

createOrUpdateSecretWhenSecretExists(keywhiz.service.daos.SecretDAOTest)  Time elapsed: 0.028 sec  <<< ERROR!
org.jooq.exception.DataAccessException: SQL [insert into secrets (name, createdat, updatedat, description, createdby, updatedby, type, options) values (?, cast(? as timestamp), cast(? as timestamp), ?, ?, ?, ?, ?) returning secrets.id]; duplicate key value violates unique constraint "secrets_pkey"
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:154)
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:136)
	at com.impossibl.postgres.jdbc.PGConnectionImpl.execute(PGConnectionImpl.java:438)
	at com.impossibl.postgres.jdbc.PGStatement.executeStatement(PGStatement.java:375)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.execute(PGPreparedStatement.java:261)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:277)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:92)
	at org.jooq.tools.jdbc.DefaultPreparedStatement.executeQuery(DefaultPreparedStatement.java:83)
	at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:376)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:342)
	at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:176)
	at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:142)
	at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:123)
	at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:138)
	at org.jooq.impl.UpdatableRecordImpl.store0(UpdatableRecordImpl.java:185)
	at org.jooq.impl.UpdatableRecordImpl.access$000(UpdatableRecordImpl.java:85)
	at org.jooq.impl.UpdatableRecordImpl$1.operate(UpdatableRecordImpl.java:135)
	at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:123)
	at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:131)
	at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:123)
	at keywhiz.service.daos.SecretSeriesDAO.createSecretSeries(SecretSeriesDAO.java:91)
	at keywhiz.service.daos.SecretDAO.lambda$createSecret$17(SecretDAO.java:93)
	at org.jooq.impl.DefaultDSLContext.transactionResult(DefaultDSLContext.java:318)
	at keywhiz.service.daos.SecretDAO.createSecret(SecretDAO.java:79)
	at keywhiz.service.daos.SecretDAOTest.createOrUpdateSecretWhenSecretExists(SecretDAOTest.java:247)

deleteSecretsByName(keywhiz.service.daos.SecretDAOTest)  Time elapsed: 0.023 sec  <<< ERROR!
org.jooq.exception.DataAccessException: SQL [insert into secrets (name, createdat, updatedat, description, createdby, updatedby, type, options) values (?, cast(? as timestamp), cast(? as timestamp), ?, ?, ?, ?, ?) returning secrets.id]; duplicate key value violates unique constraint "secrets_pkey"
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:154)
	at com.impossibl.postgres.jdbc.ErrorUtils.makeSQLException(ErrorUtils.java:136)
	at com.impossibl.postgres.jdbc.PGConnectionImpl.execute(PGConnectionImpl.java:438)
	at com.impossibl.postgres.jdbc.PGStatement.executeStatement(PGStatement.java:375)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.execute(PGPreparedStatement.java:261)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:277)
	at com.impossibl.postgres.jdbc.PGPreparedStatement.executeQuery(PGPreparedStatement.java:92)

.....


ests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.048 sec

Results :

Tests in error:
  SecretDAOTest.createSecretSucceedsIfCurrentVersionIsNull:200 » DataAccess SQL ...
  SecretDAOTest.createOrUpdateSecretWhenSecretExists:247 » DataAccess SQL [inser...
  SecretDAOTest.deleteSecretsByName:425 » DataAccess SQL [insert into secrets (n...

Tests run: 360, Failures: 0, Errors: 3, Skipped: 4

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Keywhiz (Parent) ................................... SUCCESS [  1.473 s]
[INFO] Keywhiz Testing .................................... SUCCESS [  0.676 s]
[INFO] Keywhiz API ........................................ SUCCESS [  4.271 s]
[INFO] Keywhiz Client ..................................... SUCCESS [  0.058 s]
[INFO] Keywhiz CLI ........................................ SUCCESS [  5.851 s]
[INFO] Keywhiz HKDF ....................................... SUCCESS [  0.949 s]
[INFO] Keywhiz Model ...................................... SUCCESS [  7.151 s]
[INFO] Keywhiz Log ........................................ SUCCESS [  0.036 s]
[INFO] Keywhiz Server ..................................... FAILURE [01:38 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:59 min
[INFO] Finished at: 2017-01-08T06:40:56+00:00
[INFO] Final Memory: 47M/511M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project keywhiz-server: There are test failures.
[ERROR]
[ERROR] Please refer to /root/keywhiz/server/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project keywhiz-server: There are test failures.

See #291

We are planning to remove postgres support.

Though this doesn't look postgres related:

WARN [2017-01-08 06:39:28,789] io.netty.util.internal.ThreadLocalRandom: Failed to generate a seed from SecureRandom within 3 seconds. Not enough entrophy?

@mcpherrinm thanks! I was trying to setup one locally using postgresql. By the way, do you guys have any roadmap/future dev plans for keywhiz?