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

end-to-end tests: refactor and fix flaky tests #2470

Merged
merged 47 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
aaf932f
chore(end-to-end): make `DecodeRPC` not test aware
qdm12 Mar 15, 2022
565330a
chore(end-to-end): make RPC helpers not test aware
qdm12 Mar 14, 2022
001e989
chore(end-to-end): `waitForNode` context based function
qdm12 Mar 15, 2022
1890624
chore(end-to-end); use `t.TempDir()` for base paths
qdm12 Mar 30, 2022
aa1668a
chore(end-to-end): `GenerateGenesisAuths`
qdm12 Mar 30, 2022
6ec6b70
chore(end-to-end): remove global variables `GenesisDefault` and `Gene…
qdm12 Mar 14, 2022
fff9b1b
chore(end-to-end): remove global framework variable
qdm12 Mar 30, 2022
c7e718d
chore(end-to-end): remove global configuration variables
qdm12 Mar 22, 2022
9d96dd0
chore(end-to-end): remove global variable `GenesisTwoAuthsSecondaryVR…
qdm12 Mar 23, 2022
dc6952c
chore(end-to-end): inline RPC method strings
qdm12 Mar 30, 2022
440d36f
chore(end-to-end): remove `HOSTNAME` variable
qdm12 Mar 30, 2022
f174620
chore(end-to-end): remove `DecodeRPC_NT`
qdm12 Mar 30, 2022
fb73229
chore(end-to-end): split `tests/utils` package
qdm12 Mar 24, 2022
ab3e4e2
chore(end-to-end): rework start and stop of nodes
qdm12 Mar 30, 2022
0ffec90
chore(end-to-end): refactor `getResponse`
qdm12 Mar 30, 2022
bab313d
chore(end-to-end): remove global variables in stress tests
qdm12 Mar 31, 2022
37482c6
chore(end-to-end): `retry.UntilNoError` function
qdm12 Apr 4, 2022
fcad087
chore(end-to-end): refactor `TestSystemRPC`
qdm12 Apr 4, 2022
4cd02d7
fix(end-to-end): `TestSync_SingleBlockProducer` not flaky
qdm12 Apr 6, 2022
65f0bda
chore(end-to-end): Faster `TestAuthorSubmitExtrinsic`
qdm12 Apr 7, 2022
e19112a
chore(end-to-end): only use Toml configuration
qdm12 Apr 22, 2022
85b2bdb
chore(end-to-end): wrap runtime error for init
qdm12 Apr 22, 2022
d6f16d8
Do not assert best block number and hash for now
qdm12 Apr 27, 2022
204ffb7
chore(dot): remove `exportConfig` and `TestExportConfig`
qdm12 May 2, 2022
aa0ab13
chore(dot): remove `ExportTomlConfig` and its test
qdm12 May 2, 2022
5b1a38c
chore(e2e): install npm dependencies from Go code
qdm12 May 2, 2022
ca61882
chore(tests/rpc): remove 1s sleep
qdm12 May 2, 2022
5ea98fe
chore(tests/stress): replace `compareFinalizedHeadsWithRetry` with `r…
qdm12 May 2, 2022
501cbb9
fix(tests/utils/node): reset log before starting command
qdm12 May 2, 2022
33b68f5
chore(tests): getters without `Get` prefix
qdm12 May 2, 2022
9f731fa
chore(tests/utils/retry): shared common code
qdm12 May 2, 2022
a1708ee
chore(tests): remove `websocket` package
qdm12 May 2, 2022
47b2f98
chore(tests/utils/rpc): change error wrapping to `malformed block hea…
qdm12 May 2, 2022
d85fc1e
chore(tests/utils/rpc): fix the bloody body
qdm12 May 2, 2022
20ae819
Return runtime error channels instead of injecting them
qdm12 Jun 2, 2022
a298950
Simplify `MakeNodes` to use `New` for each node
qdm12 Jun 3, 2022
f360f5a
Init in parallel for all code paths
qdm12 Jun 3, 2022
cd04c44
Update tests/utils/runtime/errors.go
qdm12 Jun 8, 2022
3d82658
Move errors.go from `runtime` to `node` package
qdm12 Jun 8, 2022
6bbb186
Unexport all `errorsFanIn` types and methods
qdm12 Jun 8, 2022
7bece96
Rename rpc/models.go to rpc/types.go
qdm12 Jun 8, 2022
dffb642
`TestRestartNode`: helper `stopNodes` function
qdm12 Jun 8, 2022
e936970
Do not use reflect
qdm12 Jun 8, 2022
ee48c78
Refactor `TestChainSubscriptionRPC`
qdm12 Jun 9, 2022
f0e0187
Merge stable workflow in rpc workflow
qdm12 Jun 9, 2022
b35877f
Log out configuration file content on runtime error
qdm12 Jun 10, 2022
c1271b2
Restore sleep between launches for stable tests
qdm12 Jun 10, 2022
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
33 changes: 0 additions & 33 deletions .github/workflows/docker-stable.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ test_data
trie_putandget_failed_test_data_*
tmp

