Skip to content

Commit ca43348

Browse files
chore: Fix AFE tests in cloud-devel and staging (googleapis#4200)
1 parent 685bb09 commit ca43348

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 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,26 @@ 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 =
138+
assertWithMessage("Metric " + metric + " returned data.")
139+
.that(response.getTimeSeriesCount());
140+
if (isProduction()) {
141+
subject.isEqualTo(0);
142+
} else {
143+
subject.isGreaterThan(0);
144+
}
145+
138146
} else {
139147
assertWithMessage("Metric " + metric + " didn't return any data.")
140148
.that(response.getTimeSeriesCount())
141149
.isGreaterThan(0);
142150
}
143151
}
144152
}
153+
154+
private boolean isProduction() {
155+
String jobType = System.getenv("JOB_TYPE");
156+
return !Strings.isNullOrEmpty(jobType)
157+
&& !(jobType.contains("devel") || jobType.contains("staging"));
158+
}
145159
}

0 commit comments

Comments
 (0)