public TransactionOutcomeMetricsAssert hasNoKnowledgeOf(TableReference tableReference) { assertMetricNotExists(actual.getMetricName( TransactionOutcome.READ_WRITE_CONFLICT, getTableReferenceTags(tableReference))); assertMetricNotExists(actual.getMetricName( TransactionOutcome.WRITE_WRITE_CONFLICT, getTableReferenceTags(tableReference))); return this; }
private void checkPresentAndCheckCount(TransactionOutcome outcome, long count, TableReference tableReference) { MetricName metricName = actual.getMetricName(outcome, getTableReferenceTags(tableReference)); checkPresentAndCheckCount(metricName, count); }
public TransactionOutcomeMetricsAssert hasPlaceholderWriteWriteConflicts(long count) { checkPresentAndCheckCount( TransactionOutcome.WRITE_WRITE_CONFLICT, count, LoggingArgs.PLACEHOLDER_TABLE_REFERENCE); return this; }
@Test public void tableReferencesIncludedAsTagIfSafe() { transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_1); transactionOutcomeMetrics.markWriteWriteConflict(SAFE_REFERENCE_1); assertThat(transactionOutcomeMetrics) .hasNamedReadWriteConflicts(SAFE_REFERENCE_1, 2) .hasNamedWriteWriteConflicts(SAFE_REFERENCE_1, 1); }
@Test public void conflictsInUnsafeTablesAreNotIncludedAsTags() { transactionOutcomeMetrics.markWriteWriteConflict(UNSAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_2); assertThat(transactionOutcomeMetrics) .hasNoKnowledgeOf(UNSAFE_REFERENCE_1) .hasNoKnowledgeOf(UNSAFE_REFERENCE_2); }
private void checkPresentAndCheckCount(TransactionOutcome outcome, long count) { MetricName metricName = actual.getMetricName(outcome, ImmutableMap.of()); checkPresentAndCheckCount(metricName, count); }
@Test public void canMarkMultipleSuccessfulCommits() { transactionOutcomeMetrics.markSuccessfulCommit(); transactionOutcomeMetrics.markSuccessfulCommit(); transactionOutcomeMetrics.markSuccessfulCommit(); transactionOutcomeMetrics.markSuccessfulCommit(); assertThat(transactionOutcomeMetrics).hasSuccessfulCommits(4); }
@Test public void correctlyDistinguishesConflictsInSafeAndUnsafeTables() { transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_2); transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_2); assertThat(transactionOutcomeMetrics) .hasPlaceholderReadWriteConflicts(2) .hasNamedReadWriteConflicts(SAFE_REFERENCE_1, 1) .hasNamedReadWriteConflicts(SAFE_REFERENCE_2, 1); } }
@Test public void conflictsAcrossMultipleUnsafeTablesAreTrackedWithTheSamePlaceholder() { transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_2); transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(UNSAFE_REFERENCE_2); assertThat(transactionOutcomeMetrics).hasPlaceholderReadWriteConflicts(4); }
@Test public void conflictsInDifferentTablesAreSeparateMetrics() { transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_1); transactionOutcomeMetrics.markReadWriteConflict(SAFE_REFERENCE_2); assertThat(transactionOutcomeMetrics) .hasNamedReadWriteConflicts(SAFE_REFERENCE_1, 1) .hasNamedReadWriteConflicts(SAFE_REFERENCE_2, 1); }
@Test public void conflictsInUnsafeTablesAreTrackedWithPlaceholder() { transactionOutcomeMetrics.markWriteWriteConflict(UNSAFE_REFERENCE_1); assertThat(transactionOutcomeMetrics).hasPlaceholderWriteWriteConflicts(1); }
@Test public void canMarkOneSuccessfulCommit() { transactionOutcomeMetrics.markSuccessfulCommit(); assertThat(transactionOutcomeMetrics).hasSuccessfulCommits(1); }
public TransactionOutcomeMetricsAssert hasAborts(long count) { checkPresentAndCheckCount(TransactionOutcome.ABORT, count); return this; }
public TransactionOutcomeMetricsAssert hasPlaceholderReadWriteConflicts(long count) { checkPresentAndCheckCount( TransactionOutcome.READ_WRITE_CONFLICT, count, LoggingArgs.PLACEHOLDER_TABLE_REFERENCE); return this; }
public TransactionOutcomeMetricsAssert hasFailedCommits(long count) { checkPresentAndCheckCount(TransactionOutcome.FAILED_COMMIT, count); return this; }
public TransactionOutcomeMetricsAssert hasRollbackOther(long count) { checkPresentAndCheckCount(TransactionOutcome.ROLLBACK_OTHER, count); return this; }
public TransactionOutcomeMetricsAssert hasPutUnlessExistsFailures(long count) { checkPresentAndCheckCount(TransactionOutcome.PUT_UNLESS_EXISTS_FAILED, count); return this; }
public TransactionOutcomeMetricsAssert hasNamedWriteWriteConflicts(TableReference tableReference, long count) { checkPresentAndCheckCount(TransactionOutcome.WRITE_WRITE_CONFLICT, count, tableReference); return this; }
public TransactionOutcomeMetricsAssert hasLocksExpired(long count) { checkPresentAndCheckCount(TransactionOutcome.LOCKS_EXPIRED, count); return this; }
public TransactionOutcomeMetricsAssert hasPreCommitCheckFailures(long count) { checkPresentAndCheckCount(TransactionOutcome.PRE_COMMIT_CHECK_FAILED, count); return this; }