tests/utils/config*
tests/utils/genesis*

# node_modules used by polkadot.js/api tests
tests/polkadotjs_test/node_modules
!tests/polkadotjs_test/test/*.wasm
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ RUN wget -qO- https://deb.nodesource.com/setup_14.x | bash - && \
RUN wget -O /usr/local/bin/subkey https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0 && \
chmod +x /usr/local/bin/subkey

# Polkadot JS dependencies
WORKDIR /go/src/github.com/ChainSafe/gossamer/tests/polkadotjs_test
COPY tests/polkadotjs_test/package.json tests/polkadotjs_test/package-lock.json ./
RUN npm install

timwu20 marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /go/src/github.com/ChainSafe/gossamer

# Go dependencies
Expand Down
16 changes: 5 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,26 @@ test:
git lfs pull
go test -short -coverprofile c.out ./... -timeout=30m

## it-stable: Runs Integration Tests Stable mode
it-stable:
@echo " > \033[32mRunning Integration Tests...\033[0m "
@chmod +x scripts/integration-test-all.sh
./scripts/integration-test-all.sh -q 3 -s 10

## it-stress: Runs Integration Tests stress mode
it-stress: build
@echo " > \033[32mRunning stress tests...\033[0m "
HOSTNAME=0.0.0.0 MODE=stress go test ./tests/stress/... -timeout=15m -v -short -run TestSync_
MODE=stress go test ./tests/stress/... -timeout=15m -v -short -run TestSync_

it-grandpa: build
@echo " > \033[32mRunning GRANDPA stress tests...\033[0m "
HOSTNAME=0.0.0.0 MODE=stress go test ./tests/stress/... -timeout=12m -v -short -run TestStress_Grandpa_
MODE=stress go test ./tests/stress/... -timeout=12m -v -short -run TestStress_Grandpa_

it-rpc: build
@echo " > \033[32mRunning Integration Tests RPC Specs mode...\033[0m "
HOSTNAME=0.0.0.0 MODE=rpc go test ./tests/rpc/... -timeout=10m -v
MODE=rpc go test ./tests/rpc/... -timeout=10m -v

it-sync: build
@echo " > \033[32mRunning Integration Tests sync mode...\033[0m "
HOSTNAME=0.0.0.0 MODE=sync go test ./tests/sync/... -timeout=5m -v
MODE=sync go test ./tests/sync/... -timeout=5m -v

it-polkadotjs: build
@echo " > \033[32mRunning Integration Tests polkadot.js/api mode...\033[0m "
HOSTNAME=0.0.0.0 MODE=polkadot go test ./tests/polkadotjs_test/... -timeout=5m -v
MODE=polkadot go test ./tests/polkadotjs_test/... -timeout=5m -v

## test: Runs `go test -race` on project test files.
test-state-race:
Expand Down
7 changes: 0 additions & 7 deletions docs/docs/testing-and-debugging/test-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ Proceed to open `cover.html` in your preferred browser.
### Gossamer Integration Tests

Running Gossamer's integration tests with the below commands will build a Gossamer binary, install required dependencies, and then proceeds to run the provided set of tests. Integration tests can also be run within a docker container.


To run Gossamer integration tests in **stable** mode run the following command:

```
make it-stable
```

To run Gossamer integration tests in **stress** mode run the following command:

Expand Down
28 changes: 0 additions & 28 deletions dot/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,9 @@ import (
"os"
"strings"

ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/cosmos/go-bip39"
"github.com/naoina/toml"
)

// exportConfig exports a dot configuration to a toml configuration file
func exportConfig(cfg *Config, fp string) {
raw, err := toml.Marshal(*cfg)
if err != nil {
logger.Errorf("failed to marshal configuration: %s", err)
os.Exit(1)
}
if err := os.WriteFile(fp, raw, 0600); err != nil {
logger.Errorf("failed to write file: %s", err)
os.Exit(1)
}
}

// ExportTomlConfig exports a dot configuration to a toml configuration file
func ExportTomlConfig(cfg *ctoml.Config, fp string) {
raw, err := toml.Marshal(*cfg)
if err != nil {
logger.Errorf("failed to marshal configuration: %s", err)
os.Exit(1)
}
if err := os.WriteFile(fp, raw, 0600); err != nil {
logger.Errorf("failed to write file: %s", err)
os.Exit(1)
}
}

// CreateJSONRawFile will generate a JSON genesis file with raw storage
func CreateJSONRawFile(bs *BuildSpec, fp string) {
data, err := bs.ToJSONRaw()
Expand Down
149 changes: 0 additions & 149 deletions dot/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"path/filepath"
"testing"

ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/genesis"
Expand Down Expand Up @@ -80,154 +79,6 @@ func TestCreateJSONRawFile(t *testing.T) {
}
}

func TestExportConfig(t *testing.T) {
filepath := filepath.Join(t.TempDir(), "test.json")
type args struct {
cfg *Config
fp string
}
tests := []struct {
name string
args args
want *os.File
wantedContent string
}{
{
name: "working example",
args: args{
cfg: &Config{},
fp: filepath,
},
want: &os.File{},
wantedContent: `[global]
name = ""
id = ""
base_path = ""
log_lvl = 0
publish_metrics = false
metrics_address = ""
no_telemetry = false
telemetry_urls = []
retain_blocks = 0
pruning = ""
[log]
core_lvl = 0
digest_lvl = 0
sync_lvl = 0
network_lvl = 0
rpc_lvl = 0
state_lvl = 0
runtime_lvl = 0
block_producer_lvl = 0
finality_gadget_lvl = 0
[init]
genesis = ""
[account]
key = ""
unlock = ""
[core]
roles = 0
babe_authority = false
b_a_b_e_lead = false
grandpa_authority = false
wasm_interpreter = ""
grandpa_interval = 0
[network]
port = 0
bootnodes = []
protocol_id = ""
no_bootstrap = false
no_m_dns = false
min_peers = 0
max_peers = 0
persistent_peers = []
discovery_interval = 0
public_ip = ""
public_dns = ""
[rpc]
enabled = false
external = false
unsafe = false
unsafe_external = false
port = 0
host = ""
modules = []
w_s_port = 0
w_s = false
w_s_external = false
w_s_unsafe = false
w_s_unsafe_external = false
[system]
system_name = ""
system_version = ""
[state]
rewind = 0
[pprof]
enabled = false
[pprof.settings]
listening_address = ""
block_profile_rate = 0
mutex_profile_rate = 0
`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
exportConfig(tt.args.cfg, tt.args.fp)

content, err := ioutil.ReadFile(tt.args.fp)
require.NoError(t, err)
require.Equal(t, tt.wantedContent, string(content))

})
}
}

func TestExportTomlConfig(t *testing.T) {
filepath := filepath.Join(t.TempDir(), "test.json")
type args struct {
cfg *ctoml.Config
fp string
}
tests := []struct {
name string
args args
wantedContent string
}{
{
name: "working example",
args: args{
cfg: &ctoml.Config{},
fp: filepath,
},
wantedContent: `[core]
babe-authority = false
grandpa-authority = false
`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ExportTomlConfig(tt.args.cfg, tt.args.fp)

content, err := ioutil.ReadFile(tt.args.fp)
require.NoError(t, err)
require.Equal(t, tt.wantedContent, string(content))

})
}
}

func TestNewTestConfig(t *testing.T) {
basePath := t.TempDir()
incBasePath := basePath[:len(basePath)-1] + "2"
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func GetDevGenesisPath(t *testing.T) string {
return filepath.Join(GetProjectRootPathTest(t), "./chain/dev/genesis.json")
}

// GetDevGenesisSpecPathTest gets the dev genesis spec path
func GetDevGenesisSpecPathTest(t *testing.T) string {
return filepath.Join(GetProjectRootPathTest(t), "./chain/dev/genesis-spec.json")
}

// GetGssmrGenesisPath gets the gssmr genesis path
// and returns an error if it cannot find it.
func GetGssmrGenesisPath() (path string, err error) {
Expand Down
Loading