Skip to content

Commit

Permalink
Add smoke test Gradle target
Browse files Browse the repository at this point in the history
  • Loading branch information
prdoyle committed Nov 16, 2024
1 parent 83bb473 commit 98c6139
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Run Gradle Publish
run: |
./gradlew :bosk-core:test publishToSonatype closeAndReleaseSonatypeStagingRepository \
./gradlew smoke publishToSonatype closeAndReleaseSonatypeStagingRepository \
-Pversion="${{github.event.release.tag_name}}" \
--info
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.parallel.ResourceLock;
import works.bosk.junit.Slow;

import static org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;

Expand All @@ -29,5 +30,6 @@
@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@ResourceLock(value="mongoContainer", mode=READ_WRITE)
@Slow // These are inherently slow because they prevent tests from running in parallel
public @interface DisruptsMongoService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import works.bosk.drivers.mongo.TestParameters.EventTiming;
import works.bosk.drivers.mongo.TestParameters.ParameterSet;
import works.bosk.junit.ParametersByName;
import works.bosk.junit.Slow;

import static works.bosk.drivers.mongo.MongoDriverSettings.DatabaseFormat.SEQUOIA;

@UsesMongoService
@Slow
class MongoDriverConformanceTest extends DriverConformanceTest {
private final Deque<Runnable> tearDownActions = new ArrayDeque<>();
private static MongoService mongoService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import works.bosk.DriverStack;
import works.bosk.drivers.HanoiTest;
import works.bosk.junit.ParametersByName;
import works.bosk.junit.Slow;

import static works.bosk.drivers.mongo.MainDriver.COLLECTION_NAME;

@UsesMongoService
@Slow
public class MongoDriverHanoiTest extends HanoiTest {
private static MongoService mongoService;
private final Queue<Runnable> shutdownOperations = new ConcurrentLinkedDeque<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import works.bosk.exceptions.FlushFailureException;
import works.bosk.exceptions.InvalidTypeException;
import works.bosk.junit.ParametersByName;
import works.bosk.junit.Slow;

import static ch.qos.logback.classic.Level.ERROR;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -32,6 +33,7 @@
/**
* Tests the kinds of recovery actions a human operator might take to try to get a busted service running again.
*/
@Slow
public class MongoDriverRecoveryTest extends AbstractMongoDriverTest {
FlushOrWait flushOrWait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import works.bosk.exceptions.FlushFailureException;
import works.bosk.exceptions.InvalidTypeException;
import works.bosk.junit.ParametersByName;
import works.bosk.junit.Slow;
import works.bosk.util.Classes;

import static ch.qos.logback.classic.Level.ERROR;
Expand Down Expand Up @@ -447,6 +448,7 @@ void deleteNonexistentField_ignored() throws InvalidTypeException, IOException,

@ParametersByName
@UsesMongoService
@Slow
void databaseMissingField_fallsBackToDefaultState() throws InvalidTypeException, IOException, InterruptedException {
setLogging(ERROR, ChangeReceiver.class);

Expand Down Expand Up @@ -576,6 +578,7 @@ void refurbish_createsField() throws IOException, InterruptedException {

@ParametersByName
@UsesMongoService
@Slow
void manifestVersionBump_disconnects() throws IOException, InterruptedException {
setLogging(ERROR, MainDriver.class, ChangeReceiver.class);

Expand Down
19 changes: 19 additions & 0 deletions bosk-testing/src/main/java/works/bosk/junit/Slow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package works.bosk.junit;

import org.junit.jupiter.api.Tag;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Omits the test from the {@code smoke} task.
*/
@Target({METHOD, TYPE})
@Retention(RUNTIME)
@Tag("slow")
public @interface Slow {
}
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ spotless {
allprojects {
group = 'works.bosk'
// version should be set as a property with -Pversion

tasks.register('smoke', Test) {
// A set of tests that should finish in under a minute or so.
// Used as a quick double-check before publishing, when we've already
// run the full test suite and so there's no need to run it again.
// If publishing takes longer than desired, tests can be annotated
// with @Slow to omit them from this suite.

group = 'verification'
description = 'Skips tests tagged as "slow" for a quick verification that basic functionality works.'

useJUnitPlatform {
excludeTags 'slow'
}
}
}

nexusPublishing {
Expand Down

0 comments on commit 98c6139

Please sign in to comment.