Skip to content

Commit 79d7596

Browse files
authored
Tolerate errors dumping logs in pipeline tests (#2391)
Errors are ignored in two cases more now: when the status of the stack cannot be obtained, and when using the compose provider, when the elasticsearch service doesn't exist. This should help on executions of pipeline tests against existing servers using only environment variables on default configuration.
1 parent edb5fbe commit 79d7596

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

internal/stack/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func dumpStackLogs(ctx context.Context, options DumpOptions) ([]DumpResult, erro
7171

7272
for _, requestedService := range options.Services {
7373
if !slices.Contains(services, requestedService) {
74-
return nil, fmt.Errorf("local service %s does not exist", requestedService)
74+
return nil, fmt.Errorf("%w: local service %s does not exist", ErrUnavailableStack, requestedService)
7575
}
7676
}
7777

internal/testrunner/runners/pipeline/tester.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,23 @@ func (r *tester) checkElasticsearchLogs(ctx context.Context, startTesting time.T
235235

236236
testingTime := startTesting.Truncate(time.Second)
237237

238+
statusOptions := stack.Options{
239+
Profile: r.profile,
240+
}
241+
_, err := r.provider.Status(ctx, statusOptions)
242+
if err != nil {
243+
logger.Debugf("Not checking Elasticsearch logs: %s", err)
244+
return nil, nil
245+
}
246+
238247
dumpOptions := stack.DumpOptions{
239248
Profile: r.profile,
240249
Services: []string{"elasticsearch"},
241250
Since: testingTime,
242251
}
243252
dump, err := r.provider.Dump(ctx, dumpOptions)
244253
var notImplementedErr *stack.ErrNotImplemented
245-
if errors.As(err, &notImplementedErr) {
254+
if errors.As(err, &notImplementedErr) || errors.Is(err, stack.ErrUnavailableStack) {
246255
logger.Debugf("Not checking Elasticsearch logs: %s", err)
247256
return nil, nil
248257
}

0 commit comments

Comments
 (0)