Skip to content

Commit 66b74e9

Browse files
move all providers to use fasthttp even for streaming
1 parent b99f41c commit 66b74e9

File tree

125 files changed

+1240
-950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1240
-950
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ go.work.sum
3535
*.db-shm
3636
*.db-wal
3737

38+
# Test reports
39+
test-reports/
40+
3841
.claude

Makefile

Lines changed: 210 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ help: ## Show this help message
3434
@echo " HOST Server host (default: localhost)"
3535
@echo " PORT Server port (default: 8080)"
3636
@echo " PROMETHEUS_LABELS Labels for Prometheus metrics"
37-
@echo " LOG_STYLE Logger output format: json|pretty (default: json)"
38-
@echo " LOG_LEVEL Logger level: debug|info|warn|error (default: info)"
37+
@echo " LOG_STYLE Logger output format: json|pretty (default: json)"
38+
@echo " LOG_LEVEL Logger level: debug|info|warn|error (default: info)"
3939
@echo " APP_DIR App data directory inside container (default: /app/data)"
40+
@echo ""
41+
@echo "$(YELLOW)Test Configuration:$(NC)"
42+
@echo " TEST_REPORTS_DIR Directory for HTML test reports (default: test-reports)"
43+
@echo " GOTESTSUM_FORMAT Test output format: testname|dots|pkgname|standard-verbose (default: testname)"
4044

4145
cleanup-enterprise: ## Clean up enterprise directories if present
4246
@echo "$(GREEN)Cleaning up enterprise...$(NC)"
@@ -55,6 +59,28 @@ install-air: ## Install air for hot reloading (if not already installed)
5559
@which air > /dev/null || (echo "$(YELLOW)Installing air for hot reloading...$(NC)" && go install github.com/air-verse/air@latest)
5660
@echo "$(GREEN)Air is ready$(NC)"
5761

62+
install-gotestsum: ## Install gotestsum for test reporting (if not already installed)
63+
@which gotestsum > /dev/null || (echo "$(YELLOW)Installing gotestsum for test reporting...$(NC)" && go install gotest.tools/gotestsum@latest)
64+
@echo "$(GREEN)gotestsum is ready$(NC)"
65+
66+
install-junit-viewer: ## Install junit-viewer for HTML report generation (if not already installed)
67+
@if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
68+
if which junit-viewer > /dev/null 2>&1; then \
69+
echo "$(GREEN)junit-viewer is already installed$(NC)"; \
70+
else \
71+
echo "$(YELLOW)Installing junit-viewer for HTML reports...$(NC)"; \
72+
if npm install -g junit-viewer 2>&1; then \
73+
echo "$(GREEN)junit-viewer installed successfully$(NC)"; \
74+
else \
75+
echo "$(RED)Failed to install junit-viewer. HTML reports will be skipped.$(NC)"; \
76+
echo "$(YELLOW)You can install it manually: npm install -g junit-viewer$(NC)"; \
77+
exit 0; \
78+
fi; \
79+
fi \
80+
else \
81+
echo "$(YELLOW)CI environment detected, skipping junit-viewer installation$(NC)"; \
82+
fi
83+
5884
dev: install-ui install-air setup-workspace ## Start complete development environment (UI + API with proxy)
5985
@echo "$(GREEN)Starting Bifrost complete development environment...$(NC)"
6086
@echo "$(YELLOW)This will start:$(NC)"
@@ -114,25 +140,201 @@ clean: ## Clean build artifacts and temporary files
114140
@rm -rf tmp/
115141
@rm -f transports/bifrost-http/build-errors.log
116142
@rm -rf transports/bifrost-http/tmp/
143+
@rm -rf $(TEST_REPORTS_DIR)/
117144
@echo "$(GREEN)Clean complete$(NC)"
118145

