Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make CI green #3114

Merged
merged 25 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2e568a9
use build tags on integration tests and run in groups as precursor to…
ramin Jan 15, 2024
caca981
updated filename
ramin Jan 15, 2024
083adb4
lint, imports
ramin Jan 15, 2024
c76b2dd
don't overkill with matrix just yet
ramin Jan 15, 2024
37d6398
remove concurrency control that accidentally cancels overall go-ci
ramin Jan 15, 2024
4da5a3c
use correct go input
ramin Jan 15, 2024
4125c72
organize helpers
ramin Jan 15, 2024
8a0ddda
disable race in a few places
ramin Jan 15, 2024
f7ff2a2
segment race tests
ramin Jan 15, 2024
6a58599
show tags in text output
ramin Jan 15, 2024
a33d67f
naming improvements
ramin Jan 15, 2024
771b556
skip some reconstruction
ramin Jan 15, 2024
1420717
run sync tests
ramin Jan 17, 2024
f9fef32
split race into own unit test execution becuase of racey macos-latest…
ramin Jan 17, 2024
ef5b0ce
renaming
ramin Jan 17, 2024
d1e745f
remove test branch
ramin Jan 17, 2024
aaa5488
add back branch to trigger a few times
ramin Jan 18, 2024
80a7388
Revert "add back branch to trigger a few times"
ramin Jan 18, 2024
a7a2c01
Merge branch 'main' into ci/ramin/integration-tests
ramin Jan 18, 2024
3b0e728
use latest of TestListenerWithNonEmptyBlocks
ramin Jan 18, 2024
d63a571
no race on discovery tests
ramin Jan 18, 2024
1cdd7ca
merge main
ramin Jan 19, 2024
7a6f797
find another that flakes intermittently on race (potentially)
ramin Jan 19, 2024
ef672e2
Merge branch 'main' into ci/ramin/integration-tests
ramin Jan 22, 2024
2b88bdb
Merge branch 'main' into ci/ramin/integration-tests
ramin Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ concurrency:

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.debug.outputs.debug }}
Expand Down Expand Up @@ -104,11 +105,10 @@ jobs:
file: ./coverage.txt
name: coverage-${{ matrix.os }}

unit_race_test:
unit_test_race:
needs: [lint, go_mod_tidy_check]
name: Run Unit Tests with Race Detector
name: Unit Tests with Race Detector (ubuntu-latest)
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v4
Expand All @@ -119,24 +119,11 @@ jobs:
go-version: ${{ inputs.go-version }}

- name: execute test run
run: make test-unit-race
run: make test-unit-race ENABLE_VERBOSE=${{ needs.setup.outputs.debug }}

integration_test:
name: Integration Tests
needs: [lint, go_mod_tidy_check]
name: Run Integration Tests
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: Integration Tests
run: make test-integration

- name: Integration Tests with Race Detector
run: make test-integration-race
uses: ./.github/workflows/integration-tests.yml
with:
go-version: ${{ inputs.go-version }}
115 changes: 115 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Integration Tests

on:
workflow_call:
inputs:
go-version:
description: 'Go version'
required: true
type: string

jobs:
api_tests:
name: Integration Tests API
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run API tests
run: make test-integration TAGS=api

blob_tests:
name: Integration Tests Blob
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run blob tests
run: make test-integration TAGS=blob

fraud_tests:
name: Integration Tests Fraud
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run fraud tests
run: make test-integration TAGS=fraud

nd_tests:
name: Integration Tests ND
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run nd tests
run: make test-integration TAGS=nd

p2p_tests:
name: Integration Tests p2p
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run p2p tests
run: make test-integration TAGS=p2p

reconstruction_tests:
name: Integration Tests Reconstruction
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run reconstruction tests
run: make test-integration SHORT=true TAGS=reconstruction

sync_tests:
name: Integration Tests Sync
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run sync tests
run: make test-integration SHORT=true TAGS=sync
27 changes: 12 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PROJECTNAME=$(shell basename "$(PWD)")
DIR_FULLPATH=$(shell pwd)
versioningPath := "github.com/celestiaorg/celestia-node/nodebuilder/node"
LDFLAGS=-ldflags="-X '$(versioningPath).buildTime=$(shell date)' -X '$(versioningPath).lastCommit=$(shell git rev-parse HEAD)' -X '$(versioningPath).semanticVersion=$(shell git describe --tags --dirty=-dev 2>/dev/null || git rev-parse --abbrev-ref HEAD)'"
TAGS=integration
SHORT=
ifeq (${PREFIX},)
PREFIX := /usr/local
endif
Expand All @@ -13,6 +15,11 @@ else
VERBOSE =
LOG_AND_FILTER =
endif
ifeq ($(SHORT),true)
INTEGRATION_RUN_LENGTH = -short
else
INTEGRATION_RUN_LENGTH =
endif
## help: Get more info on make commands.
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
Expand Down Expand Up @@ -118,29 +125,21 @@ test-unit:
## test-unit-race: Running unit tests with data race detector
test-unit-race:
@echo "--> Running unit tests with data race detector"
@go test -race `go list ./... | grep -v nodebuilder/tests`
@go test $(VERBOSE) -race -covermode=atomic -coverprofile=coverage.txt `go list ./... | grep -v nodebuilder/tests` $(LOG_AND_FILTER)
.PHONY: test-unit-race

