Skip to content

Commit

Permalink
fixup! snp: don't validate hostdata in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Oct 1, 2024
1 parent 8daea21 commit 05807fa
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions e2e/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,20 @@ func getFailures(ctx context.Context, t *testing.T, ct *contrasttest.ContrastTes
// parse the logs
metrics, err := (&expfmt.TextParser{}).TextToMetricFamilies(strings.NewReader(metricsString))
require.NoError(err)
failures := -1
for k, v := range metrics {
if k != "contrast_grpc_server_handled_total" {
continue
}
failures = 0
for _, metric := range v.GetMetric() {
for _, labelPair := range metric.GetLabel() {
if labelPair.Name == nil || *labelPair.Name != "grpc_code" {
continue
}
if labelPair.Value == nil || *labelPair.Value != "PermissionDenied" {
break
}
failures += int(metric.GetCounter().GetValue())
const metricName = "contrast_grpc_server_handled_total"
metricFamily, ok := metrics[metricName]
require.True(ok, "metric family %q not found", metricName)
failures := 0
for _, metric := range metricFamily.GetMetric() {
for _, labelPair := range metric.GetLabel() {
if labelPair.Name == nil || *labelPair.Name != "grpc_code" {
continue
}
if labelPair.Value == nil || *labelPair.Value != "PermissionDenied" {
break
}
failures += int(metric.GetCounter().GetValue())
}
}
if failures == -1 {
// metric not found
t.Error("metric \"contrast_grpc_server_handled_total\" not found")
}
return failures
}

0 comments on commit 05807fa

Please sign in to comment.