119-
test: ## Run tests for bifrost-http
146+
clean-test-reports: ## Clean test reports only
147+
@echo "$(YELLOW)Cleaning test reports...$(NC)"
148+
@rm -rf $(TEST_REPORTS_DIR)/
149+
@echo "$(GREEN)Test reports cleaned$(NC)"
150+
151+
generate-html-reports: ## Convert existing XML reports to HTML
152+
@if ! which junit-viewer > /dev/null 2>&1; then \
153+
echo "$(RED)Error: junit-viewer not installed$(NC)"; \
154+
echo "$(YELLOW)Install with: make install-junit-viewer$(NC)"; \
155+
exit 1; \
156+
fi
157+
@echo "$(GREEN)Converting XML reports to HTML...$(NC)"
158+
@if [ ! -d "$(TEST_REPORTS_DIR)" ] || [ -z "$$(ls -A $(TEST_REPORTS_DIR)/*.xml 2>/dev/null)" ]; then \
159+
echo "$(YELLOW)No XML reports found in $(TEST_REPORTS_DIR)$(NC)"; \
160+
echo "$(YELLOW)Run tests first: make test-all$(NC)"; \
161+
exit 0; \
162+
fi
163+
@for xml in $(TEST_REPORTS_DIR)/*.xml; do \
164+
html=$${xml%.xml}.html; \
165+
echo " Converting $$(basename $$xml) → $$(basename $$html)"; \
166+
junit-viewer --results=$$xml --save=$$html 2>/dev/null || true; \
167+
done
168+
@echo ""
169+
@echo "$(GREEN)✓ HTML reports generated$(NC)"
170+
@echo "$(CYAN)View reports:$(NC)"
171+
@ls -1 $(TEST_REPORTS_DIR)/*.html 2>/dev/null | sed 's|$(TEST_REPORTS_DIR)/| open $(TEST_REPORTS_DIR)/|' || true
172+
173+
test: install-gotestsum ## Run tests for bifrost-http
120174
@echo "$(GREEN)Running bifrost-http tests...$(NC)"
121-
@cd transports/bifrost-http && GOWORK=off go test -v ./...
175+
@mkdir -p $(TEST_REPORTS_DIR)
176+
@cd transports/bifrost-http && GOWORK=off gotestsum \
177+
--format=$(GOTESTSUM_FORMAT) \
178+
--junitfile=../../$(TEST_REPORTS_DIR)/bifrost-http.xml \
179+
-- -v ./...
180+
@if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
181+
if which junit-viewer > /dev/null 2>&1; then \
182+
echo "$(YELLOW)Generating HTML report...$(NC)"; \
183+
if junit-viewer --results=$(TEST_REPORTS_DIR)/bifrost-http.xml --save=$(TEST_REPORTS_DIR)/bifrost-http.html 2>/dev/null; then \
184+
echo ""; \
185+
echo "$(CYAN)HTML report: $(TEST_REPORTS_DIR)/bifrost-http.html$(NC)"; \
186+
echo "$(CYAN)Open with: open $(TEST_REPORTS_DIR)/bifrost-http.html$(NC)"; \
187+
else \
188+
echo "$(YELLOW)HTML generation failed. JUnit XML report available.$(NC)"; \
189+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/bifrost-http.xml$(NC)"; \
190+
fi; \
191+
else \
192+
echo ""; \
193+
echo "$(YELLOW)junit-viewer not installed. Install with: make install-junit-viewer$(NC)"; \
194+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/bifrost-http.xml$(NC)"; \
195+
fi \
196+
else \
197+
echo ""; \
198+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/bifrost-http.xml$(NC)"; \
199+
fi
122200

123-
test-core: ## Run core tests
201+
test-core: install-gotestsum ## Run core tests (Usage: make test-core PROVIDER=anthropic TESTCASE=SimpleChat)
124202
@echo "$(GREEN)Running core tests...$(NC)"
125-
@cd core && go test -v ./...
203+
@mkdir -p $(TEST_REPORTS_DIR)
204+
@if [ -n "$(PROVIDER)" ]; then \
205+
echo "$(CYAN)Running tests for provider: $(PROVIDER)$(NC)"; \
206+
if [ ! -f "tests/core-providers/$(PROVIDER)_test.go" ]; then \
207+
echo "$(RED)Error: Provider test file '$(PROVIDER)_test.go' not found$(NC)"; \
208+
echo "$(YELLOW)Available providers:$(NC)"; \
209+
ls tests/core-providers/*_test.go 2>/dev/null | grep -v cross_provider | xargs -n 1 basename | sed 's/_test\.go//' | sed 's/^/ - /'; \
210+
exit 1; \
211+
fi; \
212+
fi; \
213+
if [ -f .env ]; then \
214+
echo "$(YELLOW)Loading environment variables from .env...$(NC)"; \
215+
set -a; . ./.env; set +a; \
216+
fi; \
217+
if [ -n "$(PROVIDER)" ]; then \
218+
PROVIDER_TEST_NAME=$$(echo "$(PROVIDER)" | awk '{print toupper(substr($$0,1,1)) tolower(substr($$0,2))}' | sed 's/openai/OpenAI/i; s/sgl/SGL/i'); \
219+
if [ -n "$(TESTCASE)" ]; then \
220+
echo "$(CYAN)Running Test$${PROVIDER_TEST_NAME}/$${PROVIDER_TEST_NAME}Tests/$(TESTCASE)...$(NC)"; \
221+
cd tests/core-providers && GOWORK=off gotestsum \
222+
--format=$(GOTESTSUM_FORMAT) \
223+
--junitfile=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).xml \
224+
-- -v -run "^Test$${PROVIDER_TEST_NAME}$$/.*Tests/$(TESTCASE)$$"; \
225+
if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
226+
if which junit-viewer > /dev/null 2>&1; then \
227+
echo "$(YELLOW)Generating HTML report...$(NC)"; \
228+
junit-viewer --results=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).xml --save=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).html 2>/dev/null || true; \
229+
echo ""; \
230+
echo "$(CYAN)HTML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).html$(NC)"; \
231+
echo "$(CYAN)Open with: open $(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).html$(NC)"; \
232+
else \
233+
echo ""; \
234+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).xml$(NC)"; \
235+
fi; \
236+
else \
237+
echo ""; \
238+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER)-$(TESTCASE).xml$(NC)"; \
239+
fi; \
240+
else \
241+
echo "$(CYAN)Running Test$${PROVIDER_TEST_NAME}...$(NC)"; \
242+
cd tests/core-providers && GOWORK=off gotestsum \
243+
--format=$(GOTESTSUM_FORMAT) \
244+
--junitfile=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER).xml \
245+
-- -v -run "^Test$${PROVIDER_TEST_NAME}$$"; \
246+
if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
247+
if which junit-viewer > /dev/null 2>&1; then \
248+
echo "$(YELLOW)Generating HTML report...$(NC)"; \
249+
junit-viewer --results=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER).xml --save=../../$(TEST_REPORTS_DIR)/core-$(PROVIDER).html 2>/dev/null || true; \
250+
echo ""; \
251+
echo "$(CYAN)HTML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER).html$(NC)"; \
252+
echo "$(CYAN)Open with: open $(TEST_REPORTS_DIR)/core-$(PROVIDER).html$(NC)"; \
253+
else \
254+
echo ""; \
255+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER).xml$(NC)"; \
256+
fi; \
257+
else \
258+
echo ""; \
259+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-$(PROVIDER).xml$(NC)"; \
260+
fi; \
261+
fi \
262+
else \
263+
if [ -n "$(TESTCASE)" ]; then \
264+
echo "$(RED)Error: TESTCASE requires PROVIDER to be specified$(NC)"; \
265+
echo "$(YELLOW)Usage: make test-core PROVIDER=anthropic TESTCASE=SimpleChat$(NC)"; \
266+
exit 1; \
267+
fi; \
268+
cd tests/core-providers && GOWORK=off gotestsum \
269+
--format=$(GOTESTSUM_FORMAT) \
270+
--junitfile=../../$(TEST_REPORTS_DIR)/core-all.xml \
271+
-- -v ./...; \
272+
if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
273+
if which junit-viewer > /dev/null 2>&1; then \
274+
echo "$(YELLOW)Generating HTML report...$(NC)"; \
275+
junit-viewer --results=../../$(TEST_REPORTS_DIR)/core-all.xml --save=../../$(TEST_REPORTS_DIR)/core-all.html 2>/dev/null || true; \
276+
echo ""; \
277+
echo "$(CYAN)HTML report: $(TEST_REPORTS_DIR)/core-all.html$(NC)"; \
278+
echo "$(CYAN)Open with: open $(TEST_REPORTS_DIR)/core-all.html$(NC)"; \
279+
else \
280+
echo ""; \
281+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-all.xml$(NC)"; \
282+
fi; \
283+
else \
284+
echo ""; \
285+
echo "$(CYAN)JUnit XML report: $(TEST_REPORTS_DIR)/core-all.xml$(NC)"; \
286+
fi; \
287+
fi
126288

127-
test-plugins: ## Run plugin tests
289+
test-plugins: install-gotestsum ## Run plugin tests
128290
@echo "$(GREEN)Running plugin tests...$(NC)"
291+
@mkdir -p $(TEST_REPORTS_DIR)
129292
@cd plugins && find . -name "*.go" -path "*/tests/*" -o -name "*_test.go" | head -1 > /dev/null && \
130293
for dir in $$(find . -name "*_test.go" -exec dirname {} \; | sort -u); do \
294+
plugin_name=$$(echo $$dir | sed 's|^\./||' | sed 's|/|-|g'); \
131295
echo "Testing $$dir..."; \
132-
cd $$dir && go test -v ./... && cd - > /dev/null; \
296+
cd $$dir && gotestsum \
297+
--format=$(GOTESTSUM_FORMAT) \
298+
--junitfile=../../$(TEST_REPORTS_DIR)/plugin-$$plugin_name.xml \
299+
-- -v ./... && cd - > /dev/null; \
300+
if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
301+
if which junit-viewer > /dev/null 2>&1; then \
302+
echo "$(YELLOW)Generating HTML report for $$plugin_name...$(NC)"; \
303+
junit-viewer --results=../$(TEST_REPORTS_DIR)/plugin-$$plugin_name.xml --save=../$(TEST_REPORTS_DIR)/plugin-$$plugin_name.html 2>/dev/null || true; \
304+
fi; \
305+
fi; \
133306
done || echo "No plugin tests found"
307+
@echo ""
308+
@if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
309+
echo "$(CYAN)HTML reports saved to $(TEST_REPORTS_DIR)/plugin-*.html$(NC)"; \
310+
else \
311+
echo "$(CYAN)JUnit XML reports saved to $(TEST_REPORTS_DIR)/plugin-*.xml$(NC)"; \
312+
fi
134313

135314
test-all: test-core test-plugins test ## Run all tests
315+
@echo ""
316+
@echo "$(GREEN)═══════════════════════════════════════════════════════════$(NC)"
317+
@echo "$(GREEN) All Tests Complete - Summary $(NC)"
318+
@echo "$(GREEN)═══════════════════════════════════════════════════════════$(NC)"
319+
@echo ""
320+
@if [ -z "$$CI" ] && [ -z "$$GITHUB_ACTIONS" ] && [ -z "$$GITLAB_CI" ] && [ -z "$$CIRCLECI" ] && [ -z "$$JENKINS_HOME" ]; then \
321+
echo "$(YELLOW)Generating combined HTML report...$(NC)"; \
322+
junit-viewer --results=$(TEST_REPORTS_DIR) --save=$(TEST_REPORTS_DIR)/index.html 2>/dev/null || true; \
323+
echo ""; \
324+
echo "$(CYAN)HTML reports available in $(TEST_REPORTS_DIR)/:$(NC)"; \
325+
ls -1 $(TEST_REPORTS_DIR)/*.html 2>/dev/null | sed 's/^/ ✓ /' || echo " No reports found"; \
326+
echo ""; \
327+
echo "$(YELLOW)📊 View all test results:$(NC)"; \
328+
echo "$(CYAN) open $(TEST_REPORTS_DIR)/index.html$(NC)"; \
329+
echo ""; \
330+
echo "$(YELLOW)Or view individual reports:$(NC)"; \
331+
ls -1 $(TEST_REPORTS_DIR)/*.html 2>/dev/null | grep -v index.html | sed 's|$(TEST_REPORTS_DIR)/| open $(TEST_REPORTS_DIR)/|' || true; \
332+
echo ""; \
333+
else \
334+
echo "$(CYAN)JUnit XML reports available in $(TEST_REPORTS_DIR)/:$(NC)"; \
335+
ls -1 $(TEST_REPORTS_DIR)/*.xml 2>/dev/null | sed 's/^/ ✓ /' || echo " No reports found"; \
336+
echo ""; \
337+
fi
136338

137339
# Quick start with example config
138340
quick-start: ## Quick start with example config and maxim plugin

core/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/aws/aws-sdk-go-v2 v1.39.3
99
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.2
1010
github.com/aws/aws-sdk-go-v2/config v1.31.13
11+
github.com/aws/smithy-go v1.23.1
1112
github.com/bytedance/sonic v1.14.1
1213
github.com/google/uuid v1.6.0
1314
github.com/mark3labs/mcp-go v0.41.1
@@ -29,7 +30,6 @@ require (
2930
github.com/aws/aws-sdk-go-v2/service/sso v1.29.7 // indirect
3031
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.2 // indirect
3132
github.com/aws/aws-sdk-go-v2/service/sts v1.38.7 // indirect
32-
github.com/aws/smithy-go v1.23.1 // indirect
3333
github.com/bahlo/generic-list-go v0.2.0 // indirect
3434
github.com/buger/jsonparser v1.1.1 // indirect
3535
github.com/bytedance/gopkg v0.1.3 // indirect

0 commit comments

Comments
 (0)