bulltrackers-module 1.0.750 → 1.0.752
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,7 +31,10 @@ async function adminTestHandler(req, res) {
|
|
|
31
31
|
limit = 10,
|
|
32
32
|
force = true, // Default to force for testing
|
|
33
33
|
useWorkerPool, // Override: true/false/undefined (use config)
|
|
34
|
-
dryRun = false
|
|
34
|
+
dryRun = false,
|
|
35
|
+
// [NEW] Accept override parameters for infrastructure testing
|
|
36
|
+
outputTable, // e.g., "computation_results_test"
|
|
37
|
+
workerUrl // e.g., "https://...cloudfunctions.net/worker-test"
|
|
35
38
|
} = req.body || {};
|
|
36
39
|
|
|
37
40
|
console.log(`[AdminTest] Action: ${action}, Computation: ${computation}, Date: ${date}`);
|
|
@@ -93,38 +96,59 @@ async function adminTestHandler(req, res) {
|
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// Prepare Config Overrides
|
|
100
|
+
// We create this here so we can log what's happening
|
|
101
|
+
const baseConfig = system.config;
|
|
102
|
+
let customConfig = null;
|
|
103
|
+
|
|
104
|
+
// Check if we need to modify the configuration
|
|
105
|
+
if (outputTable || useWorkerPool !== undefined || workerUrl) {
|
|
106
|
+
customConfig = { ...baseConfig }; // Shallow copy
|
|
107
|
+
|
|
108
|
+
// 1. Override Output Table
|
|
109
|
+
if (outputTable) {
|
|
110
|
+
console.log(`[AdminTest] ⚠️ Redirecting output to: ${outputTable}`);
|
|
111
|
+
// Fix for TS Error: Ensure baseConfig.resultStore exists before spreading
|
|
112
|
+
const baseStore = baseConfig.resultStore;
|
|
113
|
+
if (!baseStore) {
|
|
114
|
+
throw new Error("System config is missing 'resultStore'");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
customConfig.resultStore = {
|
|
118
|
+
...baseStore,
|
|
119
|
+
table: outputTable
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 2. Override Worker Pool Settings
|
|
124
|
+
if (useWorkerPool !== undefined || workerUrl) {
|
|
125
|
+
const basePool = baseConfig.workerPool || {};
|
|
126
|
+
customConfig.workerPool = {
|
|
127
|
+
...basePool,
|
|
128
|
+
// If useWorkerPool is explicitly provided, use it. Otherwise keep existing.
|
|
129
|
+
enabled: useWorkerPool !== undefined ? useWorkerPool : basePool.enabled,
|
|
130
|
+
// If workerUrl provided, override it.
|
|
131
|
+
workerUrl: workerUrl || basePool.workerUrl
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Log the override state
|
|
135
|
+
console.log(`[AdminTest] Worker Pool Override: Enabled=${customConfig.workerPool.enabled}, URL=${customConfig.workerPool.workerUrl || 'default'}`);
|
|
136
|
+
}
|
|
99
137
|
}
|
|
100
138
|
|
|
101
139
|
console.log(`[AdminTest] Running ${computation} for ${date}...`);
|
|
102
140
|
console.log(`[AdminTest] Options: force=${force}, dryRun=${dryRun}, entityIds=${entityIds?.join(',') || 'all'}`);
|
|
103
141
|
|
|
104
|
-
// Prepare run options
|
|
105
142
|
const runOptions = {
|
|
106
143
|
date,
|
|
107
144
|
computation,
|
|
108
145
|
entityIds: entityIds || null,
|
|
109
146
|
dryRun,
|
|
110
147
|
force,
|
|
111
|
-
useWorkerPool
|
|
148
|
+
useWorkerPool,
|
|
149
|
+
config: customConfig // Inject the modified config
|
|
112
150
|
};
|
|
113
151
|
|
|
114
|
-
// [FIX] If forcing worker pool, inject config to enable it dynamically
|
|
115
|
-
// This prevents Orchestrator from ignoring the request if default config has enabled: false
|
|
116
|
-
if (useWorkerPool) {
|
|
117
|
-
const baseConfig = system.config;
|
|
118
|
-
runOptions.config = {
|
|
119
|
-
...baseConfig,
|
|
120
|
-
workerPool: {
|
|
121
|
-
...(baseConfig.workerPool || {}),
|
|
122
|
-
enabled: true
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
console.log('[AdminTest] Injecting config to FORCE enable RemoteTaskRunner');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
152
|
const result = await system.runComputation(runOptions);
|
|
129
153
|
|
|
130
154
|
const duration = Date.now() - startTime;
|
|
@@ -169,27 +193,39 @@ async function adminTestHandler(req, res) {
|
|
|
169
193
|
|
|
170
194
|
console.log(`[AdminTest] Running LIMITED test: ${sampleEntities.length} entities`);
|
|
171
195
|
|
|
196
|
+
// Prepare Config Overrides (Same logic as 'run')
|
|
197
|
+
const baseConfig = system.config;
|
|
198
|
+
let customConfig = null;
|
|
199
|
+
|
|
200
|
+
if (outputTable || useWorkerPool !== undefined || workerUrl) {
|
|
201
|
+
customConfig = { ...baseConfig };
|
|
202
|
+
|
|
203
|
+
if (outputTable) {
|
|
204
|
+
const baseStore = baseConfig.resultStore;
|
|
205
|
+
if (!baseStore) throw new Error("System config missing 'resultStore'");
|
|
206
|
+
customConfig.resultStore = { ...baseStore, table: outputTable };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (useWorkerPool !== undefined || workerUrl) {
|
|
210
|
+
const basePool = baseConfig.workerPool || {};
|
|
211
|
+
customConfig.workerPool = {
|
|
212
|
+
...basePool,
|
|
213
|
+
enabled: useWorkerPool !== undefined ? useWorkerPool : basePool.enabled,
|
|
214
|
+
workerUrl: workerUrl || basePool.workerUrl
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
172
219
|
const runOptions = {
|
|
173
220
|
date,
|
|
174
221
|
computation,
|
|
175
222
|
entityIds: sampleEntities,
|
|
176
223
|
dryRun,
|
|
177
224
|
force,
|
|
178
|
-
useWorkerPool
|
|
225
|
+
useWorkerPool,
|
|
226
|
+
config: customConfig
|
|
179
227
|
};
|
|
180
228
|
|
|
181
|
-
// Apply the same fix for run_limited if needed
|
|
182
|
-
if (useWorkerPool) {
|
|
183
|
-
const baseConfig = system.config;
|
|
184
|
-
runOptions.config = {
|
|
185
|
-
...baseConfig,
|
|
186
|
-
workerPool: {
|
|
187
|
-
...(baseConfig.workerPool || {}),
|
|
188
|
-
enabled: true
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
229
|
const result = await system.runComputation(runOptions);
|
|
194
230
|
|
|
195
231
|
const duration = Date.now() - startTime;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Here is the comprehensive documentation for the **Admin Test Endpoint (`compute-admin-test`)**. This guide details the supported actions, available overrides, and their specific impacts on your infrastructure.
|
|
2
|
+
|
|
3
|
+
### **Overview**
|
|
4
|
+
|
|
5
|
+
The Admin Test Endpoint is a privileged tool designed for **safe, isolated testing** of computations in production. It allows you to trigger runs manually, bypass scheduling locks, and—most importantly—**divert execution to test infrastructure** (custom tables or worker pools) to prevent polluting production data.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### **Global Overrides (Infrastructure Testing)**
|
|
10
|
+
|
|
11
|
+
These parameters can be applied to **`run`** and **`run_limited`** actions to redirect the execution flow.
|
|
12
|
+
|
|
13
|
+
| Parameter | Type | Description | Impact |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| **`outputTable`** | `string` | The BigQuery table where results will be written. | **Data Diversion**: Instead of writing to `computation_results_v3`, the Orchestrator writes to this table. Useful for validating logic without affecting production dashboards. |
|
|
16
|
+
| **`workerUrl`** | `string` | The URL of the worker Cloud Function to invoke. | **Traffic Diversion**: If the worker pool is used, the Orchestrator will send HTTP requests to this URL instead of the production worker. |
|
|
17
|
+
| **`useWorkerPool`** | `boolean` | Force enable/disable the remote worker pool. | **Execution Strategy**: <br>
|
|
18
|
+
|
|
19
|
+
<br>`true`: Forces remote execution (even for small batches).<br>
|
|
20
|
+
|
|
21
|
+
<br>`false`: Forces local execution (inside the Admin function).<br>
|
|
22
|
+
|
|
23
|
+
<br>`undefined`: Uses system default config. |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### **Supported Actions**
|
|
28
|
+
|
|
29
|
+
#### **1. `status**`
|
|
30
|
+
|
|
31
|
+
Returns the current system manifest, listing all registered computations and their schedules.
|
|
32
|
+
|
|
33
|
+
* **Configurables:** None.
|
|
34
|
+
* **Data Written:** None.
|
|
35
|
+
* **Impact:** Read-only. Low impact.
|
|
36
|
+
* **Cloud Functions:** `compute-admin-test` (Local).
|
|
37
|
+
|
|
38
|
+
#### **2. `analyze**`
|
|
39
|
+
|
|
40
|
+
Runs the "Scheduler Logic" for a specific date to determine what *would* run, without actually running it. Checks dependencies, hash changes, and locks.
|
|
41
|
+
|
|
42
|
+
* **Configurables:**
|
|
43
|
+
* `date` (YYYY-MM-DD): The target date to analyze.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
* **Data Written:** None.
|
|
47
|
+
* **Impact:** Read-only. Low impact.
|
|
48
|
+
* **Cloud Functions:** `compute-admin-test` (Local).
|
|
49
|
+
|
|
50
|
+
#### **3. `run**`
|
|
51
|
+
|
|
52
|
+
Executes a full computation for the specified date. This is the primary tool for manual triggers and backfills.
|
|
53
|
+
|
|
54
|
+
* **Configurables:**
|
|
55
|
+
* `computation` (Required): Name of the computation (e.g., `UserPortfolioSummary`).
|
|
56
|
+
* `date`: Target date (Default: Today).
|
|
57
|
+
* `entityIds` (Array): Run only for these specific entities.
|
|
58
|
+
* `force` (Boolean): If `true`, runs even if the code/data hasn't changed (Default: `true` for testing).
|
|
59
|
+
* `dryRun` (Boolean): If `true`, computes results but **does not write to BigQuery**.
|
|
60
|
+
* *Plus Global Overrides (`outputTable`, `workerUrl`, `useWorkerPool`)*.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
* **Data Written:**
|
|
64
|
+
* **Default:** Writes to `config.resultStore.table` (Production).
|
|
65
|
+
* **With `outputTable`:** Writes to the specified custom table.
|
|
66
|
+
* **With `dryRun`:** No data written.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
* **Impact:** High. Can trigger heavy BigQuery queries and write large amounts of data.
|
|
70
|
+
* **Cloud Functions:**
|
|
71
|
+
* **Local Mode:** `compute-admin-test` processes all logic.
|
|
72
|
+
* **Worker Pool Mode:** `compute-admin-test` acts as the Orchestrator; `computation-worker` (or `workerUrl`) executes the logic.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
#### **4. `run_limited**`
|
|
77
|
+
|
|
78
|
+
A safer version of `run` that automatically fetches a small sample of entities (e.g., 5 random users) and runs the computation only for them.
|
|
79
|
+
|
|
80
|
+
* **Configurables:**
|
|
81
|
+
* `computation` (Required): Name of computation.
|
|
82
|
+
* `limit` (Integer): Number of entities to test (Default: 10).
|
|
83
|
+
* *Plus Global Overrides (`outputTable`, `workerUrl`, `useWorkerPool`)*.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
* **Data Written:** Same behavior as `run`, but only for the sampled entities.
|
|
87
|
+
* **Impact:** Moderate. Executes real logic but on a strictly limited scope.
|
|
88
|
+
* **Cloud Functions:** Same as `run`.
|
|
89
|
+
|
|
90
|
+
#### **5. `test_worker**`
|
|
91
|
+
|
|
92
|
+
Directly tests the **logic** of a worker execution locally within the Admin function. This bypasses the Orchestrator's batching and storage logic, simulating exactly what happens inside a single worker instance.
|
|
93
|
+
|
|
94
|
+
* **Configurables:**
|
|
95
|
+
* `computation` (Required): Name of computation.
|
|
96
|
+
* `entityIds` (Required Array): Must provide at least one ID to test.
|
|
97
|
+
* `date`: Target date.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
* **Data Written:** **None**. The result is returned directly in the HTTP response body for inspection.
|
|
101
|
+
* **Impact:** Low. Fetches data for 1 entity and runs logic in-memory.
|
|
102
|
+
* **Cloud Functions:** `compute-admin-test` (Local only).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### **Summary of Data Flow**
|
|
107
|
+
|
|
108
|
+
| Scenario | Execution Location | Data Destination |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| **Standard Run** | `compute-admin-test` (Local) | `computation_results_v3` (Prod) |
|
|
111
|
+
| **Standard Run + Worker Pool** | `computation-worker` (Remote) | `computation_results_v3` (Prod) |
|
|
112
|
+
| **Run + `outputTable**` | `compute-admin-test` (Local) | **`YOUR_CUSTOM_TABLE`** |
|
|
113
|
+
| **Run + `workerUrl**` | **`worker-test`** (Remote) | `computation_results_v3` (Prod) |
|
|
114
|
+
| **Run + `dryRun**` | `compute-admin-test` (Local) | *None* |
|
|
115
|
+
| **Run + `outputTable` + `workerUrl**` | **`worker-test`** (Remote) | **`YOUR_CUSTOM_TABLE`** |
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# ==============================================================================
|
|
4
|
+
# Admin Test Endpoint Interactive Tool
|
|
5
|
+
# Automates the admin.md testing procedures
|
|
6
|
+
# ==============================================================================
|
|
7
|
+
|
|
8
|
+
# Default Settings
|
|
9
|
+
REGION="europe-west1"
|
|
10
|
+
FUNCTION_NAME="compute-admin-test"
|
|
11
|
+
DEFAULT_DATE=$(date +%Y-%m-%d)
|
|
12
|
+
|
|
13
|
+
# Colors
|
|
14
|
+
GREEN='\033[0;32m'
|
|
15
|
+
BLUE='\033[0;34m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
NC='\033[0m' # No Color
|
|
19
|
+
|
|
20
|
+
echo -e "${BLUE}=================================================${NC}"
|
|
21
|
+
echo -e "${BLUE} BullTrackers Admin Test Interactive Tool ${NC}"
|
|
22
|
+
echo -e "${BLUE}=================================================${NC}"
|
|
23
|
+
|
|
24
|
+
# ------------------------------------------------------------------------------
|
|
25
|
+
# 1. Setup & Auth
|
|
26
|
+
# ------------------------------------------------------------------------------
|
|
27
|
+
echo -e "\n${YELLOW}[Setup] Retrieving Function URL and Auth Token...${NC}"
|
|
28
|
+
|
|
29
|
+
# Get Function URL
|
|
30
|
+
FUNCTION_URL=$(gcloud functions describe $FUNCTION_NAME \
|
|
31
|
+
--region=$REGION \
|
|
32
|
+
--format="value(serviceConfig.uri)" 2>/dev/null)
|
|
33
|
+
|
|
34
|
+
if [ -z "$FUNCTION_URL" ]; then
|
|
35
|
+
echo -e "${RED}[Error] Could not retrieve Function URL for '$FUNCTION_NAME' in '$REGION'.${NC}"
|
|
36
|
+
echo "Please ensure you are authenticated (gcloud auth login) and the function is deployed."
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Get Identity Token
|
|
41
|
+
TOKEN=$(gcloud auth print-identity-token 2>/dev/null)
|
|
42
|
+
|
|
43
|
+
if [ -z "$TOKEN" ]; then
|
|
44
|
+
echo -e "${RED}[Error] Could not generate Identity Token.${NC}"
|
|
45
|
+
echo "Please run: gcloud auth login"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
echo -e "${GREEN}[Success] Target: $FUNCTION_URL${NC}"
|
|
50
|
+
|
|
51
|
+
# ------------------------------------------------------------------------------
|
|
52
|
+
# 2. Helper Functions
|
|
53
|
+
# ------------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
# Function to prompt for variables with defaults
|
|
56
|
+
ask_var() {
|
|
57
|
+
local prompt="$1"
|
|
58
|
+
local default="$2"
|
|
59
|
+
local var_name="$3"
|
|
60
|
+
|
|
61
|
+
echo -ne "$prompt [${GREEN}$default${NC}]: "
|
|
62
|
+
read input
|
|
63
|
+
if [ -z "$input" ]; then
|
|
64
|
+
eval $var_name="$default"
|
|
65
|
+
else
|
|
66
|
+
eval $var_name="$input"
|
|
67
|
+
fi
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Function to execute the curl command
|
|
71
|
+
run_test() {
|
|
72
|
+
local json_payload="$1"
|
|
73
|
+
|
|
74
|
+
echo -e "\n${YELLOW}[Executing] Sending Request...${NC}"
|
|
75
|
+
echo -e "Payload: $json_payload"
|
|
76
|
+
|
|
77
|
+
curl -X POST "$FUNCTION_URL" \
|
|
78
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
79
|
+
-H "Content-Type: application/json" \
|
|
80
|
+
-d "$json_payload"
|
|
81
|
+
|
|
82
|
+
echo -e "\n${BLUE}[Done]${NC}"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# ------------------------------------------------------------------------------
|
|
86
|
+
# 3. Interactive Menu
|
|
87
|
+
# ------------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
while true; do
|
|
90
|
+
echo -e "\n${BLUE}Select an Action:${NC}"
|
|
91
|
+
echo "1) System Status (status)"
|
|
92
|
+
echo "2) Analyze Schedule (analyze)"
|
|
93
|
+
echo "3) Run Full Computation (run)"
|
|
94
|
+
echo "4) Run Limited Test (run_limited - safer)"
|
|
95
|
+
echo "5) Test Specific Entities (run with entityIds)"
|
|
96
|
+
echo "6) Test Worker Logic Directly (test_worker)"
|
|
97
|
+
echo "7) Test Worker Pool Offloading (run with useWorkerPool)"
|
|
98
|
+
echo "8) Advanced Infrastructure Test (Custom Table/Worker)"
|
|
99
|
+
echo "q) Quit"
|
|
100
|
+
|
|
101
|
+
read -p "Enter choice: " choice
|
|
102
|
+
|
|
103
|
+
case $choice in
|
|
104
|
+
1)
|
|
105
|
+
# Status
|
|
106
|
+
run_test '{"action": "status"}'
|
|
107
|
+
;;
|
|
108
|
+
|
|
109
|
+
2)
|
|
110
|
+
# Analyze
|
|
111
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
112
|
+
run_test "{\"action\": \"analyze\", \"date\": \"$TARGET_DATE\"}"
|
|
113
|
+
;;
|
|
114
|
+
|
|
115
|
+
3)
|
|
116
|
+
# Run Full
|
|
117
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
118
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
119
|
+
|
|
120
|
+
# Confirm dangerous action
|
|
121
|
+
echo -e "${RED}WARNING: This will run '$COMP_NAME' for ALL entities.${NC}"
|
|
122
|
+
read -p "Are you sure? (y/N): " confirm
|
|
123
|
+
if [[ $confirm == "y" || $confirm == "Y" ]]; then
|
|
124
|
+
run_test "{\"action\": \"run\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"force\": true}"
|
|
125
|
+
else
|
|
126
|
+
echo "Cancelled."
|
|
127
|
+
fi
|
|
128
|
+
;;
|
|
129
|
+
|
|
130
|
+
4)
|
|
131
|
+
# Run Limited
|
|
132
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
133
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
134
|
+
ask_var "Enter Limit (Num Entities)" "5" "LIMIT_NUM"
|
|
135
|
+
|
|
136
|
+
run_test "{\"action\": \"run_limited\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"limit\": $LIMIT_NUM}"
|
|
137
|
+
;;
|
|
138
|
+
|
|
139
|
+
5)
|
|
140
|
+
# Test Entities
|
|
141
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
142
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
143
|
+
ask_var "Enter Entity IDs (comma separated, no spaces)" "user-123,user-456" "RAW_IDS"
|
|
144
|
+
|
|
145
|
+
# Format IDs into JSON array
|
|
146
|
+
IFS=',' read -r -a id_array <<< "$RAW_IDS"
|
|
147
|
+
JSON_IDS=$(printf '"%s",' "${id_array[@]}")
|
|
148
|
+
JSON_IDS="[${JSON_IDS%,}]"
|
|
149
|
+
|
|
150
|
+
run_test "{\"action\": \"run\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"entityIds\": $JSON_IDS, \"force\": true}"
|
|
151
|
+
;;
|
|
152
|
+
|
|
153
|
+
6)
|
|
154
|
+
# Test Worker Logic
|
|
155
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
156
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
157
|
+
ask_var "Enter Single Entity ID" "user-123" "ENTITY_ID"
|
|
158
|
+
|
|
159
|
+
# Worker test expects array of entityIds
|
|
160
|
+
run_test "{\"action\": \"test_worker\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"entityIds\": [\"$ENTITY_ID\"]}"
|
|
161
|
+
;;
|
|
162
|
+
|
|
163
|
+
7)
|
|
164
|
+
# Test Worker Pool
|
|
165
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
166
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
167
|
+
|
|
168
|
+
echo -e "${YELLOW}Running with Worker Pool enabled...${NC}"
|
|
169
|
+
run_test "{\"action\": \"run\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"useWorkerPool\": true, \"force\": true}"
|
|
170
|
+
;;
|
|
171
|
+
|
|
172
|
+
8)
|
|
173
|
+
# Advanced Infrastructure Test (Custom Table & Worker)
|
|
174
|
+
echo -e "${YELLOW}--- Infrastructure Integration Test ---${NC}"
|
|
175
|
+
ask_var "Enter Computation Name" "UserPortfolioSummary" "COMP_NAME"
|
|
176
|
+
ask_var "Enter Date" "$DEFAULT_DATE" "TARGET_DATE"
|
|
177
|
+
ask_var "Enter Output Table Name" "computation_results_test" "OUT_TABLE"
|
|
178
|
+
ask_var "Enter Custom Worker URL (optional)" "" "WORKER_URL"
|
|
179
|
+
ask_var "Use Worker Pool? (true/false)" "true" "USE_POOL"
|
|
180
|
+
ask_var "Entity Limit (0 for Full Run)" "10" "LIMIT_NUM"
|
|
181
|
+
|
|
182
|
+
# Determine Action (run vs run_limited)
|
|
183
|
+
if [ "$LIMIT_NUM" -gt 0 ]; then
|
|
184
|
+
ACTION="run_limited"
|
|
185
|
+
LIMIT_PART=", \"limit\": $LIMIT_NUM"
|
|
186
|
+
else
|
|
187
|
+
ACTION="run"
|
|
188
|
+
LIMIT_PART=", \"force\": true"
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
# Build Optional JSON Parts
|
|
192
|
+
TABLE_PART=""
|
|
193
|
+
if [ ! -z "$OUT_TABLE" ]; then
|
|
194
|
+
TABLE_PART=", \"outputTable\": \"$OUT_TABLE\""
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
WORKER_PART=""
|
|
198
|
+
if [ ! -z "$WORKER_URL" ]; then
|
|
199
|
+
WORKER_PART=", \"workerUrl\": \"$WORKER_URL\""
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
echo -e "${YELLOW}Running ${ACTION} on ${OUT_TABLE}...${NC}"
|
|
203
|
+
|
|
204
|
+
# Construct Payload
|
|
205
|
+
# We use loose concatenation here which works fine for JSON string building in bash
|
|
206
|
+
JSON="{\"action\": \"$ACTION\", \"computation\": \"$COMP_NAME\", \"date\": \"$TARGET_DATE\", \"useWorkerPool\": $USE_POOL $LIMIT_PART $TABLE_PART $WORKER_PART}"
|
|
207
|
+
|
|
208
|
+
run_test "$JSON"
|
|
209
|
+
;;
|
|
210
|
+
|
|
211
|
+
q|Q)
|
|
212
|
+
echo "Exiting."
|
|
213
|
+
exit 0
|
|
214
|
+
;;
|
|
215
|
+
|
|
216
|
+
*)
|
|
217
|
+
echo -e "${RED}Invalid option.${NC}"
|
|
218
|
+
;;
|
|
219
|
+
esac
|
|
220
|
+
|
|
221
|
+
echo -e "\n-------------------------------------------------"
|
|
222
|
+
read -p "Press Enter to continue..."
|
|
223
|
+
done
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Main entry point for the Bulltrackers shared module.
|
|
3
3
|
* CLEANED: Removed legacy V1 Dispatcher/Computation references.
|
|
4
|
+
* UPDATED: Re-integrated Dispatcher (Task Throttler).
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
// Core utilities
|
|
@@ -21,7 +22,6 @@ const { checkDiscoveryNeed, getDiscoveryCandidates, dispatchDiscovery } = requir
|
|
|
21
22
|
const { getUpdateTargets, dispatchUpdates } = require('./functions/orchestrator/helpers/update_helpers');
|
|
22
23
|
|
|
23
24
|
// --- COMPUTATION SYSTEM V2 (The new standard) ---
|
|
24
|
-
// We import the WHOLE package now, which includes handlers AND ManifestBuilder
|
|
25
25
|
const computationSystemV2 = require('./functions/computation-system-v2/index');
|
|
26
26
|
|
|
27
27
|
// Task Engine
|
|
@@ -30,6 +30,9 @@ const { handleDiscover } = require('./functions
|
|
|
30
30
|
const { handleVerify } = require('./functions/task-engine/helpers/verify_helpers');
|
|
31
31
|
const { handleUpdate } = require('./functions/task-engine/helpers/update_helpers');
|
|
32
32
|
|
|
33
|
+
// Dispatcher (Task Throttler)
|
|
34
|
+
const { handleRequest: dispatcherRequest } = require('./functions/dispatcher/index');
|
|
35
|
+
|
|
33
36
|
const { createApiV2App } = require('./functions/api-v2/index');
|
|
34
37
|
|
|
35
38
|
// Maintenance & Backfills
|
|
@@ -76,7 +79,9 @@ const orchestrator = {
|
|
|
76
79
|
dispatchUpdates,
|
|
77
80
|
};
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
const dispatcher = {
|
|
83
|
+
handleRequest: dispatcherRequest
|
|
84
|
+
};
|
|
80
85
|
|
|
81
86
|
const taskEngine = {
|
|
82
87
|
handleRequest: taskRequest,
|
|
@@ -85,7 +90,7 @@ const taskEngine = {
|
|
|
85
90
|
handleUpdate,
|
|
86
91
|
};
|
|
87
92
|
|
|
88
|
-
const computationSystem = computationSystemV2;
|
|
93
|
+
const computationSystem = computationSystemV2;
|
|
89
94
|
|
|
90
95
|
const api = {
|
|
91
96
|
createApiV2App,
|
|
@@ -119,5 +124,5 @@ const alertSystem = {
|
|
|
119
124
|
};
|
|
120
125
|
|
|
121
126
|
module.exports = {
|
|
122
|
-
pipe: { core, orchestrator, taskEngine, computationSystem, api, maintenance, proxy, alertSystem },
|
|
127
|
+
pipe: { core, orchestrator, dispatcher, taskEngine, computationSystem, api, maintenance, proxy, alertSystem },
|
|
123
128
|
};
|