Skip to content

Commit 7baef05

Browse files
masayagclaude
andcommitted
Improve test-k8s-dataflow.sh with proper manifest.json format
Enhanced the test script to create a proper manifest.json file that matches the expected format for insights-ros-ingress uploads. This addresses upload processing issues and ensures compatibility with the ingress service. Changes: - Generate UUID-based filenames following the pattern {uuid}_openshift_usage_report.{number}.csv - Create comprehensive manifest.json with all required metadata fields - Include manifest.json in the upload archive alongside CSV files - Add cluster metadata and configuration details to match expected format This improves the test coverage for the insights-ros-ingress upload functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b744925 commit 7baef05

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

deployment/kubernetes/scripts/test-k8s-dataflow.sh

100644100755
Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ upload_test_data() {
119119

120120
local test_csv=$(create_test_data)
121121
local test_dir=$(mktemp -d)
122-
local csv_filename="openshift_usage_report.csv"
122+
local uuid=$(uuidgen | tr '[:upper:]' '[:lower:]')
123+
local csv_filename="${uuid}_openshift_usage_report.0.csv"
123124
local tar_filename="cost-mgmt.tar.gz"
124125

125126
# Copy CSV to temporary directory with expected filename
@@ -130,9 +131,79 @@ upload_test_data() {
130131
return 1
131132
fi
132133

134+
# Create manifest.json file (required by insights-ros-ingress)
135+
local manifest_json="$test_dir/manifest.json"
136+
local cluster_id=$(uuidgen | tr '[:upper:]' '[:lower:]')
137+
local current_date=$(date -u +"%Y-%m-%dT%H:%M:%S.%NZ")
138+
local start_date=$(date -u +"%Y-%m-%dT%H:00:00Z")
139+
local end_date=$(date -u +"%Y-%m-%dT%H:59:59Z")
140+
141+
cat > "$manifest_json" << EOF
142+
{
143+
"uuid": "$uuid",
144+
"cluster_id": "$cluster_id",
145+
"version": "test-version",
146+
"date": "$current_date",
147+
"files": [
148+
"$csv_filename"
149+
],
150+
"start": "$start_date",
151+
"end": "$end_date",
152+
"cr_status": {
153+
"clusterID": "$cluster_id",
154+
"clusterVersion": "test-4.10",
155+
"api_url": "http://localhost:30080",
156+
"authentication": {
157+
"type": "bearer",
158+
"secret_name": "test-auth-secret",
159+
"credentials_found": true
160+
},
161+
"packaging": {
162+
"last_successful_packaging_time": null,
163+
"max_reports_to_store": 30,
164+
"max_size_MB": 100,
165+
"number_reports_stored": 1
166+
},
167+
"upload": {
168+
"ingress_path": "/api/ingress/v1/upload",
169+
"upload": true,
170+
"upload_wait": 30,
171+
"upload_cycle": 360,
172+
"last_successful_upload_time": null,
173+
"validate_cert": false
174+
},
175+
"operator_commit": "test-commit",
176+
"prometheus": {
177+
"prometheus_configured": true,
178+
"prometheus_connected": true,
179+
"context_timeout": 120,
180+
"last_query_start_time": "$current_date",
181+
"last_query_success_time": "$current_date",
182+
"service_address": "https://prometheus-test",
183+
"skip_tls_verification": true
184+
},
185+
"reports": {
186+
"report_month": "$(date +%m)",
187+
"last_hour_queried": "$start_date - $end_date",
188+
"data_collected": true
189+
},
190+
"source": {
191+
"sources_path": "/api/sources/v1.0/",
192+
"create_source": false,
193+
"last_check_time": null,
194+
"check_cycle": 1440
195+
},
196+
"storage": {}
197+
},
198+
"certified": false
199+
}
200+
EOF
201+
202+
echo_info "Created manifest.json with cluster_id: $cluster_id"
203+
133204
# Create tar.gz file (insights-ros-ingress will extract this automatically)
134205
echo_info "Creating HCCM tar.gz archive for insights-ros-ingress..."
135-
if ! (cd "$test_dir" && tar -czf "$tar_filename" "$csv_filename"); then
206+
if ! (cd "$test_dir" && tar -czf "$tar_filename" "$csv_filename" "manifest.json"); then
136207
echo_error "Failed to create tar.gz archive"
137208
rm -f "$test_csv"
138209
rm -rf "$test_dir"

0 commit comments

Comments
 (0)