-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathMakefile.helper
More file actions
142 lines (131 loc) 路 6.28 KB
/
Copy pathMakefile.helper
File metadata and controls
142 lines (131 loc) 路 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Helper functions for common make targets
# Function to ensure user_uid exists
define ENSURE_USER_UID
@if [ ! -f "$$(echo ${SYSTEM_CONFIG_PATH}/user_uid)" ]; then \
mkdir -p ${SYSTEM_CONFIG_PATH} && \
uuidgen > ${SYSTEM_CONFIG_PATH}/user_uid; \
fi
endef
# Function to get common compose parameters
define GET_COMPOSE_PARAMS
$(if $(filter true,$(CI)),EDITION=docker-ce:test,EDITION=$${EDITION:=local-ce}) \
DEFAULT_USER_UID=$$(cat ${SYSTEM_CONFIG_PATH}/user_uid) \
$(if $(filter true,$(CI)),ENV_SECRETS_COMPONENT=${ENV_SECRETS_COMPONENT_TEST},ENV_SECRETS_COMPONENT=${ENV_SECRETS_COMPONENT})
endef
# Function to launch docker compose with GPU support
define COMPOSE_GPU
@cat docker-compose-nvidia.yml | yq '.services.ray.deploy.resources.reservations.devices[0].device_ids |= (strenv(NVIDIA_VISIBLE_DEVICES) | split(",")) | ..style="double"' | \
$(1) docker compose $(2) -f - up -d
endef
# Function to launch docker compose without GPU support
define COMPOSE_CPU
@$(1) docker compose $(2) up -d
endef
# Function to launch Helm chart (main orchestrator)
define HELM
$(HELM_ADD_REPOS)
@echo ""
$(HELM_INSTALL_RAY)
@echo ""
$(HELM_INSTALL_TEMPORAL)
@echo ""
$(HELM_INSTALL_MINIO)
@echo ""
$(HELM_INSTALL_MILVUS)
@echo ""
$(HELM_INSTALL_INSTILL_CORE)
@echo ""
$(HELM_INSTALL_OBSERVABILITY)
endef
# Function to build dev image
define BUILD_DEV
@bash -c ' \
set -e; \
trap "$(MAKE) down" ERR INT TERM && \
docker build --progress plain \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
--build-arg K6_VERSION=${K6_VERSION} \
--build-arg XK6_VERSION=${XK6_VERSION} \
--build-arg XK6_SQL_VERSION=${XK6_SQL_VERSION} \
--build-arg XK6_SQL_POSTGRES_VERSION=${XK6_SQL_POSTGRES_VERSION} \
--build-arg CACHE_DATE="$(shell date)" \
--build-arg API_GATEWAY_VERSION=${API_GATEWAY_VERSION} \
--build-arg PIPELINE_BACKEND_VERSION=${PIPELINE_BACKEND_VERSION} \
--build-arg ARTIFACT_BACKEND_VERSION=${ARTIFACT_BACKEND_VERSION} \
--build-arg MODEL_BACKEND_VERSION=${MODEL_BACKEND_VERSION} \
--build-arg MGMT_BACKEND_VERSION=${MGMT_BACKEND_VERSION} \
--build-arg CONSOLE_VERSION=${CONSOLE_VERSION} \
-t ${INSTILL_CORE_IMAGE_NAME}:${GIT_COMMIT_SHA} . \
'
endef
# Function to remove containers
define REMOVE_CONTAINERS
@docker rm -f ${CONTAINER_COMPOSE_INTEGRATION_TEST_NAME}:${GIT_COMMIT_SHA} >/dev/null 2>&1
@docker rm -f ${CONTAINER_COMPOSE_INTEGRATION_TEST_NAME}-helm:${GIT_COMMIT_SHA} >/dev/null 2>&1
endef
# Main orchestrator for removing all Helm resources
define REMOVE_HELM_RESOURCES
$(REMOVE_OBSERVABILITY)
$(REMOVE_MILVUS)
$(REMOVE_MINIO)
$(REMOVE_TEMPORAL)
$(REMOVE_RAY)
$(REMOVE_INSTILL_CORE)
endef
# Function to run backend integration test
define COMPOSE_INTEGRATION_TEST
@$(MAKE) compose-run EDITION=docker-ce:test ENV_SECRETS_COMPONENT=${ENV_SECRETS_COMPONENT_TEST}
@docker run --rm \
--network ${COMPOSE_NETWORK_NAME} \
--name ${CONTAINER_COMPOSE_INTEGRATION_TEST_NAME}-${GIT_COMMIT_SHA} \
${INSTILL_CORE_IMAGE_NAME}:${GIT_COMMIT_SHA} /bin/sh -c " \
/bin/sh -c 'cd mgmt-backend && make integration-test API_GATEWAY_URL=${API_GATEWAY_HOST}:${API_GATEWAY_PORT}' && \
/bin/sh -c 'cd pipeline-backend && make integration-test API_GATEWAY_URL=${API_GATEWAY_HOST}:${API_GATEWAY_PORT} DB_HOST=pg-sql' && \
/bin/sh -c 'cd model-backend && make integration-test API_GATEWAY_URL=${API_GATEWAY_HOST}:${API_GATEWAY_PORT}' \
"
@$(MAKE) down
endef
# Function to run Helm backend integration test
define HELM_INTEGRATION_TEST
@$(MAKE) helm-run CI=true
@bash -c 'while [[ "$$(kubectl get pods --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE} -l app.kubernetes.io/component=api-gateway,app.kubernetes.io/instance=core -o jsonpath={..status.phase})" != *"Running"* ]]; do \
echo "$$(kubectl get pods --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE})"; \
sleep 10; \
done; \
echo "$$(kubectl get pods --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE})"'
@kubectl --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE} port-forward $$(kubectl get pods --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE} -l "app.kubernetes.io/component=api-gateway,app.kubernetes.io/instance=core" -o jsonpath="{.items[0].metadata.name}") ${API_GATEWAY_PORT}:${API_GATEWAY_PORT} > /dev/null 2>&1 &
@kubectl --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE} port-forward $$(kubectl get pods --namespace ${INSTILL_CORE_KUBERNETES_NAMESPACE} -l "app.kubernetes.io/component=database,app.kubernetes.io/instance=core" -o jsonpath="{.items[0].metadata.name}") ${POSTGRESQL_PORT}:${POSTGRESQL_PORT} > /dev/null 2>&1 &
@echo "Waiting for port-forwarding to be ready..."
@timeout=120; \
while ! nc -z localhost ${API_GATEWAY_PORT} >/dev/null 2>&1 || ! nc -z localhost ${POSTGRESQL_PORT} >/dev/null 2>&1; do \
if [ $$timeout -le 0 ]; then \
echo "Timeout waiting for port-forwarding"; \
exit 1; \
fi; \
sleep 1; \
timeout=$$((timeout-1)); \
done;
@echo "Port-forwarding is ready"
@if [ "$(UNAME_S)" = "Darwin" ]; then \
docker run --rm --name ${CONTAINER_COMPOSE_INTEGRATION_TEST_NAME}-helm-${GIT_COMMIT_SHA} ${INSTILL_CORE_IMAGE_NAME}:${GIT_COMMIT_SHA} /bin/sh -c " \
/bin/sh -c 'cd mgmt-backend && make integration-test API_GATEWAY_URL=host.docker.internal:${API_GATEWAY_PORT}' && \
/bin/sh -c 'cd pipeline-backend && make integration-test API_GATEWAY_URL=host.docker.internal:${API_GATEWAY_PORT} DB_HOST=host.docker.internal' && \
/bin/sh -c 'cd model-backend && make integration-test API_GATEWAY_URL=host.docker.internal:${API_GATEWAY_PORT}' \
"; \
else \
docker run --rm --network host --name ${CONTAINER_COMPOSE_INTEGRATION_TEST_NAME}-helm-${GIT_COMMIT_SHA} ${INSTILL_CORE_IMAGE_NAME}:${GIT_COMMIT_SHA} /bin/sh -c " \
/bin/sh -c 'cd mgmt-backend && make integration-test API_GATEWAY_URL=localhost:${API_GATEWAY_PORT}' && \
/bin/sh -c 'cd pipeline-backend && make integration-test API_GATEWAY_URL=localhost:${API_GATEWAY_PORT}' && \
/bin/sh -c 'cd model-backend && make integration-test API_GATEWAY_URL=localhost:${API_GATEWAY_PORT}' \
"; \
fi
@$(MAKE) down
endef
# Function to run model deployment integration test
define MODEL_INTEGRATION_TEST
@EDITION=docker-ce:test docker compose up registry -d
@$(MAKE) build-and-push-models
@$(MAKE) compose-dev EDITION=docker-ce:test INITMODEL_ENABLED=true INITMODEL_INVENTORY=${PWD}/integration-test/models/inventory.json
@$(MAKE) wait-models-deploy
@$(MAKE) down
endef