Skip to content

Commit

Permalink
tests: add smoke tests, move tests to tests/e2e (#171)
Browse files Browse the repository at this point in the history
* add smoke tests, move tests to tests/e2e

* add runs-on

* fix e2e tests, fix go.mod

* run smoke tests every 2 hours, prepare for merge

* remove debug runs for smoke tests

* readd debug, add timeout to starship-action

* remove debug from smoke-test
  • Loading branch information
Anmol1696 committed Aug 11, 2023
1 parent ea77dce commit eaac2f8
Show file tree
Hide file tree
Showing 24 changed files with 291 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/actions/e2e-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ runs:
--cache_test_results=no \
--test_output=all \
--test_env=TEST_CONFIG_FILE=${{ inputs.config-file }} \
//tests:tests
//tests/e2e:tests
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
max-parallel: 1

env:
CONFIG_FILE: "tests/configs/${{ matrix.config-file }}"
CONFIG_FILE: "tests/e2e/configs/${{ matrix.config-file }}"

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
max-parallel: 1

env:
CONFIG_FILE: "tests/configs/${{ matrix.config-file }}"
CONFIG_FILE: "tests/e2e/configs/${{ matrix.config-file }}"

steps:
- name: Get PR branch
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
max-parallel: 3

env:
CONFIG_FILE: "tests/configs/${{ matrix.config-file }}"
CONFIG_FILE: "tests/e2e/configs/${{ matrix.config-file }}"

steps:
- name: Checkout
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
--cache_test_results=no \
--test_output=all \
--test_env=TEST_CONFIG_FILE=${{ env.CONFIG_FILE }} \
//tests:tests
//tests/e2e:tests
# todo: change this to be post step of the action
- name: Cleanup cluster
Expand Down
118 changes: 118 additions & 0 deletions .github/workflows/smoke-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Smoke tests

on:
# Run every 2 hours
schedule:
- cron: '0 */2 * * *'
workflow_dispatch: {}

jobs:
smoke-test-1:
runs-on: ubuntu-latest

strategy:
matrix:
config-file: [ "one-chain.yaml", "osmojs.yaml", "simapp.yaml", "multi-validator.yaml" ]
fail-fast: false
max-parallel: 4

env:
CONFIG_FILE: "tests/smoke/ci/${{ matrix.config-file }}"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Test infra
id: starship-action
uses: cosmology-tech/starship-action@0.2.14
with:
values: ${{ env.CONFIG_FILE }}
port-forward: true
version: 0.0.0
chart: ./charts/devnet
timeout: 10m

# todo: change this to be post step of the action
- name: Cleanup cluster
if: always()
run: |
helm delete $DEVNET_NAME --debug --namespace $DEVNET_NAMESPACE --wait || true
kubectl delete namespace $DEVNET_NAMESPACE --wait=true || true
env:
DEVNET_NAME: ${{ steps.starship-action.outputs.name }}
DEVNET_NAMESPACE: ${{ steps.starship-action.outputs.namespace }}

smoke-test-2:
needs: [smoke-test-1]
runs-on: ubuntu-latest

strategy:
matrix:
config-file: [ "one-chain.yaml", "osmojs.yaml", "simapp.yaml", "multi-validator.yaml" ]
fail-fast: true
max-parallel: 4

env:
CONFIG_FILE: "tests/smoke/ci/${{ matrix.config-file }}"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Test infra
id: starship-action
uses: cosmology-tech/starship-action@0.2.14
with:
values: ${{ env.CONFIG_FILE }}
port-forward: true
version: 0.0.0
chart: ./charts/devnet
timeout: 10m

# todo: change this to be post step of the action
- name: Cleanup cluster
if: always()
run: |
helm delete $DEVNET_NAME --debug --namespace $DEVNET_NAMESPACE --wait || true
kubectl delete namespace $DEVNET_NAMESPACE --wait=true || true
env:
DEVNET_NAME: ${{ steps.starship-action.outputs.name }}
DEVNET_NAMESPACE: ${{ steps.starship-action.outputs.namespace }}

smoke-test-3:
needs: [smoke-test-2]
runs-on: ubuntu-latest

strategy:
matrix:
config-file: [ "one-chain.yaml", "osmojs.yaml", "simapp.yaml", "multi-validator.yaml" ]
fail-fast: true
max-parallel: 4

env:
CONFIG_FILE: "tests/smoke/ci/${{ matrix.config-file }}"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Test infra
id: starship-action
uses: cosmology-tech/starship-action@0.2.14
with:
values: ${{ env.CONFIG_FILE }}
port-forward: true
version: 0.0.0
chart: ./charts/devnet
timeout: 10m

# todo: change this to be post step of the action
- name: Cleanup cluster
if: always()
run: |
helm delete $DEVNET_NAME --debug --namespace $DEVNET_NAMESPACE --wait || true
kubectl delete namespace $DEVNET_NAMESPACE --wait=true || true
env:
DEVNET_NAME: ${{ steps.starship-action.outputs.name }}
DEVNET_NAMESPACE: ${{ steps.starship-action.outputs.namespace }}
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ use (
./examples/upgrade-test
./exposer
./registry
./tests
./tools
./tests/e2e
)
2 changes: 1 addition & 1 deletion tests/BUILD.bazel → tests/e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "con
go_library(
name = "tests_lib",
srcs = ["config.go"],
importpath = "github.com/cosmology-tech/starship/tests",
importpath = "github.com/cosmology-tech/starship/tests/e2e",
visibility = ["//visibility:public"],
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/config.go → tests/e2e/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package e2e

type Chain struct {
Name string `name:"name" json:"name" yaml:"name"`
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/e2e_test.go → tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package e2e

import (
"fmt"
Expand Down Expand Up @@ -37,7 +37,7 @@ func (s *TestSuite) SetupTest() {
s.T().Log(fmt.Errorf("env var %s not set, using default value", configEnvKey))
configFile = "configs/two-chain.yaml"
}
configFile = strings.Replace(configFile, "tests/", "", -1)
configFile = strings.Replace(configFile, "tests/e2e/", "", -1)
yamlFile, err := os.ReadFile(configFile)
s.Require().NoError(err)
config := &Config{}
Expand Down
2 changes: 1 addition & 1 deletion tests/exposer_test.go → tests/e2e/exposer_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package e2e

import (
"fmt"
Expand Down
8 changes: 4 additions & 4 deletions tests/go.mod → tests/e2e/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/cosmology-tech/starship/tests
module github.com/cosmology-tech/starship/tests/e2e

go 1.19

Expand All @@ -8,6 +8,7 @@ require (
github.com/golang/protobuf v1.5.3
github.com/stretchr/testify v1.8.2
go.uber.org/zap v1.24.0
google.golang.org/protobuf v1.29.1
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -23,11 +24,10 @@ require (
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.29.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

replace (
github.com/cosmology-tech/starship/exposer => ../exposer
github.com/cosmology-tech/starship/registry => ../registry
github.com/cosmology-tech/starship/exposer => ../../exposer
github.com/cosmology-tech/starship/registry => ../../registry
)
8 changes: 8 additions & 0 deletions tests/go.sum → tests/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand All @@ -37,6 +43,7 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 h1:khxVcsk/FhnzxMKOyD+TDGwjbEOpcPuIpmafPGFmhMA=
google.golang.org/genproto v0.0.0-20230320184635-7606e756e683/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s=
Expand All @@ -48,6 +55,7 @@ google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62Uo
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion tests/registry_test.go → tests/e2e/registry_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package e2e

import (
"fmt"
Expand Down
35 changes: 35 additions & 0 deletions tests/smoke/ci/multi-validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
chains:
- name: osmosis-1
type: osmosis
numValidators: 2
ports:
rest: 1313
rpc: 26653
exposer: 38083
resources:
cpu: "0.3"
memory: 600M
faucet:
concurrency: 2
resources:
cpu: "0.1"
memory: "300M"

registry:
enabled: true
ports:
rest: 8081
grpc: 9091
resources:
cpu: "0.1"
memory: 100M

resources:
wait:
cpu: "0.1"
memory: 100M

exposer:
resources:
cpu: "0.1"
memory: 100M
27 changes: 27 additions & 0 deletions tests/smoke/ci/one-chain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
chains:
- name: osmosis-1
type: osmosis
numValidators: 1
ports:
rest: 1313
rpc: 26653
exposer: 38083
resources:
cpu: "0.5"
memory: 500M
faucet:
concurrency: 2

registry:
enabled: true
ports:
rest: 8081
grpc: 9091
resources:
cpu: "0.1"
memory: 100M

resources:
wait:
cpu: "0.1"
memory: 100M
52 changes: 52 additions & 0 deletions tests/smoke/ci/osmojs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
chains:
- name: osmosis-1
type: osmosis
image: pyramation/osmosis:v16.1.0
numValidators: 1
ports:
rest: 1317
rpc: 26657
faucet: 8007
resources:
cpu: "0.2"
memory: "200M"
- name: cosmos-2
type: cosmos
numValidators: 1
ports:
rest: 1313
rpc: 26653
faucet: 8003
resources:
cpu: "0.2"
memory: "200M"

relayers:
- name: osmos-cosmos
type: hermes
replicas: 1
chains:
- osmosis-1
- cosmos-2
resources:
cpu: "0.1"
memory: "100M"

registry:
enabled: true
ports:
rest: 8081
grpc: 9091
resources:
cpu: "0.1"
memory: "100M"

exposer:
resources:
cpu: "0.1"
memory: "100M"

faucet:
resources:
cpu: "0.1"
memory: "100M"
Loading

0 comments on commit eaac2f8

Please sign in to comment.