Skip to content

Commit

Permalink
go: modules CI (valkey-io#2801)
Browse files Browse the repository at this point in the history
* Modules CI

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Dec 19, 2024
1 parent a8040a5 commit b4231b0
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 73 deletions.
51 changes: 35 additions & 16 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,11 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
engine-version: ${{ matrix.engine.version }}

- name: Install tools for Go ${{ matrix.go }}
working-directory: ./go
run: make install-tools-go${{ matrix.go }}

- name: Set LD_LIBRARY_PATH
if: ${{ matrix.os == 'ubuntu-latest' }}
run: echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/go/target/release/deps/" >> $GITHUB_ENV

- name: Build client
working-directory: ./go
run: make build

- name: Run tests
working-directory: ./go
run: make test
- name: Install & build & test
working-directory: go
run: |
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/go/target/release/deps/
make install-tools-go${{ matrix.go }} build unit-test integ-test
- uses: ./.github/workflows/test-benchmark
with:
Expand Down Expand Up @@ -216,7 +206,7 @@ jobs:
working-directory: go
run: |
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/go/target/release/deps/
make install-tools-go${{ matrix.go }} build test
make install-tools-go${{ matrix.go }} build unit-test integ-test
- name: Upload test reports
if: always()
Expand All @@ -227,3 +217,32 @@ jobs:
path: |
utils/clusters/**
benchmarks/results/**
test-modules:
if: (github.repository_owner == 'valkey-io' && github.event_name == 'workflow_dispatch') || github.event.pull_request.head.repo.owner.login == 'valkey-io'
environment: AWS_ACTIONS
name: Modules 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

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20.0"
cache-dependency-path: go/go.sum

- name: Build and test
working-directory: ./go
run: |
make install-tools-go1.20.0
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/go/target/release/deps/
make build
make modules-test cluster-endpoints=${{ secrets.MEMDB_MODULES_ENDPOINT }} tls=true
# TODO:
# Upload test reports
2 changes: 1 addition & 1 deletion go/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = ["Valkey GLIDE Maintainers"]
crate-type = ["cdylib"]

[dependencies]
redis = { path = "../glide-core/redis-rs/redis", features = ["aio", "tokio-comp", "tls", "tokio-native-tls-comp", "tls-rustls-insecure"] }
redis = { path = "../glide-core/redis-rs/redis", features = ["aio", "tokio-comp", "connection-manager", "tokio-rustls-comp"] }
glide-core = { path = "../glide-core", features = ["socket-layer"] }
tokio = { version = "^1", features = ["rt", "macros", "rt-multi-thread", "time"] }
protobuf = { version = "3.3.0", features = [] }
Expand Down
23 changes: 14 additions & 9 deletions go/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,35 @@ Before starting this step, make sure you've installed all software requirements.

### Test

To run tests, use the following command:
To run tests, use the benefit on makefile. To run unit tests, run the following command:

```bash
go test -race ./...
make unit-test
```

For more detailed test output, add the `-v` flag:
To run integration tests, run:

```bash
go test -race ./... -v
make integ-test
```

To execute a specific test, include `-run <test_name>`. For example:
To run modules tests, run:

```bash
go test -race ./... -run TestConnectionRequestProtobufGeneration_allFieldsSet -v
make modules-test
```

### Submodules
To execute a specific test, include `test-filter=<test_name>`. For example:

After pulling new changes, ensure that you update the submodules by running the following command:
```bash
make unit-test test-filter=TestConnectionRequestProtobufGeneration_allFieldsSet
```

Integration and modules tests accept `standalone-endpoints`, `cluster-endpoints` and `tls` parameters to run tests on existing servers.
By default, those test suite start standalone and cluster servers without TLS and stop them at the end.

```bash
git submodule update --init --recursive
make integ-test standalone-endpoints=localhost:6379 cluster-endpoints=localhost:7000 tls=true
```

### Generate protobuf files
Expand Down
22 changes: 20 additions & 2 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,31 @@ format:
gofumpt -w .
golines -w --shorten-comments -m 127 .

test:
# unit tests - skip complete IT suite (including MT)
unit-test:
LD_LIBRARY_PATH=$(shell find . -name libglide_rs.so|grep -w release|tail -1|xargs dirname|xargs readlink -f):${LD_LIBRARY_PATH} \
go test -v -race ./...
go test -v -race ./... -skip TestGlideTestSuite $(if $(test-filter), -run $(test-filter))

# integration tests - run subtask with skipping modules tests
integ-test: export TEST_FILTER = -skip TestGlideTestSuite/TestModule $(if $(test-filter), -run $(test-filter))
integ-test: __it

# modules tests - run substask with default filter
modules-test: export TEST_FILTER = $(if $(test-filter), -run $(test-filter), -run TestGlideTestSuite/TestModule)
modules-test: __it

__it:
LD_LIBRARY_PATH=$(shell find . -name libglide_rs.so|grep -w release|tail -1|xargs dirname|xargs readlink -f):${LD_LIBRARY_PATH} \
go test -v -race ./integTest/... \
$(TEST_FILTER) \
$(if $(filter true, $(tls)), --tls,) \
$(if $(standalone-endpoints), --standalone-endpoints=$(standalone-endpoints)) \
$(if $(cluster-endpoints), --cluster-endpoints=$(cluster-endpoints))

# Note: this task is no longer run by CI because:
# - build failures that occur while running the task can be hidden by the task; CI still reports success in these scenarios.
# - there is not a good way to both generate a test report and log the test outcomes to GH actions.
# TODO: fix this and include -run/-skip flags
test-and-report:
mkdir -p reports
go test -v -race ./... -json | go-test-report -o reports/test-report.html
8 changes: 4 additions & 4 deletions go/integTest/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func (suite *GlideTestSuite) TestStandaloneConnect() {
config := api.NewGlideClientConfiguration().
WithAddress(&api.NodeAddress{Port: suite.standalonePorts[0]})
WithAddress(&suite.standaloneHosts[0])
client, err := api.NewGlideClient(config)

assert.Nil(suite.T(), err)
Expand All @@ -20,8 +20,8 @@ func (suite *GlideTestSuite) TestStandaloneConnect() {

func (suite *GlideTestSuite) TestClusterConnect() {
config := api.NewGlideClusterClientConfiguration()
for _, port := range suite.clusterPorts {
config.WithAddress(&api.NodeAddress{Port: port})
for _, host := range suite.clusterHosts {
config.WithAddress(&host)
}

client, err := api.NewGlideClusterClient(config)
Expand All @@ -34,7 +34,7 @@ func (suite *GlideTestSuite) TestClusterConnect() {

func (suite *GlideTestSuite) TestClusterConnect_singlePort() {
config := api.NewGlideClusterClientConfiguration().
WithAddress(&api.NodeAddress{Port: suite.clusterPorts[0]})
WithAddress(&suite.clusterHosts[0])

client, err := api.NewGlideClusterClient(config)

Expand Down
Loading

0 comments on commit b4231b0

Please sign in to comment.