Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class CreateFullBackupScheduleSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase();
}

@Test
public void testCreateFullBackupScheduleSample() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class CreateIncrementalBackupScheduleSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase(multiRegionalInstanceId);
}

@Test
public void testCreateIncrementalBackupScheduleSample() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class DeleteBackupScheduleSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase();
}

@Test
public void testDeleteBackupScheduleSample() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class GetBackupScheduleSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase();
}

@Test
public void testGetBackupScheduleSample() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class ListBackupSchedulesSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase();
}

@Test
public void testListBackupSchedulesSample() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.google.cloud.spanner.admin.database.v1.DatabaseAdminSettings;
import com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient;
import com.google.cloud.spanner.admin.instance.v1.InstanceAdminSettings;
import com.google.spanner.admin.database.v1.CreateDatabaseRequest;
import com.google.spanner.admin.database.v1.DatabaseDialect;
import com.google.spanner.admin.database.v1.InstanceName;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
Expand Down Expand Up @@ -180,4 +182,20 @@ static String getCreateDatabaseStatement(
return "CREATE DATABASE \"" + databaseName + "\"";
}
}

protected static String createEphemeralDatabase() throws Exception {
return createEphemeralDatabase(instanceId);
}

protected static String createEphemeralDatabase(String targetInstanceId) throws Exception {
String databaseId = idGenerator.generateDatabaseId();
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of(projectId, targetInstanceId).toString())
.setCreateStatement(
getCreateDatabaseStatement(databaseId, DatabaseDialect.GOOGLE_STANDARD_SQL))
.build();
databaseAdminClient.createDatabaseAsync(request).get(5, TimeUnit.MINUTES);
return databaseId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@

import com.google.spanner.admin.database.v1.BackupScheduleName;
import java.util.UUID;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class UpdateBackupScheduleSampleIT extends SampleTestBaseV2 {
// Default instance and given db should exist for tests to pass.
private static String databaseId = System.getProperty("spanner.sample.database", "mysample");

private static String databaseId;

@BeforeClass
public static void setUp() throws Exception {
databaseId = createEphemeralDatabase();
}

@Test
public void testUpdateBackupScheduleSample() throws Exception {
Expand Down
Loading