func (tck *tckReporter) SpecDidComplete(specSummary *types.SpecSummary) { if specSummary.HasFailureState() { if strings.EqualFold(specSummary.ComponentTexts[1], "#serviceBind") && strings.EqualFold(specSummary.ComponentTexts[2], "when serviceBind succeed") && strings.EqualFold(specSummary.ComponentTexts[3], "serviceBind v2/service_instances/aws-service-guid/service_bindings/aws-service-binding returns models.BindingResponse") { tck.failsWithoutAppId = true tck.failMessages = append(tck.failMessages, specSummary.ComponentTexts[1]+" "+specSummary.ComponentTexts[2]+" "+specSummary.ComponentTexts[3]) } } else { if strings.EqualFold(specSummary.ComponentTexts[1], "#serviceBind") && strings.EqualFold(specSummary.ComponentTexts[2], "when serviceBind succeed") && strings.EqualFold(specSummary.ComponentTexts[3], "serviceBind v2/service_instances/aws-service-guid/service_bindings/aws-service-binding with app_id") { tck.succeedsWithAppId = true } } _, ok := tck.apiTestPassedMap[specSummary.ComponentTexts[1]] if !ok { if specSummary.Failure == (types.SpecFailure{}) { tck.apiTestPassedMap[specSummary.ComponentTexts[1]] = 1 } } else { if specSummary.Failure == (types.SpecFailure{}) { tck.apiTestPassedMap[specSummary.ComponentTexts[1]] += 1 } } }
func (r *S3Reporter) SpecDidComplete(specSummary *ginkgotypes.SpecSummary) { if specSummary.Passed() && specSummary.IsMeasurement { for _, measurement := range specSummary.Measurements { if measurement.Info == nil { panic(fmt.Sprintf("%#v", specSummary)) } info, ok := measurement.Info.(ReporterInfo) if !ok { r.logger.Error("failed-type-assertion-on-measurement-info", errors.New("type-assertion-failed")) continue } if info.MetricName == "" { r.logger.Error("failed-blank-metric-name", errors.New("blank-metric-name")) continue } now := time.Now() data := Data{ Timestamp: now.Unix(), Measurement: *measurement, } dataJSON, err := json.Marshal(data) if err != nil { r.logger.Error("failed-marshaling-data", err) continue } measurementData := string(dataJSON) key := fmt.Sprintf("%s/%s-%s", startTime, info.MetricName, now.Format(time.RFC3339)) _, err = r.uploader.Upload(&s3manager.UploadInput{ Bucket: aws.String(r.bucketName), Key: aws.String(key), Body: bytes.NewReader([]byte(measurementData)), }) if err != nil { r.logger.Error("failed-uploading-metric-to-s3", err) continue } r.logger.Debug("successfully-uploaded-metric-to-s3", lager.Data{ "bucket-name": r.bucketName, "key": key, "content": measurementData, }) } } }
func (runner *SpecRunner) reportSpecDidComplete(summary *types.SpecSummary, failed bool) { if failed && len(summary.CapturedOutput) == 0 { summary.CapturedOutput = string(runner.writer.Bytes()) } for i := len(runner.reporters) - 1; i >= 1; i-- { runner.reporters[i].SpecDidComplete(summary) } if failed { runner.writer.DumpOut() } runner.reporters[0].SpecDidComplete(summary) }
func (r *DataDogReporter) SpecDidComplete(specSummary *types.SpecSummary) { if specSummary.Passed() && specSummary.IsMeasurement { for _, measurement := range specSummary.Measurements { if measurement.Info == nil { panic(fmt.Sprintf("%#v", specSummary)) } info, ok := measurement.Info.(ReporterInfo) if !ok { r.logger.Error("failed-type-assertion-on-measurement-info", errors.New("type-assertion-failed")) continue } if info.MetricName == "" { r.logger.Error("failed-blank-metric-name", errors.New("blank-metric-name")) continue } timestamp := float64(time.Now().Unix()) r.logger.Info("sending-metrics-to-datadog", lager.Data{"metric": info.MetricName, "prefix": r.metricPrefix}) err := r.dataDogClient.PostMetrics([]datadog.Metric{ { Metric: fmt.Sprintf("%s.%s", r.metricPrefix, info.MetricName), Points: []datadog.DataPoint{ {timestamp, measurement.Average}, }, }, }) if err != nil { r.logger.Error("failed-sending-metrics-to-datadog", err, lager.Data{"metric": info.MetricName, "prefix": r.metricPrefix}) continue } r.logger.Info("sending-metrics-to-datadog-complete", lager.Data{"metric": info.MetricName, "prefix": r.metricPrefix}) } } }
import ( . "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/config" "github.com/onsi/ginkgo/reporters" st "github.com/onsi/ginkgo/reporters/stenographer" "github.com/onsi/ginkgo/types" . "github.com/onsi/gomega" "time" ) var _ = Describe("DefaultReporter", func() { var ( reporter *reporters.DefaultReporter reporterConfig config.DefaultReporterConfigType stenographer *st.FakeStenographer ginkgoConfig config.GinkgoConfigType suite *types.SuiteSummary spec *types.SpecSummary ) BeforeEach(func() { stenographer = st.NewFakeStenographer() reporterConfig = config.DefaultReporterConfigType{ NoColor: false, SlowSpecThreshold: 0.1, NoisyPendings: true, Verbose: true, FullTrace: true, }
} } return logs } jsonRoundTrip := func(object interface{}) interface{} { jsonEncoded, err := json.Marshal(object) Ω(err).ShouldNot(HaveOccurred()) var out interface{} err = json.Unmarshal(jsonEncoded, &out) Ω(err).ShouldNot(HaveOccurred()) return out } Describe("Announcing specs", func() { var summary *types.SpecSummary BeforeEach(func() { summary = &types.SpecSummary{ ComponentTexts: []string{"A", "B"}, ComponentCodeLocations: []types.CodeLocation{ { FileName: "file/a", LineNumber: 3, FullStackTrace: "some-stack-trace", }, { FileName: "file/b", LineNumber: 4, FullStackTrace: "some-stack-trace", }, },
import ( "encoding/json" . "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/config" . "github.com/onsi/ginkgo/internal/remote" "github.com/onsi/ginkgo/types" . "github.com/onsi/gomega" ) var _ = Describe("ForwardingReporter", func() { var ( reporter *ForwardingReporter interceptor *fakeOutputInterceptor poster *fakePoster suiteSummary *types.SuiteSummary specSummary *types.SpecSummary setupSummary *types.SetupSummary serverHost string ) BeforeEach(func() { serverHost = "http://127.0.0.1:7788" poster = newFakePoster() interceptor = &fakeOutputInterceptor{ InterceptedOutput: "The intercepted output!", } reporter = NewForwardingReporter(serverHost, poster, interceptor)
func (f *failReporter) SpecDidComplete(specSummary *types.SpecSummary) { if specSummary.Failed() { f.failed = true } }
func (reporter *ForwardingReporter) SpecDidComplete(specSummary *types.SpecSummary) { output, _ := reporter.outputInterceptor.StopInterceptingAndReturnOutput() reporter.outputInterceptor.StartInterceptingOutput() specSummary.CapturedOutput = output reporter.post("/SpecDidComplete", specSummary) }