You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "Copilot (via GitHub)" <gi...@apache.org> on 2026/04/15 14:53:00 UTC

Re: [PR] test: add measure query test-case generator with pairwise combinatorial coverage [skywalking-banyandb]

Copilot commented on code in PR #1071:
URL: https://github.com/apache/skywalking-banyandb/pull/1071#discussion_r3087369561


##########
test/cases/measure/cmd/generate/pairwise.go:
##########
@@ -0,0 +1,172 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+// Pair holds a parameter-value pair for pairwise testing.
+type Pair struct {
+	Param string
+	Value string
+}
+
+// TestVector is a set of parameter-value assignments.
+type TestVector map[string]string
+
+// PairwiseGenerate generates a minimal set of test vectors covering all pairs
+// of parameter values using a simplified IPO (In-Parameter-Order) algorithm.
+func PairwiseGenerate(params map[string][]string, constraints []ConstraintFunc) []TestVector {
+	paramNames := sortedParamNames(params)
+	if len(paramNames) == 0 {
+		return nil
+	}
+
+	// Collect all required pairs
+	requiredPairs := collectAllPairs(params, constraints)
+
+	// Build test vectors using greedy pair covering
+	var vectors []TestVector
+	coveredPairs := make(map[Pair]bool)
+
+	for len(coveredPairs) < len(requiredPairs) {
+		tv := buildVector(params, paramNames, coveredPairs, constraints)
+		if tv == nil {
+			break
+		}
+		// Mark newly covered pairs
+		newCovers := 0
+		for _, pn := range paramNames {
+			for _, pn2 := range paramNames {
+				if pn >= pn2 {
+					continue
+				}
+				p := Pair{Param: pn + "=" + tv[pn], Value: pn2 + "=" + tv[pn2]}
+				if !coveredPairs[p] {
+					coveredPairs[p] = true
+					newCovers++
+				}
+			}
+		}
+		if newCovers == 0 {
+			break
+		}
+		vectors = append(vectors, tv)
+	}

Review Comment:
   In PairwiseGenerate, newly covered pairs are added to coveredPairs unconditionally, even if the pair isn't in requiredPairs. This can make `len(coveredPairs)` reach `len(requiredPairs)` early and terminate before all required pairs are actually covered. Consider only counting/recording pairs that exist in `requiredPairs` (or maintain a separate coveredRequiredPairs set).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org