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

Add starship integration running vanila stride and simple e2e tests #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions .github/workflows/starship.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Starship E2E tests

on:
push:
branches:
- main
pull_request:
branches:
- main

workflow_dispatch:

jobs:
e2e-tests:
runs-on: ubuntu-latest
steps:
- name: checkout 🛎️
uses: actions/[email protected]
- name: node
uses: actions/setup-node@v3
with:
node-version: 18.4.0
- name: deps
run: yarn
- name: bootstrap
run: yarn bootstrap
- name: build
run: yarn build
# Starship Infra setup
# - Create a local kind cluster
# - Creates a new namespace based on the name
# - 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: infra
id: starship-action
uses: cosmology-tech/[email protected]
with:
values: starship/configs/local-config.yaml
port-forward: true
version: 0.1.34
- name: e2e
run: yarn run e2e:test
26 changes: 23 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@
"dev": "cross-env NODE_ENV=development babel-node src/index --extensions \".tsx,.ts,.js\"",
"watch": "cross-env NODE_ENV=development babel-watch src/index --extensions \".tsx,.ts,.js\"",
"lint": "eslint src --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand"
"test": "jest --testPathIgnorePatterns=starship/",
"test:watch": "jest --watch --testPathIgnorePatterns=starship/",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand --testPathIgnorePatterns=starship/",
"e2e": "npm run e2e:test",
"e2e:deps": "cd tests && make setup",
"e2e:kind": "cd tests && make setup-kind",
"e2e:start": "cd tests && make start",
"e2e:test": "jest --testPathPattern=starship/ --verbose --bail",
"e2e:debug": "jest --testPathPattern=starship/ --runInBand --verbose --bail",
"e2e:stop": "cd tests && make stop",
"e2e:clean": "cd tests && make stop clean"
},
"publishConfig": {
"access": "public"
Expand All @@ -59,23 +67,35 @@
"@babel/plugin-transform-runtime": "7.18.10",
"@babel/preset-env": "7.18.10",
"@babel/preset-typescript": "^7.18.6",
"@chain-registry/client": "1.11.0",
"@confio/relayer": "0.7.0",
"@cosmjs/cosmwasm-stargate": "0.29.4",
"@cosmjs/crypto": "0.29.4",
"@osmonauts/telescope": "^0.35.0",
"@protobufs/cosmos": "^0.0.11",
"@protobufs/cosmos_proto": "^0.0.10",
"@protobufs/cosmwasm": "^0.0.11",
"@protobufs/ibc": "^0.0.11",
"@types/jest": "^28.1.6",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "28.1.3",
"babel-watch": "^7.0.0",
"bignumber.js": "9.1.0",
"cosmjs-types": "0.5.2",
"cross-env": "^7.0.2",
"eslint": "8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^28.1.3",
"jest-in-case": "^1.0.2",
"js-yaml": "4.1.0",
"long": "^5.2.0",
"node-fetch": "^2.6.9",
"path": "^0.12.7",
"prettier": "^2.7.1",
"regenerator-runtime": "^0.13.7",
"rimraf": "^3.0.2",
"sinon": "14.0.2",
"ts-jest": "^28.0.7",
"typescript": "^4.7.4"
},
Expand Down
82 changes: 82 additions & 0 deletions starship/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
HELM_NAME = stridejs
HELM_FILE = configs/config.yaml
HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.1.34

###############################################################################
### All commands ###
###############################################################################

.PHONY: setup
setup: check setup-helm

.PHONY: start
start: install port-forward

.PHONY: test
test:
jest --testPathPattern=../starship --runInBand --verbose --bail

.PHONY: stop
stop: stop-forward delete

.PHONY: clean
clean: stop clean-kind

###############################################################################
### Helm commands ###
###############################################################################

.PHONY: setup-helm
setup-helm:
helm repo add $(HELM_REPO) https://cosmology-tech.github.io/starship/
helm repo update
helm search repo $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)

.PHONY: install
install:
@echo "Installing the helm chart. This is going to take a while....."
@echo "You can check the status with \"kubectl get pods\", run in another terminal please"
helm install -f $(HELM_FILE) $(HELM_NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION) --wait --timeout 20m

.PHONY: upgrade
upgrade:
helm upgrade --debug -f $(HELM_FILE) $(HELM_NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)

.PHONY: debug
debug:
helm install --dry-run --debug -f $(HELM_FILE) $(HELM_NAME) $(HELM_REPO)/$(HELM_CHART)

.PHONY: delete
delete:
-helm delete $(HELM_NAME)

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

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

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

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

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

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

.PHONY: clean-kind
clean-kind:
kind delete cluster --name $(KIND_CLUSTER)
75 changes: 75 additions & 0 deletions starship/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## 1. Installation
Inorder to get started with starship, one needs to install the following
* `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

Note: To make the process easy we have a simple command that will try and install dependencies
so that you dont have to.

```bash
npm run e2e:deps
```
This command will
* check (and install) if your system has all the dependencies needed to run the e2e tests wtih Starship
* fetch the helm charts for Starship

## 2. Connect to a kubernetes cluster
Inorder to set up the infrastructure, for Starship, we need access to a kubernetes cluster.
One can either perform connect to a
* remote cluster in a managed kubernetes service
* use kubernetes desktop to spin up a cluster
* use kind to create a local cluster on local machine

To make this easier we have a handy command which will create a local kind cluster and give you access
to a kubernetes cluster locally.

NOTE: Resources constraint on local machine will affect the performance of Starship spinup time

```bash
npm run e2e:kind
```

Run the following command to check connection to a k8s cluster
```bash
kubectl get pods
```

## 3. Start Starship
Now with the dependencies and a kubernetes cluster in handy, we can proceed with creating the mini-cosmos ecosystem

Run
```bash
npm run e2e:start
```

We use the config file `configs/config.yaml` as the genesis file to define the topology of the e2e test infra. Change it as required

Note: Spinup will take some time, while you wait for the system, can check the progress in another tab with `kubectl get pods`

## 4. Run the tests
We have everything we need, our desired infrastructure is now running as intended, now we can run
our end-to-end tests.

Run
```bash
npm run e2e:test
```

## 5. Stop the infra
The tests should be ideompotent, so the tests can be run multiple times (which is recommeded), since the time to spinup is still high (around 5 to 10 mins).

Once the state of the mini-cosmos is corrupted, you can stop the deployments with
```bash
npm run e2e:stop
```
Which will
* Stop port-forwarding the traffic to your local
* Delete all the helm charts deployed

## 6. Cleanup kind (optional)
If you are using kind for your kubernetes cluster, you can delete it with
```bash
npm run e2e:clean
```
Loading