func processGroup()

in pkg/updater/resultstore/resultstore.go [427:548]


func processGroup(tg *configpb.TestGroup, group *invocationGroup) *updater.InflatedColumn {
	if group == nil || group.Invocations == nil {
		return nil
	}
	methodLimit := testMethodLimit(tg)
	matchMethods, unmatchMethods, matchMethodsErr, unmatchMethodsErr := testMethodRegex(tg)

	col := &updater.InflatedColumn{
		Column: &statepb.Column{
			Name: group.GroupID,
		},
		Cells: map[string]updater.Cell{},
	}

	groupedCells := make(map[string][]updater.Cell)

	hintTime := time.Unix(0, 0)
	headers := make([][]string, len(tg.GetColumnHeader()))

	// extract info from underlying invocations and target results
	for _, invocation := range group.Invocations {

		if build := identifyBuild(tg, invocation); build != "" {
			col.Column.Build = build
		} else {
			col.Column.Build = group.GroupID
		}

		started := invocation.InvocationProto.GetTiming().GetStartTime()
		resultStartTime := timestampMilliseconds(started)
		if col.Column.Started == 0 || resultStartTime < col.Column.Started {
			col.Column.Started = resultStartTime
		}

		if started.AsTime().After(hintTime) {
			hintTime = started.AsTime()
		}

		for i, headerConf := range tg.GetColumnHeader() {
			if invHeaders := invocation.extractHeaders(headerConf); invHeaders != nil {
				headers[i] = append(headers[i], invHeaders...)
			}
		}

		if err := matchMethodsErr; err != nil {
			groupedCells["test_method_match_regex"] = append(groupedCells["test_method_match_regex"],
				updater.Cell{
					Result:  statuspb.TestStatus_TOOL_FAIL,
					Message: err.Error(),
				})
		}

		if err := unmatchMethodsErr; err != nil {
			groupedCells["test_method_unmatch_regex"] = append(groupedCells["test_method_unmatch_regex"],
				updater.Cell{
					Result:  statuspb.TestStatus_TOOL_FAIL,
					Message: err.Error(),
				})
		}

		for targetID, singleActionResults := range invocation.TargetResults {
			for _, sar := range singleActionResults {
				if !includeStatus(tg, sar) {
					continue
				}

				// assign status
				status, ok := convertStatus[sar.ConfiguredTargetProto.GetStatusAttributes().GetStatus()]
				if !ok {
					status = statuspb.TestStatus_UNKNOWN
				}
				// TODO(sultan-duisenbay): sanitize build target and apply naming config
				var cell updater.Cell
				cell.CellID = invocation.InvocationProto.GetId().GetInvocationId()
				cell.ID = targetID
				cell.Result = status
				if cr := customTargetStatus(tg.GetCustomEvaluatorRuleSet(), sar); cr != nil {
					cell.Result = *cr
				}
				groupedCells[targetID] = append(groupedCells[targetID], cell)
				testResults := getTestResults(sar.ActionProto.GetTestAction().GetTestSuite())
				testResults, filtered := filterResults(testResults, tg.GetTestMethodProperties(), matchMethods, unmatchMethods)
				processTestResults(tg, groupedCells, testResults, sar, cell, targetID, methodLimit)
				if filtered && len(testResults) == 0 {
					continue
				}

				for i, headerConf := range tg.GetColumnHeader() {
					if targetHeaders := sar.extractHeaders(headerConf); targetHeaders != nil {
						headers[i] = append(headers[i], targetHeaders...)
					}
				}

				cell.Metrics = calculateMetrics(sar)

				// TODO (@bryanlou) check if we need to include properties from the target in addition to test cases
				properties := map[string][]string{}
				testSuite := sar.ActionProto.GetTestAction().GetTestSuite()
				for _, t := range testSuite.GetTests() {
					appendProperties(properties, t, nil)
				}
			}
		}

		for name, cells := range groupedCells {
			split := updater.SplitCells(name, cells...)
			for outName, outCell := range split {
				col.Cells[outName] = outCell
			}
		}
	}

	hint, err := hintTime.MarshalText()
	if err != nil {
		hint = []byte{}
	}

	col.Column.Hint = string(hint)
	col.Column.Extra = compileHeaders(tg.GetColumnHeader(), headers)

	return col
}