more fixes before final part
All checks were successful
Unit Tests / unit-tests (pull_request) Successful in 9m58s
Integration Tests / integration-tests (pull_request) Successful in 9m58s

This commit is contained in:
Tanishq Dubey 2025-05-18 11:35:22 -04:00
parent 8f90c1b16d
commit 92fb052594
No known key found for this signature in database
GPG Key ID: CFC1931B84DFC3F9
5 changed files with 51 additions and 45 deletions

View File

@ -18,7 +18,7 @@ clean:
# Run all tests
test: generate
@echo "Running all tests..."
@go test -v -count=1 ./... --coverprofile=coverage.out
@go test -v -count=1 ./... --coverprofile=coverage.out --short
# Run unit tests only (faster, no integration tests)
test-unit:

View File

@ -11,6 +11,7 @@ import (
"syscall"
"time"
"git.dws.rip/dubey/kat/internal/agent"
"git.dws.rip/dubey/kat/internal/api"
"git.dws.rip/dubey/kat/internal/cli"
"git.dws.rip/dubey/kat/internal/config"

View File

@ -125,13 +125,13 @@ func (a *Agent) SetupMTLSClient() error {
// Override the dial function to map any hostname to the leader's IP
DialTLS: func(network, addr string) (net.Conn, error) {
// Extract host and port from addr
host, port, err := net.SplitHostPort(addr)
_, port, err := net.SplitHostPort(addr)
if err != nil {
return nil, err
}
// Extract host and port from LeaderAPI
leaderHost, leaderPort, err := net.SplitHostPort(a.LeaderAPI)
leaderHost, _, err := net.SplitHostPort(a.LeaderAPI)
if err != nil {
return nil, err
}
@ -211,8 +211,13 @@ func (a *Agent) sendHeartbeat() error {
return fmt.Errorf("failed to marshal node status: %w", err)
}
leaderHost, leaderPort, err := net.SplitHostPort(a.LeaderAPI)
if err != nil {
return err
}
// Construct URL - use leader.kat.cluster.local as hostname to match certificate
url := fmt.Sprintf("https://leader.kat.cluster.local/v1alpha1/nodes/%s/status", a.NodeName)
url := fmt.Sprintf("https://%s:%s/v1alpha1/nodes/%s/status", leaderHost, leaderPort, a.NodeName)
// Create request
req, err := http.NewRequest("POST", url, bytes.NewBuffer(statusJSON))

View File

@ -13,6 +13,8 @@ import (
"testing"
"time"
"crypto/x509/pkix"
"git.dws.rip/dubey/kat/internal/pki"
)

View File

@ -2,14 +2,12 @@ package api
import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"time"
"git.dws.rip/dubey/kat/internal/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)