fix: Suite endpoint listed as standalone endpoint (#1276)
This commit is contained in:
@@ -303,36 +303,37 @@ func TestStore_MixedEndpointsAndSuites(t *testing.T) {
|
|||||||
|
|
||||||
// Test 3: GetAllEndpointStatuses should only return endpoints, not suites
|
// Test 3: GetAllEndpointStatuses should only return endpoints, not suites
|
||||||
t.Run("GetAllEndpointStatuses", func(t *testing.T) {
|
t.Run("GetAllEndpointStatuses", func(t *testing.T) {
|
||||||
store, endpoint1, endpoint2, suiteEndpoint1, suiteEndpoint2, testSuite := setupStore(t)
|
store, endpoint1, endpoint2, _, _, testSuite := setupStore(t)
|
||||||
|
|
||||||
// InsertEndpointResult all test data
|
// Insert standalone endpoint results only
|
||||||
store.InsertEndpointResult(endpoint1, &endpoint.Result{Success: true, Timestamp: time.Now(), Duration: 100 * time.Millisecond})
|
store.InsertEndpointResult(endpoint1, &endpoint.Result{Success: true, Timestamp: time.Now(), Duration: 100 * time.Millisecond})
|
||||||
store.InsertEndpointResult(endpoint2, &endpoint.Result{Success: false, Timestamp: time.Now(), Duration: 200 * time.Millisecond})
|
store.InsertEndpointResult(endpoint2, &endpoint.Result{Success: false, Timestamp: time.Now(), Duration: 200 * time.Millisecond})
|
||||||
store.InsertEndpointResult(suiteEndpoint1, &endpoint.Result{Success: true, Timestamp: time.Now(), Duration: 50 * time.Millisecond})
|
// Suite endpoints should only exist as part of suite results, not as individual endpoint results
|
||||||
store.InsertEndpointResult(suiteEndpoint2, &endpoint.Result{Success: true, Timestamp: time.Now(), Duration: 75 * time.Millisecond})
|
|
||||||
store.InsertSuiteResult(testSuite, &suite.Result{
|
store.InsertSuiteResult(testSuite, &suite.Result{
|
||||||
Name: testSuite.Name, Group: testSuite.Group, Success: true,
|
Name: testSuite.Name, Group: testSuite.Group, Success: true,
|
||||||
Timestamp: time.Now(), Duration: 125 * time.Millisecond,
|
Timestamp: time.Now(), Duration: 125 * time.Millisecond,
|
||||||
|
EndpointResults: []*endpoint.Result{
|
||||||
|
{Success: true, Duration: 50 * time.Millisecond, Name: "suite-endpoint1"},
|
||||||
|
{Success: true, Duration: 75 * time.Millisecond, Name: "suite-endpoint2"},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
statuses, err := store.GetAllEndpointStatuses(&paging.EndpointStatusParams{})
|
statuses, err := store.GetAllEndpointStatuses(&paging.EndpointStatusParams{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to get all endpoint statuses: %v", err)
|
t.Fatalf("failed to get all endpoint statuses: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should have 4 endpoints (2 regular + 2 suite endpoints)
|
// Should have 2 endpoints (only standalone endpoints, not suite endpoints)
|
||||||
if len(statuses) != 4 {
|
if len(statuses) != 2 {
|
||||||
t.Errorf("expected 4 endpoint statuses, got %d", len(statuses))
|
t.Errorf("expected 2 endpoint statuses, got %d", len(statuses))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify all are endpoint statuses with correct data, not suite statuses
|
// Verify all are standalone endpoint statuses with correct data, not suite endpoints
|
||||||
expectedEndpoints := map[string]struct {
|
expectedEndpoints := map[string]struct {
|
||||||
success bool
|
success bool
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
}{
|
}{
|
||||||
"endpoint1": {success: true, duration: 100 * time.Millisecond},
|
"endpoint1": {success: true, duration: 100 * time.Millisecond},
|
||||||
"endpoint2": {success: false, duration: 200 * time.Millisecond},
|
"endpoint2": {success: false, duration: 200 * time.Millisecond},
|
||||||
"suite-endpoint1": {success: true, duration: 50 * time.Millisecond},
|
|
||||||
"suite-endpoint2": {success: true, duration: 75 * time.Millisecond},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, status := range statuses {
|
for _, status := range statuses {
|
||||||
|
|||||||
@@ -50,12 +50,10 @@ func executeSuite(s *suite.Suite, cfg *config.Config, extraLabels []string) {
|
|||||||
if cfg.Metrics {
|
if cfg.Metrics {
|
||||||
metrics.PublishMetricsForSuite(s, result, extraLabels)
|
metrics.PublishMetricsForSuite(s, result, extraLabels)
|
||||||
}
|
}
|
||||||
// Store individual endpoint results and handle alerting
|
// Handle alerting for suite endpoints
|
||||||
for i, ep := range s.Endpoints {
|
for i, ep := range s.Endpoints {
|
||||||
if i < len(result.EndpointResults) {
|
if i < len(result.EndpointResults) {
|
||||||
epResult := result.EndpointResults[i]
|
epResult := result.EndpointResults[i]
|
||||||
// Store the endpoint result
|
|
||||||
UpdateEndpointStatus(ep, epResult)
|
|
||||||
// Handle alerting if configured and not under maintenance
|
// Handle alerting if configured and not under maintenance
|
||||||
if cfg.Alerting != nil && !cfg.Maintenance.IsUnderMaintenance() {
|
if cfg.Alerting != nil && !cfg.Maintenance.IsUnderMaintenance() {
|
||||||
// Check if endpoint is under maintenance
|
// Check if endpoint is under maintenance
|
||||||
|
|||||||
Reference in New Issue
Block a user