Skip to content

Commit b1029ea

Browse files
feat: install network node software without nmt (#197)
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com> Signed-off-by: Nathan Klick <nathan@swirldslabs.com> Co-authored-by: Nathan Klick <nathan@swirldslabs.com>
1 parent 6ca10ee commit b1029ea

10 files changed

Lines changed: 415 additions & 256 deletions

File tree

.github/workflows/zxc-compile-code.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,9 @@ jobs:
120120
121121
- name: Helm Chart Test
122122
id: helm-chart-test
123+
working-directory: dev
123124
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
124-
run: |
125-
kubectl config get-contexts
126-
helm install fst ./charts/hedera-network --values ./charts/hedera-network/nodes.yaml
127-
helm test fst
128-
TEST_STATUS="${?}"
129-
if [[ "${TEST_STATUS}" -ne 0 ]]; then
130-
kubectl logs network-test
131-
kubectl delete pod network-test
132-
fi
125+
run: make test
133126

134127
- name: Compile
135128
id: gradle-build

charts/hedera-network/templates/tests/test-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
annotations:
66
"helm.sh/hook": test
77
# add hook-failed once bug is fixed that prevents it from getting logs
8-
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
8+
"helm.sh/hook-delete-policy": before-hook-creation
99
spec:
1010
serviceAccountName: pod-monitor
1111
volumes:

dev/Makefile

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,80 @@
11
SCRIPTS_DIR=$(PWD)/scripts
2-
TMP_DIR="${SCRIPTS_DIR}/../temp"
2+
CHART_DIR=$(PWD)/../charts/hedera-network
3+
SCRIPT_NAME=direct-install.sh
4+
5+
TMP_DIR=${SCRIPTS_DIR}/../temp
36

47
.PHONY: all
58
all: setup setup-cluster reset
69

710
.PHONY: setup
811
setup:
9-
rm -f "${TMP_DIR}/*.*"
10-
cp "${SCRIPTS_DIR}/template.env" "${TMP_DIR}/.env"
12+
@rm -f "${TMP_DIR}/"*.*
13+
@cp "${SCRIPTS_DIR}/template.env" "${TMP_DIR}/.env"
1114

1215
.PHONY: setup-cluster
1316
setup-cluster:
14-
kind create cluster -n fst
17+
@kind create cluster -n fst
1518

1619
.PHONY: deploy-chart
1720
deploy-chart:
1821
@echo ">> Deploying helm chart..." && \
19-
helm install fst ../charts/hedera-network && \
20-
echo ">> Waiting for network to be ready (timeout=300s)..." && \
21-
kubectl wait --for=jsonpath='{.status.phase}'=Running pod -l fullstack.hedera.com/type=network-node --timeout=300s && \
22-
echo ">> Running helm test..." && \
23-
helm test fst &> "${TMP_DIR}/deploy.log" &
22+
echo "" && \
23+
helm install fst ../charts/hedera-network --values "${CHART_DIR}/nodes.yaml"
2424

25-
.PHONY: helm-test-logs
26-
helm-test-logs:
27-
@kubectl wait --for=jsonpath='{.status.phase}'=Running pod/network-test --timeout=300s && \
28-
kubectl logs -f network-test
25+
.PHONY: helm-test
26+
helm-test: setup deploy-chart
27+
@echo "" && \
28+
echo ">> Running helm test..." && \
29+
echo "" && \
30+
helm test fst --logs
2931

3032
.PHONY: deploy-network
31-
deploy-network: deploy-chart helm-test-logs
33+
deploy-network: deploy-chart
34+
@echo "" && \
35+
echo ">> Pod Information...." && \
36+
echo "" && \
3237
kubectl get pods -o wide && \
38+
echo "" && \
39+
echo ">> Service Information...." && \
40+
echo "" && \
3341
kubectl get svc -o wide
3442

43+
.PHONY: destroy-test-container
44+
destroy-test-container:
45+
@echo "" && \
46+
echo ">> Deleting test container..." && \
47+
kubectl delete pod network-test || true
48+
3549
.PHONY: destroy-network
36-
destroy-network:
37-
@echo ">> Uninstalling helm chart..." && helm uninstall fst && sleep 10
50+
destroy-network: destroy-test-container
51+
@echo "" && \
52+
echo ">> Uninstalling helm chart..." && \
53+
helm uninstall fst && \
54+
sleep 10
55+
56+
.PHONY: test
57+
test: deploy-network helm-test destroy-network
3858

3959
.PHONY: setup-nodes
4060
setup-nodes:
41-
source "${SCRIPTS_DIR}/helper.sh" && setup_node_all
61+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && setup_node_all
4262

4363
.PHONY: start-nodes
4464
start-nodes:
45-
source "${SCRIPTS_DIR}/helper.sh" && start_node_all
65+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && start_node_all
4666

4767
.PHONY: verify-nodes
4868
verify-nodes:
49-
source "${SCRIPTS_DIR}/helper.sh" && verify_node_all
69+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && verify_node_all
5070

5171
.PHONY: stop-nodes
5272
stop-nodes:
53-
source "${SCRIPTS_DIR}/helper.sh" && stop_node_all
73+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && stop_node_all
5474

5575
.PHONY: reset-nodes
5676
reset-nodes:
57-
source "${SCRIPTS_DIR}/helper.sh" && reset_node_all
77+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && reset_node_all
5878

5979
.PHONY: gen-keys
6080
gen-keys:
@@ -65,11 +85,11 @@ restart: stop-nodes destroy-network deploy-network start-nodes
6585

6686
.PHONY: prep-address-book
6787
prep-address-book:
68-
source "${SCRIPTS_DIR}/helper.sh" && prep_address_book
88+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && prep_address_book
6989

7090
.PHONY: run-func
7191
run-func:
72-
source "${SCRIPTS_DIR}/helper.sh" && ${FUNC}
92+
source "${SCRIPTS_DIR}/${SCRIPT_NAME}" && ${FUNC}
7393

7494
.PHONY: start
7595
start: deploy-network setup-nodes start-nodes

dev/scripts/direct-install.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
4+
readonly SCRIPT_DIR
5+
6+
# shellcheck source=./helper.sh
7+
source "${SCRIPT_DIR}/helper.sh"
8+
9+
function create_hapi_directories() {
10+
local pod="${1}"
11+
12+
if [ -z "${pod}" ]; then
13+
echo "ERROR: 'mkdirs' - pod name is required"
14+
return "${EX_ERR}"
15+
fi
16+
17+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "mkdir -p $HAPI_PATH" || true
18+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "mkdir -p $HAPI_PATH/data/keys" || true
19+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "mkdir -p $HAPI_PATH/data/config" || true
20+
}
21+
22+
function unzip_build() {
23+
local pod="${1}"
24+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "cd ${HAPI_PATH} && jar xvf /home/hedera/build-*" || true
25+
}
26+
27+
function start_service() {
28+
local pod="${1}"
29+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "systemctl restart network-node" || true
30+
}
31+
32+
function stop_service() {
33+
local pod="${1}"
34+
"${KCTL}" exec "${pod}" -c root-container -- bash -c "systemctl stop network-node" || true
35+
}
36+
37+
function setup_node_all() {
38+
if [[ "${#NODE_NAMES[*]}" -le 0 ]]; then
39+
echo "ERROR: Node list is empty. Set NODE_NAMES env variable with a list of nodes"
40+
return "${EX_ERR}"
41+
fi
42+
43+
echo ""
44+
echo "Processing nodes ${NODE_NAMES[*]} ${#NODE_NAMES[@]}"
45+
echo "-----------------------------------------------------------------------------------------------------"
46+
47+
fetch_platform_build || return "${EX_ERR}"
48+
prep_address_book || return "${EX_ERR}"
49+
50+
local node_name
51+
for node_name in "${NODE_NAMES[@]}"; do
52+
local pod="network-${node_name}-0" # pod name
53+
54+
create_hapi_directories "${pod}" || return "${EX_ERR}"
55+
copy_platform "${pod}" || return "${EX_ERR}"
56+
ls_path "${pod}" "${HEDERA_HOME_DIR}" || return "${EX_ERR}"
57+
58+
# hedera.crt, hedera.keys
59+
copy_hedera_keys "${pod}" || return "${EX_ERR}"
60+
61+
# config.txt,settings.txt
62+
# log4j2.xml, api-permission.properties, application.properties, bootstrap.properties
63+
copy_config_files "${node_name}" "${pod}" || return "${EX_ERR}"
64+
ls_path "${pod}" "${HAPI_PATH}/"
65+
66+
# private-${node}.pfx, public.pfx
67+
copy_node_keys "${node_name}" "${pod}" || return "${EX_ERR}"
68+
ls_path "${pod}" "${HAPI_PATH}/data/keys/"
69+
set_permission "${pod}" "${HAPI_PATH}"
70+
71+
unzip_build "${pod}"
72+
done
73+
}
74+
75+
76+
function start_node_all() {
77+
set -x
78+
if [[ "${#NODE_NAMES[*]}" -le 0 ]]; then
79+
echo "ERROR: Node list is empty. Set NODE_NAMES env variable with a list of nodes"
80+
return "${EX_ERR}"
81+
fi
82+
83+
echo ""
84+
echo "Processing nodes ${NODE_NAMES[*]} ${#NODE_NAMES[@]}"
85+
echo "-----------------------------------------------------------------------------------------------------"
86+
87+
local node_name
88+
for node_name in "${NODE_NAMES[@]}"; do
89+
local pod="network-${node_name}-0" # pod name
90+
start_service "${pod}" || return "${EX_ERR}"
91+
log_time
92+
done
93+
94+
verify_node_all || return "${EX_ERR}"
95+
96+
return "${EX_OK}"
97+
}
98+
99+
function stop_node_all() {
100+
if [[ "${#NODE_NAMES[*]}" -le 0 ]]; then
101+
echo "ERROR: Node list is empty. Set NODE_NAMES env variable with a list of nodes"
102+
return "${EX_ERR}"
103+
fi
104+
echo ""
105+
echo "Processing nodes ${NODE_NAMES[*]} ${#NODE_NAMES[@]}"
106+
echo "-----------------------------------------------------------------------------------------------------"
107+
108+
local node_name
109+
for node_name in "${NODE_NAMES[@]}"; do
110+
local pod="network-${node_name}-0" # pod name
111+
stop_service "${pod}" || return "${EX_ERR}"
112+
log_time
113+
done
114+
115+
return "${EX_OK}"
116+
}

0 commit comments

Comments
 (0)