.append("\nHost: ").append(spanner.getOptions().getHost()) .append("\nProject: ").append(project) .append("\nInstance: ").append(instance)
@Test public void defaultBuilder() { // We need to set the project id since in test environment we cannot obtain a default project // id. SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); assertThat(options.getHost()).isEqualTo("https://spanner.googleapis.com"); assertThat(options.getPrefetchChunks()).isEqualTo(4); assertThat(options.getSessionLabels()).isNull(); }
@Test public void builder() { String host = "http://localhost:8000/"; String projectId = "test-project"; Map<String, String> labels = new HashMap<>(); labels.put("env", "dev"); SpannerOptions options = SpannerOptions.newBuilder() .setHost(host) .setProjectId(projectId) .setPrefetchChunks(2) .setSessionLabels(labels) .build(); assertThat(options.getHost()).isEqualTo(host); assertThat(options.getProjectId()).isEqualTo(projectId); assertThat(options.getPrefetchChunks()).isEqualTo(2); assertThat(options.getSessionLabels()).containsExactlyEntriesIn(labels); }
@Override protected void before() throws Throwable { this.initializeConfig(); this.config.setUp(); SpannerOptions options = config.spannerOptions(); String instanceProperty = System.getProperty(TEST_INSTANCE_PROPERTY, ""); InstanceId instanceId; if (!instanceProperty.isEmpty()) { instanceId = InstanceId.of(instanceProperty); isOwnedInstance = false; logger.log(Level.INFO, "Using existing test instance: {0}", instanceId); } else { instanceId = InstanceId.of(config.spannerOptions().getProjectId(), "test-instance"); isOwnedInstance = true; } testHelper = RemoteSpannerHelper.create(options, instanceId); instanceAdminClient = testHelper.getClient().getInstanceAdminClient(); logger.log(Level.FINE, "Test env endpoint is {0}", options.getHost()); if (isOwnedInstance) { initializeInstance(instanceId); } }