|
|
|
|
@ -11,7 +11,7 @@ |
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
package promql |
|
|
|
|
package promql_test |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"testing" |
|
|
|
|
@ -19,39 +19,40 @@ import ( |
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
|
|
|
|
|
|
"github.com/prometheus/prometheus/model/labels" |
|
|
|
|
"github.com/prometheus/prometheus/promql" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func TestVector_ContainsSameLabelset(t *testing.T) { |
|
|
|
|
for name, tc := range map[string]struct { |
|
|
|
|
vector Vector |
|
|
|
|
vector promql.Vector |
|
|
|
|
expected bool |
|
|
|
|
}{ |
|
|
|
|
"empty vector": { |
|
|
|
|
vector: Vector{}, |
|
|
|
|
vector: promql.Vector{}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"vector with one series": { |
|
|
|
|
vector: Vector{ |
|
|
|
|
vector: promql.Vector{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"vector with two different series": { |
|
|
|
|
vector: Vector{ |
|
|
|
|
vector: promql.Vector{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "b")}, |
|
|
|
|
}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"vector with two equal series": { |
|
|
|
|
vector: Vector{ |
|
|
|
|
vector: promql.Vector{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
}, |
|
|
|
|
expected: true, |
|
|
|
|
}, |
|
|
|
|
"vector with three series, two equal": { |
|
|
|
|
vector: Vector{ |
|
|
|
|
vector: promql.Vector{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "b")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
@ -67,35 +68,35 @@ func TestVector_ContainsSameLabelset(t *testing.T) { |
|
|
|
|
|
|
|
|
|
func TestMatrix_ContainsSameLabelset(t *testing.T) { |
|
|
|
|
for name, tc := range map[string]struct { |
|
|
|
|
matrix Matrix |
|
|
|
|
matrix promql.Matrix |
|
|
|
|
expected bool |
|
|
|
|
}{ |
|
|
|
|
"empty matrix": { |
|
|
|
|
matrix: Matrix{}, |
|
|
|
|
matrix: promql.Matrix{}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"matrix with one series": { |
|
|
|
|
matrix: Matrix{ |
|
|
|
|
matrix: promql.Matrix{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"matrix with two different series": { |
|
|
|
|
matrix: Matrix{ |
|
|
|
|
matrix: promql.Matrix{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "b")}, |
|
|
|
|
}, |
|
|
|
|
expected: false, |
|
|
|
|
}, |
|
|
|
|
"matrix with two equal series": { |
|
|
|
|
matrix: Matrix{ |
|
|
|
|
matrix: promql.Matrix{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
}, |
|
|
|
|
expected: true, |
|
|
|
|
}, |
|
|
|
|
"matrix with three series, two equal": { |
|
|
|
|
matrix: Matrix{ |
|
|
|
|
matrix: promql.Matrix{ |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "b")}, |
|
|
|
|
{Metric: labels.FromStrings("lbl", "a")}, |
|
|
|
|
|