Skip to content

Commit 4492683

Browse files
chore: Fix AFE tests in cloud-devel and staging
1 parent 0ca9541 commit 4492683

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBuiltInMetricsTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.google.cloud.spanner.*;
2525
import com.google.cloud.spanner.testing.EmulatorSpannerHelper;
2626
import com.google.common.base.Stopwatch;
27+
import com.google.common.base.Strings;
28+
import com.google.common.truth.IntegerSubject;
2729
import com.google.monitoring.v3.ListTimeSeriesRequest;
2830
import com.google.monitoring.v3.ListTimeSeriesResponse;
2931
import com.google.monitoring.v3.ProjectName;
@@ -132,14 +134,24 @@ public void testBuiltinMetricsWithDefaultOTEL() throws Exception {
132134
// disabled.
133135
// Keeping this check to enable this check in the future.
134136
if (metric.equals("afe_latencies")) {
135-
assertWithMessage("Metric " + metric + " returned data.")
136-
.that(response.getTimeSeriesCount())
137-
.isEqualTo(0);
137+
IntegerSubject subject = assertWithMessage("Metric " + metric + " returned data.")
138+
.that(response.getTimeSeriesCount());
139+
if (isProduction()) {
140+
subject.isEqualTo(0);
141+
} else {
142+
subject.isGreaterThan(0);
143+
}
144+
138145
} else {
139146
assertWithMessage("Metric " + metric + " didn't return any data.")
140147
.that(response.getTimeSeriesCount())
141148
.isGreaterThan(0);
142149
}
143150
}
144151
}
152+
153+
private boolean isProduction() {
154+
String jobType = System.getenv("JOB_TYPE");
155+
return !Strings.isNullOrEmpty(jobType) && !(jobType.contains("devel") || jobType.contains("staging"));
156+
}
145157
}

0 commit comments

Comments
 (0)