Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhigarg92 committed Jan 20, 2025
1 parent 2ce5429 commit 40ed7bf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions google-cloud-spanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<site.installationModule>google-cloud-spanner</site.installationModule>
<opencensus.version>0.31.1</opencensus.version>
<spanner.testenv.config.class>com.google.cloud.spanner.GceTestEnvConfig</spanner.testenv.config.class>
<spanner.testenv.instance>projects/gcloud-devel/instances/spanner-testing-east1</spanner.testenv.instance>
<spanner.gce.config.project_id>gcloud-devel</spanner.gce.config.project_id>
<spanner.testenv.instance>projects/span-cloud-testing/instances/alka-testing</spanner.testenv.instance>
<spanner.gce.config.project_id>span-cloud-testing</spanner.gce.config.project_id>
<spanner.testenv.kms_key.name>projects/gcloud-devel/locations/us-east1/keyRings/cmek-test-key-ring/cryptoKeys/cmek-test-key</spanner.testenv.kms_key.name>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.google.cloud.spanner.BuiltInMetricsConstant.GAX_METER_NAME;
import static com.google.cloud.spanner.BuiltInMetricsConstant.INSTANCE_ID_KEY;
import static com.google.cloud.spanner.BuiltInMetricsConstant.PROJECT_ID_KEY;
import static com.google.cloud.spanner.BuiltInMetricsConstant.SPANNER_METER_NAME;
import static com.google.cloud.spanner.BuiltInMetricsConstant.SPANNER_PROMOTED_RESOURCE_LABELS;
import static com.google.cloud.spanner.BuiltInMetricsConstant.SPANNER_RESOURCE_TYPE;

Expand Down Expand Up @@ -75,8 +76,8 @@ static List<TimeSeries> convertToSpannerTimeSeries(List<MetricData> collection)
List<TimeSeries> allTimeSeries = new ArrayList<>();

for (MetricData metricData : collection) {
// Get common metrics data from GAX library
if (!metricData.getInstrumentationScopeInfo().getName().equals(GAX_METER_NAME)) {
// Get metrics data from GAX library and Spanner library
if (!(metricData.getInstrumentationScopeInfo().getName().equals(GAX_METER_NAME) || metricData.getInstrumentationScopeInfo().getName().equals(SPANNER_METER_NAME))) {
// Filter out metric data for instruments that are not part of the spanner metrics list
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class GceTestEnvConfig implements TestEnvConfig {

public GceTestEnvConfig() {
String projectId = System.getProperty(GCE_PROJECT_ID, "");
projectId = "span-cloud-testing";
String serverUrl = System.getProperty(GCE_SERVER_URL, "");
String credentialsFile = System.getProperty(GCE_CREDENTIALS_FILE, "");
double errorProbability =
Expand All @@ -83,22 +84,22 @@ public GceTestEnvConfig() {
throw new RuntimeException(e);
}
}
SpannerInterceptorProvider interceptorProvider =
SpannerInterceptorProvider.createDefault().with(new GrpcErrorInjector(errorProbability));
if (attemptDirectPath) {
interceptorProvider =
interceptorProvider.with(new DirectPathAddressCheckInterceptor(directPathTestScenario));
}
builder.setInterceptorProvider(interceptorProvider);
// SpannerInterceptorProvider interceptorProvider =
// SpannerInterceptorProvider.createDefault().with(new GrpcErrorInjector(errorProbability));
// if (attemptDirectPath) {
// interceptorProvider =
// interceptorProvider.with(new DirectPathAddressCheckInterceptor(directPathTestScenario));
// }
// builder.setInterceptorProvider(interceptorProvider);
// DirectPath tests need to set a custom endpoint to the ChannelProvider
InstantiatingGrpcChannelProvider.Builder customChannelProviderBuilder =
InstantiatingGrpcChannelProvider.newBuilder();
if (attemptDirectPath) {
customChannelProviderBuilder
.setEndpoint(DIRECT_PATH_ENDPOINT)
.setAttemptDirectPath(true)
.setAttemptDirectPathXds()
.setInterceptorProvider(interceptorProvider);
.setAttemptDirectPathXds();
// .setInterceptorProvider(interceptorProvider);
builder.setChannelProvider(customChannelProviderBuilder.build());
}
options = builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ protected void before() throws Throwable {

SpannerOptions options = config.spannerOptions();
String instanceProperty = System.getProperty(TEST_INSTANCE_PROPERTY, "");
instanceProperty = "projects/span-cloud-testing/instances/alka-testing";
InstanceId instanceId;
if (!instanceProperty.isEmpty() && !alwaysCreateNewInstance) {
instanceId = InstanceId.of(instanceProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

@Category(ParallelIntegrationTest.class)
@RunWith(JUnit4.class)
@Ignore("Built-in Metrics are not GA'ed yet. Enable this test once the metrics are released")
// @Ignore("Built-in Metrics are not GA'ed yet. Enable this test once the metrics are released")
public class ITBuiltInMetricsTest {

private static Database db;
Expand Down Expand Up @@ -82,10 +82,12 @@ public void testBuiltinMetricsWithDefaultOTEL() throws Exception {

String metricFilter =
String.format(
"metric.type=\"spanner.googleapis.com/client/%s\" "
+ "AND resource.labels.instance=\"%s\" AND metric.labels.method=\"Spanner.ExecuteStreamingSql\""
"metric.type=\"spanner.googleapis.com/client/%s\""
+ " AND resource.type=\"spanner_instance\""
+ " AND metric.labels.method=\"Spanner.Commit\""
+ " AND resource.labels.instance_id=\"%s\""
+ " AND metric.labels.database=\"%s\"",
"operation_latencies", env.getTestHelper().getInstanceId(), db.getId());
"operation_latencies", db.getId().getInstanceId().getInstance(), db.getId().getDatabase());

ListTimeSeriesRequest.Builder requestBuilder =
ListTimeSeriesRequest.newBuilder()
Expand Down

0 comments on commit 40ed7bf

Please sign in to comment.