Skip to content

Commit

Permalink
Merge pull request #192 from fauna/perf-test-tweaks
Browse files Browse the repository at this point in the history
chore(perf-tests): A few minor tweaks to perf tests
  • Loading branch information
adambollen authored Dec 18, 2024
2 parents 259b6f0 + df5d225 commit 7d1e340
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion concourse/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ resources:
- name: dev-tests-trigger
type: time
source:
interval: 6h
interval: 24h

jobs:
- name: set-self
Expand Down
2 changes: 1 addition & 1 deletion concourse/scripts/perf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export LOG_UNIQUE=$(date +%s%3N)
# Install fauna-shell
apt update -qq
apt install -y -qq npm
npm install --silent -g fauna-shell@^2.0.0
npm install --silent -g fauna-shell@^3.0.0

cd repo.git

Expand Down
2 changes: 1 addition & 1 deletion perf-test-setup
Submodule perf-test-setup updated 2 files
+23 −2 README.md
+1 −1 init.sh
29 changes: 24 additions & 5 deletions src/test/java/com/fauna/e2e/E2EFeedsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import com.fauna.exception.InvalidRequestException;
import com.fauna.response.QueryFailure;
import com.fauna.response.QuerySuccess;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
Expand Down Expand Up @@ -46,6 +48,10 @@ public static void setup() {
FaunaConfig config =
FaunaConfig.builder().endpoint(LOCAL).secret("secret").build();
client = Fauna.client(config);
}

@BeforeEach
public void setupEach() {
productCollectionTs = Fixtures.ProductCollection(client);
}

Expand Down Expand Up @@ -85,7 +91,10 @@ public void manualFeed() {
// Handle page
FeedPage<Product> latestPage = pageFuture.join();
lastPageCursor = latestPage.getCursor();
productUpdates.addAll(latestPage.getEvents());

List<FaunaEvent<Product>> pageOfEvents = latestPage.getEvents();

productUpdates.addAll(pageOfEvents);
pageCount++;

// Get next page (if it's not null)
Expand All @@ -100,11 +109,21 @@ public void manualFeed() {
}
assertEquals(50, productUpdates.size());
assertEquals(25, pageCount);
// Because there is no filtering, these cursors are the same.
// If we filtered events, then the page cursor could be different from the cursor of the last element.
assertEquals(lastPageCursor,
productUpdates.get(productUpdates.size() - 1).getCursor());

client.query(fql("Product.create({name:\"newProduct\",quantity:123})"));

FeedOptions newOptions =
FeedOptions.builder().cursor(lastPageCursor).pageSize(2)
.build();

FeedPage<Product> newPageFuture =
client.poll(source, newOptions, Product.class).join();

List<FaunaEvent<Product>> newEvents = newPageFuture.getEvents();

assertEquals(1, newEvents.size());
assertEquals("newProduct", newEvents.get(0).getData().get().getName());
assertEquals(123, newEvents.get(0).getData().get().getQuantity());
}

@Test
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/com/fauna/perf/PerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ private static Stream<Arguments> getTestData() throws IOException {
}

@BeforeAll
public static void setup() {
public static void setup() throws IllegalArgumentException, InterruptedException, ExecutionException {
client = Fauna.client();

// Throw away results of initial query used just for establishing connection
client.asyncQuery(fql("null")).get();
}

@AfterAll
Expand Down

0 comments on commit 7d1e340

Please sign in to comment.