Skip to content

Commit

Permalink
Java: add CI to run modules (valkey-io#2388)
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Oct 7, 2024
1 parent 615034f commit abc8666
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 4 deletions.
46 changes: 42 additions & 4 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }}
host:
- {
OS: ubuntu,
RUNNER: ubuntu-latest,
TARGET: x86_64-unknown-linux-gnu
}
OS: ubuntu,
RUNNER: ubuntu-latest,
TARGET: x86_64-unknown-linux-gnu,
}
# - {
# OS: macos,
# RUNNER: macos-latest,
Expand Down Expand Up @@ -195,3 +195,41 @@ jobs:
with:
cargo-toml-folder: ./java
name: lint java rust

test-modules:
if: github.repository_owner == 'valkey-io'
name: Running Module Tests
runs-on: [self-hosted, linux, ARM64]
timeout-minutes: 15
steps:
- name: Setup self-hosted runner access
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/valkey-glide

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17

- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
with:
version: "26.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test java wrapper
working-directory: java
run: ./gradlew :integTest:modulesTest -Dcluster-endpoints=${{ secrets.MEMDB_MODULES_ENDPOINT }} -Dtls=true

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-modules
path: |
java/integTest/build/reports/**
5 changes: 5 additions & 0 deletions java/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ You can combine this with test filter as well:
./gradlew :integTest:test -Dcluster-endpoints=localhost:7000 -Dstandalone-endpoints=localhost:6379 --tests 'TransactionTests' -Dtls=true
```
To run server modules test (it doesn't start servers):
```bash
./gradlew :integTest:modulesTest -Dcluster-endpoints=localhost:7000 -Dtls=true
```

### Generate files
To (re)generate protobuf code, use the following command:

Expand Down
16 changes: 16 additions & 0 deletions java/integTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,19 @@ tasks.withType(Test) {
logger.quiet "${desc.className}.${desc.name}: ${result.resultType} ${(result.getEndTime() - result.getStartTime())/1000}s"
}
}

test {
filter {
excludeTestsMatching 'glide.modules.*'
}
}

tasks.register('modulesTest', Test) {
doFirst {
clusterHosts = System.getProperty("cluster-endpoints")
}

filter {
includeTestsMatching 'glide.modules.*'
}
}
23 changes: 23 additions & 0 deletions java/integTest/src/test/java/glide/modules/JsonTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.modules;

import static glide.TestUtilities.commonClusterClientConfig;
import static glide.api.models.configuration.RequestRoutingConfiguration.SimpleSingleNodeRoute.RANDOM;
import static org.junit.jupiter.api.Assertions.assertTrue;

import glide.api.GlideClusterClient;
import glide.api.models.commands.InfoOptions.Section;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;

public class JsonTests {
@Test
@SneakyThrows
public void check_module_loaded() {
var client =
GlideClusterClient.createClient(commonClusterClientConfig().requestTimeout(5000).build())
.get();
var info = client.info(new Section[] {Section.MODULES}, RANDOM).get().getSingleValue();
assertTrue(info.contains("# json_core_metrics"));
}
}
24 changes: 24 additions & 0 deletions java/integTest/src/test/java/glide/modules/VectorSearchTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.modules;

import static glide.TestUtilities.commonClusterClientConfig;
import static glide.api.models.configuration.RequestRoutingConfiguration.SimpleSingleNodeRoute.RANDOM;
import static org.junit.jupiter.api.Assertions.assertTrue;

import glide.api.GlideClusterClient;
import glide.api.models.commands.InfoOptions.Section;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;

public class VectorSearchTests {

@Test
@SneakyThrows
public void check_module_loaded() {
var client =
GlideClusterClient.createClient(commonClusterClientConfig().requestTimeout(5000).build())
.get();
var info = client.info(new Section[] {Section.MODULES}, RANDOM).get().getSingleValue();
assertTrue(info.contains("# search_index_stats"));
}
}

0 comments on commit abc8666

Please sign in to comment.