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

Starship integration #56

Merged
merged 35 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
486c697
Semi working integration of Starship with mesh-security with custom code
Anmol1696 Jul 7, 2023
a3701a1
Semi working full mesh security lifecycle
Anmol1696 Jul 8, 2023
7a9cb35
Update devnet setup for starship multi-node setup
Anmol1696 Jul 8, 2023
078925e
rename denoms to uosmo and ujuno to get seperation of chains
Anmol1696 Jul 9, 2023
deb76ef
Cleanup the tests: update the structure
Anmol1696 Jul 10, 2023
e71cb9e
Fix setup command and update cmd main file
Anmol1696 Jul 13, 2023
802c532
Update devnet information for latest contracts and endpoints
Anmol1696 Jul 14, 2023
2c72b27
update endpoints
Anmol1696 Jul 14, 2023
8a7f670
2 way inital devnet
Anmol1696 Jul 14, 2023
aaedeb0
update new devnet
Anmol1696 Jul 15, 2023
6a10b9e
updated devnet, 2 chain mesh setup working
Anmol1696 Jul 15, 2023
e9e3fb2
add e2e tests of 2 way contract to run in the CI
Anmol1696 Jul 16, 2023
6b41389
run a particular function for test
Anmol1696 Jul 16, 2023
b311939
working model of 2 way contract
Anmol1696 Jul 20, 2023
3f5cecf
Merge remote-tracking branch 'origin/main' into anmol/starship-2-way-…
Anmol1696 Aug 10, 2023
2f313c0
Revert adhoc changes made to mesh-security-sdk for hackathon
Anmol1696 Aug 10, 2023
7bee6fa
revert makefile for demo app
Anmol1696 Aug 10, 2023
ca312d1
move testdata outside for using it with e2e tests and startship tests
Anmol1696 Aug 14, 2023
83c254b
Merge main into branch
Anmol1696 Aug 22, 2023
086be79
update starship yaml files to run with mesh-security-sdk
Anmol1696 Aug 30, 2023
3df8ca4
Merge remote-tracking branch 'origin/main' into anmol/trim-starship-i…
Anmol1696 Aug 31, 2023
8a11acb
working version of starship with meshd
Anmol1696 Aug 31, 2023
4b38473
fix main_test.go and go mod
Anmol1696 Aug 31, 2023
4626a37
fix ci starship config
Anmol1696 Aug 31, 2023
3e23f9d
run starship ci on push to test branch
Anmol1696 Aug 31, 2023
8eac1af
fix typo errors
Anmol1696 Aug 31, 2023
24f4264
fix typos and type errors
Anmol1696 Sep 1, 2023
5d5dd72
add step to perform go mod before setting up the infra
Anmol1696 Sep 1, 2023
ef9cac7
Merge pull request #65 from osmosis-labs/anmol/trim-starship-integration
Anmol1696 Sep 1, 2023
e571715
commit to trigger CI
Anmol1696 Sep 1, 2023
909a74d
add retry of running tests incase of transient errors
Anmol1696 Sep 1, 2023
155cbef
temp disable workflows in the CI
Anmol1696 Sep 1, 2023
9ebf4f5
Add readme, update make commands, add todo to change docker image in …
Anmol1696 Sep 1, 2023
0d61a22
remove ci-debuging for the PR
Anmol1696 Sep 1, 2023
0c6f735
update docker image to use ghcr.io meshd image
Anmol1696 Sep 2, 2023
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
66 changes: 66 additions & 0 deletions .github/workflows/starship-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Starship E2E tests

on:
push:
branches:
- main
pull_request:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure if we want to run this on every PR, takes around 15mins to run the CI

branches:
- main
workflow_dispatch: {}

jobs:
e2e-test:
runs-on: ubuntu-latest
timeout-minutes: 30

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

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.20
id: go

- name: Deps
run: |
cd tests/starship/
go mod tidy

# Starship Infra setup
# - Connects to k8s cluster with kubeconfig (digital ocean)
# - Creates a new namespace based on the name (deleted in next step)
# - Spins up the infra with the given config file
# - Waits till all nodes are running (timeout 30m)
# - Port forward all ports to localhost for next steps to connect
- name: Setup Test infra
id: starship-action
uses: cosmology-tech/starship-action@0.2.15
with:
values: tests/starship/configs/ci.yaml
port-forward: true
version: 0.1.46-rc1

- name: Run Tests
id: run-tests
run: |
cd tests/starship/
make test

- name: Run Tests (retry on failure)
if: steps.run-tests.outcome == 'failure'
run: |
cd tests/starship/
make test

