bug: microcks test get swallows test failure details and operation results in text output mode

Aberta Para iniciantes
#608 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
85/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
go
Domínio
cli

Direção de pesquisa

Comece em cmd/testQuery.go, especialmente na conversão para TestResultSummary, e compare a saída de texto com cmd/testExecutor.go e o formatador existente em pkg/output. Adicione ou atualize um teste específico para microcks test get no modo de texto. O trabalho estará concluído quando a saída incluir as operações com falha e suas mensagens de erro, e não apenas a tabela de resumo.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Describe the bug

I noticed that when running microcks test get <testResultId> on a failed test, the CLI doesn't show any failure details or which operations failed.

Right now, it just prints the exact same 1-line table you get from microcks test list:

ID      SERVICE ID  SUCCESS  IN PROGRESS  ELAPSED
test-1  svc-orders  false    false        150ms

Looking at cmd/testQuery.go, the CLI actually calls mc.GetFullTestResult(args[0]) which returns the full TestCaseResults and step error messages, but then lines 97–107 cast it down to TestResultSummary and drop all the operation results before printing:

return printTestResults([]connectors.TestResultSummary{{
    ID:             result.ID,
    Version:        result.Version,
    TestNumber:     result.TestNumber,
    TestDate:       result.TestDate,
    TestedEndpoint: result.TestedEndpoint,
    ServiceID:      result.ServiceID,
    ElapsedTime:    result.ElapsedTime,
    Success:        result.Success,
    InProgress:     result.InProgress,
}})

So if a test fails, there's no way to see what actually went wrong from the terminal without passing --output json and digging through raw JSON.

Expected behavior

In default text mode, microcks test get should format the test result using the existing output.NewFormatter(output.FormatText) (similar to what cmd/testExecutor.go does):

Test test-1: FAILURE (150ms)
  [FAIL] POST /orders
      order-validation: price: expected number got string

This way you can immediately see which operations failed and the error message directly in your terminal.

Actual behavior
$ microcks test get test-1 --microcksURL http://127.0.0.1:8888
ID      SERVICE ID  SUCCESS  IN PROGRESS  ELAPSED
test-1  svc-orders  false    false        150ms

All test cases, operations, and failure messages are omitted from the output.

Image
How to Reproduce?
  1. Spin up a quick local mock returning a failed test with testCaseResults:
python3 -c '
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class Mock(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-Type", "application/json")
        self.end_headers()
        self.wfile.write(json.dumps({
            "id": "test-1",
            "serviceId": "svc-orders",
            "success": False,
            "elapsedTime": 150,
            "testCaseResults": [{
                "operationName": "POST /orders",
                "success": False,
                "elapsedTime": 150,
                "testStepResults": [{
                    "requestName": "order-validation",
                    "success": False,
                    "message": "price: expected number got string"
                }]
            }]
        }).encode())
    def log_message(self, *args): pass
HTTPServer(("127.0.0.1", 8888), Mock).serve_forever()
'
  1. Run test get:
go run main.go test get test-1 --microcksURL http://127.0.0.1:8888

You'll see it only prints the 1-line summary table without showing the failed POST /orders operation or the error message.

Microcks version or git rev

main

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

cli

Additional information

Since output.NewFormatter(output.FormatText) is already implemented in pkg/output, we can just route text mode through it in newTestGetCommand.

Tested this locally and happy to submit a PR with the fix and unit test if this sounds good!

Linguagem predominante
Go
Estrelas
59
Forks
74
Merge médio
4d 5h
PRs com merge (30d)
15

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microcks/microcks-cli

Todas as issues de microcks/microcks-cli

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.