-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
976 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,12 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v3.3 | ||
uses: azure/setup-helm@v3.5 | ||
with: | ||
version: v3.12.1 | ||
|
||
|
@@ -67,8 +67,9 @@ jobs: | |
- name: Create kind cluster | ||
uses: helm/[email protected] | ||
with: | ||
node_image: kindest/node:v1.27.3 | ||
node_image: kindest/node:v1.28.0 | ||
config: chart-testing/kind-config.yaml | ||
wait: 5m | ||
if: steps.list-changed.outputs.changed | ||
|
||
- name: Replace secrets in Helm charts | ||
|
@@ -86,9 +87,31 @@ jobs: | |
|
||
- name: Run chart-testing (install) | ||
run: | | ||
ct install \ | ||
--target-branch ${{ github.event.repository.default_branch }} \ | ||
--charts ${{ steps.list-changed.outputs.changed }} | ||
# Exclude charts/node as it is covered by proper tests. Exclude more charts if needed | ||
CHARTS_WITHOUT_TESTS=$(printf "${{ steps.list-changed.outputs.changed }}" | sed -E 's|charts/node,?||g') | ||
if [[ -n "$CHARTS_WITHOUT_TESTS" ]]; then | ||
ct install \ | ||
--target-branch ${{ github.event.repository.default_branch }} \ | ||
--charts $CHARTS_WITHOUT_TESTS | ||
fi | ||
if: steps.list-changed.outputs.changed | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
cache-dependency-path: "charts/**/ginkgo/go.sum" | ||
if: steps.list-changed.outputs.changed | ||
|
||
- name: Run ginkgo tests | ||
run: | | ||
export KUBECONFIG=~/.kube/config | ||
CHANGED_CHARTS=${{ steps.list-changed.outputs.changed }} | ||
for chart in ${CHANGED_CHARTS//,/$IFS}; do | ||
if [[ -f $chart/ci/Makefile ]]; then | ||
pushd $chart/ci && make test | ||
popd | ||
fi | ||
done | ||
if: steps.list-changed.outputs.changed | ||
|
||
validate-manifests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ci/**/charts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cluster-create: | ||
kind create cluster --config ../../chart-testing/kind-config.yaml --name node-testing --wait 5m | ||
test: | ||
docker build -f addons/nginx-assets-server/nginx-assets-server.Dockerfile -t nginx-assets-server:latest addons/nginx-assets-server | ||
kind load docker-image --name chart-testing docker.io/library/nginx-assets-server:latest | ||
./run-tests.sh | ||
clean: | ||
kind delete cluster --name node-testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resources: | ||
- metallb | ||
- metrics-server | ||
- nginx-ingress-controller | ||
- nginx-assets-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: metallb.io/v1beta1 | ||
kind: IPAddressPool | ||
metadata: | ||
name: kind-default | ||
spec: | ||
addresses: | ||
# - 10.89.0.247-10.89.0.252 # for Podman | ||
- 172.18.255.240-172.18.255.250 # for Docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
helmCharts: | ||
- name: metallb | ||
includeCRDs: true | ||
valuesFile: values.yaml | ||
releaseName: metallb | ||
version: 0.13.11 | ||
repo: https://metallb.github.io/metallb | ||
|
||
namespace: metallb-system | ||
|
||
resources: | ||
- ns.yaml | ||
- ipaddresses.yaml | ||
- l2advertisement.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: metallb.io/v1beta1 | ||
kind: L2Advertisement | ||
metadata: | ||
name: kind-default | ||
spec: | ||
ipAddressPools: | ||
- kind-default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: metallb-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
controller: | ||
image: | ||
tag: v0.13.11 | ||
speaker: | ||
image: | ||
tag: v0.13.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
helmCharts: | ||
- name: metrics-server | ||
includeCRDs: true | ||
releaseName: metrics-server | ||
version: 3.11.0 | ||
repo: https://kubernetes-sigs.github.io/metrics-server/ | ||
|
||
namespace: metrics-server | ||
|
||
resources: | ||
- ns.yaml | ||
|
||
patches: | ||
- patch: |- | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --kubelet-insecure-tls | ||
target: | ||
version: v1 | ||
kind: Deployment | ||
name: metrics-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: metrics-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Build chainspec | ||
``` | ||
polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > rococo-local.json | ||
``` |
168 changes: 168 additions & 0 deletions
168
charts/node/ci/addons/nginx-assets-server/assets/rococo-local.json
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+795 KB
charts/node/ci/addons/nginx-assets-server/assets/tick_v9-chain-backup.tar.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace: assets-server | ||
|
||
resources: | ||
- ns.yaml | ||
- nginx-assets-server.yaml |
5 changes: 5 additions & 0 deletions
5
charts/node/ci/addons/nginx-assets-server/nginx-assets-server.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM docker.io/nginx:1.25.2-alpine | ||
|
||
COPY assets/tick_v9-chain-backup.tar.gz assets/rococo-local.json /usr/share/nginx/html/ | ||
RUN tar -xzf /usr/share/nginx/html/tick_v9-chain-backup.tar.gz -C /usr/share/nginx/html/ && \ | ||
rm /usr/share/nginx/html/tick_v9-chain-backup.tar.gz |
37 changes: 37 additions & 0 deletions
37
charts/node/ci/addons/nginx-assets-server/nginx-assets-server.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: assets-server | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: assets-server | ||
template: | ||
metadata: | ||
labels: | ||
app: assets-server | ||
spec: | ||
containers: | ||
- name: assets-server | ||
image: docker.io/library/nginx-assets-server:latest | ||
imagePullPolicy: Never | ||
resources: | ||
limits: | ||
memory: "128Mi" | ||
cpu: "500m" | ||
ports: | ||
- name: http | ||
containerPort: 80 | ||
--- | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: assets-server | ||
spec: | ||
selector: | ||
app: assets-server | ||
ports: | ||
- name: http | ||
protocol: TCP | ||
port: 80 | ||
targetPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: assets-server |
12 changes: 12 additions & 0 deletions
12
charts/node/ci/addons/nginx-ingress-controller/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
helmCharts: | ||
- name: ingress-nginx | ||
includeCRDs: true | ||
releaseName: ingress-nginx | ||
valuesFile: values.yaml | ||
version: 4.7.2 | ||
repo: https://kubernetes.github.io/ingress-nginx | ||
|
||
namespace: ingress-nginx | ||
|
||
resources: | ||
- ns.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: ingress-nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
controller: | ||
config: | ||
worker-processes: 2 # https://github.com/kubernetes/ingress-nginx/issues/6141 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
node: | ||
chain: rococo-local | ||
role: full | ||
replicas: 2 | ||
chainData: | ||
storageClass: standard | ||
volumeSize: 1Gi | ||
chainKeystore: | ||
storageClass: standard | ||
mountInMemory: | ||
enabled: true | ||
podManagementPolicy: Parallel | ||
persistentVolumeClaimRetentionPolicy: | ||
whenDeleted: Delete | ||
whenScaled: Delete | ||
substrateApiSidecar: | ||
enabled: true | ||
enableSidecarReadinessProbe: true | ||
perNodeServices: | ||
relayP2pService: | ||
enabled: true | ||
type: NodePort | ||
setPublicAddressToExternalIp: | ||
enabled: false | ||
ingress: | ||
enabled: true | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
rules: | ||
- host: dev-rpc.local | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: dev-rpc-node | ||
port: | ||
name: rpc | ||
image: | ||
tag: v1.0.0 | ||
repository: docker.io/parity/polkadot | ||
wsHealthExporter: | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 32M | ||
limits: | ||
cpu: 200m | ||
memory: 64M | ||
env: | ||
WSHE_NODE_MAX_UNSYNCHRONIZED_BLOCK_DRIFT: "4" | ||
WSHE_NODE_MIN_PEERS: "0" | ||
terminationGracePeriodSeconds: 10 | ||
|
||
substrateApiSidecar: | ||
metrics: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package node_test | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
appsv1 "k8s.io/api/apps/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
var _ = Describe("dev-rpc", Ordered, func() { | ||
var c *kubernetes.Clientset | ||
var ctx context.Context | ||
var cancel context.CancelFunc | ||
const releaseName = "dev-rpc" | ||
|
||
BeforeEach(func() { | ||
|
||
ctx, cancel = context.WithCancel(context.Background()) | ||
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
c = kubernetes.NewForConfigOrDie(config) | ||
}) | ||
|
||
When("an RPC node is running", func() { | ||
It("should return the list of supported RPC methods", func() { | ||
|
||
getAvailableReplicas := func(ss *appsv1.StatefulSet) int32 { return ss.Status.AvailableReplicas } | ||
getOpts := metav1.GetOptions{} | ||
|
||
stsName := fmt.Sprintf("%s-node", releaseName) | ||
By("checking all the replicas are available") | ||
ss, err := c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(ss.Status.Replicas).NotTo(BeZero()) | ||
origReplicas := *ss.Spec.Replicas | ||
|
||
Eventually(func() (*appsv1.StatefulSet, error) { | ||
return c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts) | ||
}, timeout, PollingInterval).Should(WithTransform(getAvailableReplicas, Equal(origReplicas))) | ||
|
||
rpcIngress, err := c.NetworkingV1().Ingresses(namespace).Get(ctx, stsName, getOpts) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
loadbalancerIP := rpcIngress.Status.LoadBalancer.Ingress[0].IP | ||
rpcHostname := rpcIngress.Spec.Rules[0].Host | ||
|
||
var resp *http.Response | ||
var respBody []byte | ||
var respBodyJSON map[string]interface{} | ||
|
||
Eventually(func(g Gomega) int { | ||
reqJSON := []byte(`{"id":42, "jsonrpc":"2.0", "method": "rpc_methods"}`) | ||
req, err := http.NewRequest("POST", fmt.Sprintf("http://%s", loadbalancerIP), bytes.NewBuffer(reqJSON)) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
req.Host = rpcHostname | ||
req.Header.Set("Content-Type", "application/json") | ||
resp, err = http.DefaultClient.Do(req) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
defer resp.Body.Close() | ||
g.Expect(resp.StatusCode).To(Equal(http.StatusOK)) | ||
respBody, err = io.ReadAll(resp.Body) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
errJSON := json.Unmarshal(respBody, &respBodyJSON) | ||
g.Expect(errJSON).NotTo(HaveOccurred()) | ||
return resp.StatusCode | ||
}, timeout, PollingInterval).Should(Equal(http.StatusOK)) | ||
|
||
Expect(respBodyJSON).To(HaveKey("result")) | ||
}) | ||
}) | ||
|
||
AfterEach(func() { | ||
cancel() | ||
}) | ||
}) |
Oops, something went wrong.