# Starship resource cleanup on cluster
- 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 tests/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestMain(m *testing.M) {
flag.StringVar(&wasmContractPath, "contracts-path", "testdata", "Set path to dir with gzipped wasm contracts")
flag.StringVar(&wasmContractPath, "contracts-path", "../testdata", "Set path to dir with gzipped wasm contracts")
flag.BoolVar(&wasmContractGZipped, "gzipped", true, "Use `.gz` file ending when set")
flag.Parse()

Expand Down
72 changes: 72 additions & 0 deletions tests/starship/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/make -f

BUILD_DIR = ./build

all: test

test:
go test -count=1 -mod=readonly -v -race -run Test2WayContract ./...

build-setup:
cd setup && go build cmd/... -o build/ ./setup

run-setup:
cd setup && go run ./...

build:
CGO_ENABLED=1 go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

build-linux:
CGO_ENABLED=1 GOOS=linux go test -c -mod=readonly -o $(BUILD_DIR)/mesh-security.e2e.test

.PHONY: all build build-linux test

###############################################################################
### Starship Helm Charts ###
###############################################################################
NAME = mesh-security
FILE = configs/local.yaml

HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.1.46-rc1

.PHONY: check
setup-deps:
bash $(CURDIR)/scripts/dev-setup.sh

install:
bash $(CURDIR)/scripts/install.sh --config $(FILE) --version $(HELM_VERSION) --name $(NAME)

debug:
bash $(CURDIR)/scripts/install.sh --config $(FILE) --version $(HELM_VERSION) --name $(NAME) --dry-run

delete:
-helm delete $(NAME)

stop: stop-forward delete

###############################################################################
### Port forward ###
###############################################################################

.PHONY: port-forward
port-forward:
bash $(CURDIR)/scripts/port-forward.sh --config=$(FILE)

.PHONY: stop-forward
stop-forward:
-pkill -f "port-forward"

###############################################################################
### Local Kind Setup ###
###############################################################################
KIND_CLUSTER=starship

.PHONY: setup-kind
setup-kind:
kind create cluster --name $(KIND_CLUSTER)

.PHONY: clean-kind
clean-kind:
kind delete cluster --name $(KIND_CLUSTER)
90 changes: 90 additions & 0 deletions tests/starship/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Starship Tests
Multi-chain e2e tests that run against any chain, using chain binaries, relayers
and deploying Mesh-Security contracts.

Starship runs by separating out the infra from the tests that are run against the infra.

## Getting Started
### Setup script
In the `tests/starship` dir, run

```bash
make setup-deps ## Installs dependencies for Starship
```

### Manul install (alternate)
Alternatively to the setup script one can just install the deps directly:
* docker: https://docs.docker.com/get-docker/
* kubectl: https://kubernetes.io/docs/tasks/tools/
* kind: https://kind.sigs.k8s.io/docs/user/quick-start/#installation
* helm: https://helm.sh/docs/intro/install/
* yq: https://github.com/mikefarah/yq/#install

## Connect to a kubernetes cluster
### Spinup local cluster
On Linux:
```bash
make setup-kind
```

On Mac:
Use Docker Desktop to setup kubernetes cluster: https://docs.docker.com/desktop/kubernetes/#turn-on-kubernetes

### Connect to a remote cluster (alternate)
If one has access to a k8s cluster via a `kubeconfig` file one can run Starship directly on the remote cluster.

## Check connection with cluster
Run
```bash
kubectl get nodes
```

## Run Tests
Once the initial connection and setup is done, then one can spin up starship infra with

```bash
make install
# OR if you want to run specific config file
make install FILE=configs/devnet.yaml
```

Once the helm chart is installed, you will have to wait for pods to be in a `Running` state. Usually takes 3-5 mins depending on the resources available.
Can check with
```bash
kubectl get pods
```

When all pods are in `Running` state, run port-forwarding to access the nodes on localhost
```bash
make port-forward
# All exposed endpoints would be printed by this command
```

Now you can run the tests with:
```bash
make test
```

Once done, cleanup with:
```bash
make stop
```


## Configs
Starship configs is the definition of the infra we want to spin up.
Present in `test/starship/configs`, are multiple versions of the similar infra, tweaked to be able to run in different environments
* `configs/local.yaml`: Config file to be able to run locally
* `configs/devnet.yaml`: Supposed to be run on a larger k8s cluster, with more resources and number of validators
* `configs/ci.yaml`: Limited resources on the GH-Action runner, can be adapted for with reducing cpu,memory allocated

All the config files are similar topology, but different resources allocated.
Topology:
* 2 chains: `mesh-1` and `mesh-2` (both running `mesh-security-sdk` demo app)
* 1 hermes relayer: running between the chains, in pull mode (1.6.0)
* Registry service: analogous to cosmos chain-registry, but for only our infra
* Optionally explorer: ping-pub explorer for the mini cosmos

Details of each of arguments in the config file can be found [here](https://starship.cosmology.tech/config/chains)


93 changes: 93 additions & 0 deletions tests/starship/configs/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
chains:
- name: mesh-1
type: custom
numValidators: 1
image: ghcr.io/osmosis-labs/meshd:latest
home: /root/.meshd
binary: meshd
prefix: mesh
denom: stake
coins: 100000000000000stake
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/osmosis/mesh-security-sdk
genesis:
app_state:
meshsecurity:
params:
epoch_length: 10
staking:
params:
unbonding_time: 200s
ports:
rest: 1313
rpc: 26653
faucet: 8003
resources:
cpu: "0.2"
memory: "200M"
faucet:
concurreny: 2
resources:
cpu: "0.1"
memory: "100M"
- name: mesh-2
type: custom
numValidators: 1
image: ghcr.io/osmosis-labs/meshd:latest
home: /root/.meshd
binary: meshd
prefix: mesh
denom: stake
coins: 100000000000000stake
hdPath: m/44'/118'/0'/0/0
coinType: 118
repo: https://github.com/osmosis/mesh-security-sdk
genesis:
app_state:
meshsecurity:
params:
epoch_length: 10
staking:
params:
unbonding_time: 200s
ports:
rest: 1317
rpc: 26657
faucet: 8007
resources:
cpu: "0.2"
memory: "200M"
faucet:
concurreny: 2
resources:
cpu: "0.1"
memory: "100M"

relayers:
- name: mesh-1-mesh-2
type: hermes
replicas: 1
image: ghcr.io/cosmology-tech/starship/hermes:1.6.0
chains:
- mesh-1
- mesh-2
config:
event_source:
mode: pull
resources:
cpu: "0.1"
memory: "100M"

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

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