## test-integration: Running /integration tests located in nodebuilder/tests
test-integration:
@echo "--> Running integrations tests"
@go test ./nodebuilder/tests
@echo "--> Running integrations tests $(VERBOSE) -tags=$(TAGS) $(INTEGRATION_RUN_LENGTH)"
@go test $(VERBOSE) -tags=$(TAGS) $(INTEGRATION_RUN_LENGTH) ./nodebuilder/tests
.PHONY: test-integration

## test-integration-race: Running integration tests with data race detector located in node/tests
test-integration-race:
@echo "--> Running integration tests with data race detector"
@go test -race ./nodebuilder/tests
@echo "--> Running integration tests with data race detector -tags=$(TAGS)"
@go test -race -tags=$(TAGS) ./nodebuilder/tests
.PHONY: test-integration-race

## test: Running both unit and integrations tests
test:
@echo "--> Running all tests without data race detector"
@go test ./...
@echo "--> Running all tests with data race detector"
@go test -race ./...
.PHONY: test

## benchmark: Running all benchmarks
benchmark:
@echo "--> Running benchmarks"
Expand All @@ -164,7 +163,6 @@ pb-gen:
done;
.PHONY: pb-gen


## openrpc-gen: Generate OpenRPC spec for Celestia-Node's RPC api
openrpc-gen:
@echo "--> Generating OpenRPC spec"
Expand Down Expand Up @@ -221,7 +219,6 @@ goreleaser-release:
.PHONY: goreleaser-release

# Copied from https://github.com/dgraph-io/badger/blob/main/Makefile

USER_ID = $(shell id -u)
HAS_JEMALLOC = $(shell test -f /usr/local/lib/libjemalloc.a && echo "jemalloc")
JEMALLOC_URL = "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2"
Expand Down
55 changes: 55 additions & 0 deletions core/fetcher_no_race_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//go:build !race

package core

import (
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/types"
)

// TestBlockFetcherHeaderValues tests that both the Commit and ValidatorSet
// endpoints are working as intended.
func TestBlockFetcherHeaderValues(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
t.Cleanup(cancel)

client := StartTestNode(t).Client
fetcher := NewBlockFetcher(client)

// generate some blocks
newBlockChan, err := fetcher.SubscribeNewBlockEvent(ctx)
require.NoError(t, err)
// read once from channel to generate next block
var h int64
select {
case evt := <-newBlockChan:
h = evt.Header.Height
case <-ctx.Done():
require.NoError(t, ctx.Err())
}
// get Commit from current height
commit, err := fetcher.Commit(ctx, &h)
require.NoError(t, err)
// get ValidatorSet from current height
valSet, err := fetcher.ValidatorSet(ctx, &h)
require.NoError(t, err)
// get next block
var nextBlock types.EventDataSignedBlock
select {
case nextBlock = <-newBlockChan:
case <-ctx.Done():
require.NoError(t, ctx.Err())
}
// compare LastCommit from next block to Commit from first block height
assert.Equal(t, nextBlock.Header.LastCommitHash, commit.Hash())
assert.Equal(t, nextBlock.Header.Height, commit.Height+1)
// compare ValidatorSet hash to the ValidatorsHash from first block height
hexBytes := valSet.Hash()
assert.Equal(t, nextBlock.ValidatorSet.Hash(), hexBytes)
require.NoError(t, fetcher.UnsubscribeNewBlockEvent(ctx))
}
43 changes: 0 additions & 43 deletions core/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/types"
)

func TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent(t *testing.T) {
Expand Down Expand Up @@ -38,45 +37,3 @@ func TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent(t *testing.T) {
}
require.NoError(t, fetcher.UnsubscribeNewBlockEvent(ctx))
}

// TestBlockFetcherHeaderValues tests that both the Commit and ValidatorSet
// endpoints are working as intended.
func TestBlockFetcherHeaderValues(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
t.Cleanup(cancel)

client := StartTestNode(t).Client
fetcher := NewBlockFetcher(client)

// generate some blocks
newBlockChan, err := fetcher.SubscribeNewBlockEvent(ctx)
require.NoError(t, err)
// read once from channel to generate next block
var h int64
select {
case evt := <-newBlockChan:
h = evt.Header.Height
case <-ctx.Done():
require.NoError(t, ctx.Err())
}
// get Commit from current height
commit, err := fetcher.Commit(ctx, &h)
require.NoError(t, err)
// get ValidatorSet from current height
valSet, err := fetcher.ValidatorSet(ctx, &h)
require.NoError(t, err)
// get next block
var nextBlock types.EventDataSignedBlock
select {
case nextBlock = <-newBlockChan:
case <-ctx.Done():
require.NoError(t, ctx.Err())
}
// compare LastCommit from next block to Commit from first block height
assert.Equal(t, nextBlock.Header.LastCommitHash, commit.Hash())
assert.Equal(t, nextBlock.Header.Height, commit.Height+1)
// compare ValidatorSet hash to the ValidatorsHash from first block height
hexBytes := valSet.Hash()
assert.Equal(t, nextBlock.ValidatorSet.Hash(), hexBytes)
require.NoError(t, fetcher.UnsubscribeNewBlockEvent(ctx))
}
Loading
Loading