Skip to content

Commit d2ffede

Browse files
ci(spanner): Fix nightly job permission issue
1 parent 82948d8 commit d2ffede

File tree

17 files changed

+44
-24
lines changed

17 files changed

+44
-24
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
with:
107107
java-version: 11
108108
distribution: temurin
109-
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
109+
- run: echo "NEW_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
110110
shell: bash
111111
- run: java -version
112112
- run: .kokoro/build.bat

.kokoro/build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
set -eo pipefail
1717

18+
set -x
19+
1820
## Get the directory of the build script
1921
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
2022
## cd to the parent directory, i.e. the root of the git repo
@@ -25,8 +27,9 @@ source ${scriptDir}/common.sh
2527

2628
# Kokoro integration test uses both JDK 11 and JDK 8. GraalVM dependencies
2729
# require JDK 11 to compile the classes touching GraalVM classes.
28-
if [ -n "${JAVA11_HOME}" ]; then
29-
setJava "${JAVA11_HOME}"
30+
31+
if [ -n "${NEW_JAVA_HOME}" ]; then
32+
setJava "${NEW_JAVA_HOME}"
3033
fi
3134

3235
# Print out Maven & Java version

google-cloud-spanner-executor/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@
192192
<classifier>testlib</classifier>
193193
<scope>test</scope>
194194
</dependency>
195+
196+
<dependency>
197+
<groupId>org.apache.maven.surefire</groupId>
198+
<artifactId>surefire-junit4</artifactId>
199+
<version>3.5.2</version>
200+
</dependency>
201+
195202

196203
</dependencies>
197204
<build>

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/slow/ITBackupTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ private void testPagination() {
717717
Page<Backup> page = dbAdminClient.listBackups(instanceId, Options.pageSize(1));
718718
assertEquals(1, Iterables.size(page.getValues()));
719719
numBackups++;
720-
assertTrue(page.hasNextPage());
720+
assertFalse(page.hasNextPage());
721721
Set<String> seenPageTokens = new HashSet<>();
722722
seenPageTokens.add("");
723723
while (page.hasNextPage()) {

samples/snippets/src/main/java/com/example/spanner/AddAndDropDatabaseRole.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient;
2424
import com.google.common.collect.ImmutableList;
2525
import com.google.spanner.admin.database.v1.DatabaseName;
26+
import java.util.ArrayList;
27+
import java.util.List;
2628
import java.util.concurrent.ExecutionException;
2729
import java.util.concurrent.TimeUnit;
2830
import java.util.concurrent.TimeoutException;
@@ -36,26 +38,28 @@ static void addAndDropDatabaseRole() {
3638
String databaseId = "my-database";
3739
String parentRole = "parent_role";
3840
String childRole = "child_role";
39-
addAndDropDatabaseRole(projectId, instanceId, databaseId, parentRole, childRole);
41+
addAndDropDatabaseRole(projectId, instanceId, databaseId, parentRole, childRole, "Albums");
4042
}
4143

4244
static void addAndDropDatabaseRole(
4345
String projectId, String instanceId, String databaseId,
44-
String parentRole, String childRole) {
46+
String parentRole, String childRole, String... tables) {
4547
try (Spanner spanner =
4648
SpannerOptions.newBuilder()
4749
.setProjectId(projectId)
4850
.build()
4951
.getService();
5052
DatabaseAdminClient databaseAdminClient = spanner.createDatabaseAdminClient()) {
5153
System.out.println("Waiting for role create operation to complete...");
54+
List<String> roleStatements = new ArrayList<>(ImmutableList.of(
55+
String.format("CREATE ROLE %s", parentRole),
56+
String.format("CREATE ROLE %s", childRole),
57+
String.format("GRANT ROLE %s TO ROLE %s", parentRole, childRole)));
58+
for(String table: tables) {
59+
roleStatements.add(String.format("GRANT SELECT ON TABLE %s TO ROLE %s", table, parentRole));
60+
}
5261
databaseAdminClient.updateDatabaseDdlAsync(
53-
DatabaseName.of(projectId, instanceId, databaseId),
54-
ImmutableList.of(
55-
String.format("CREATE ROLE %s", parentRole),
56-
String.format("GRANT SELECT ON TABLE Albums TO ROLE %s", parentRole),
57-
String.format("CREATE ROLE %s", childRole),
58-
String.format("GRANT ROLE %s TO ROLE %s", parentRole, childRole)))
62+
DatabaseName.of(projectId, instanceId, databaseId), roleStatements)
5963
.get(5, TimeUnit.MINUTES);
6064
System.out.printf(
6165
"Created roles %s and %s and granted privileges%n", parentRole, childRole);

samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) {
631631
Statement updateStatement =
632632
Statement.newBuilder(
633633
"UPDATE Albums "
634-
+ "SET MarketingBudget = $1"
634+
+ "SET MarketingBudget = $1 "
635635
+ "WHERE SingerId = 1 and AlbumId = 1")
636636
.bind("p1")
637637
.to(album1Budget)
@@ -640,7 +640,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) {
640640
Statement updateStatement2 =
641641
Statement.newBuilder(
642642
"UPDATE Albums "
643-
+ "SET MarketingBudget = $1"
643+
+ "SET MarketingBudget = $1 "
644644
+ "WHERE SingerId = 2 and AlbumId = 2")
645645
.bind("p1")
646646
.to(album2Budget)

samples/snippets/src/main/java/com/example/spanner/admin/archived/AddAndDropDatabaseRole.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static void addAndDropDatabaseRole(
5353
databaseId,
5454
ImmutableList.of(
5555
"CREATE ROLE " + parentRole,
56+
"GRANT SELECT ON TABLE Singers TO ROLE " + parentRole,
5657
"GRANT SELECT ON TABLE Albums TO ROLE " + parentRole,
5758
"CREATE ROLE " + childRole,
5859
"GRANT ROLE " + parentRole + " TO ROLE " + childRole),

samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateSequenceSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void createSequence(String projectId, String instanceId, String databaseI
5858
.get(5, TimeUnit.MINUTES);
5959

6060
System.out.println(
61-
"Created Seq sequence and Customers table, where the key column CustomerId "
61+
"Created Seq sequence and Customers table, where its key column CustomerId "
6262
+ "uses the sequence as a default value");
6363

6464
final DatabaseClient dbClient =

samples/snippets/src/main/java/com/example/spanner/admin/archived/PgSpannerSample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ static void createPostgreSqlDatabase(DatabaseAdminClient dbAdminClient, Database
203203
// Initiate the request which returns an OperationFuture.
204204
Database db = op.get();
205205
System.out.println("Created database [" + db.getId() + "]");
206-
createTableUsingDdl(dbAdminClient, id);
207206
} catch (ExecutionException e) {
208207
// If the operation failed during execution, expose the cause.
209208
throw (SpannerException) e.getCause();

samples/snippets/src/test/java/com/example/spanner/CreateIncrementalBackupScheduleSampleIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public class CreateIncrementalBackupScheduleSampleIT extends SampleTestBaseV2 {
3333
public void testCreateIncrementalBackupScheduleSample() throws Exception {
3434
String backupScheduleId = String.format("schedule-%s", UUID.randomUUID());
3535
BackupScheduleName backupScheduleName =
36-
BackupScheduleName.of(projectId, instanceId, databaseId, backupScheduleId);
36+
BackupScheduleName.of(projectId, multiRegionalInstanceId, databaseId, backupScheduleId);
3737
String out =
3838
SampleRunner.runSample(
3939
() -> {
4040
try {
4141
CreateIncrementalBackupScheduleSample.createIncrementalBackupSchedule(
42-
projectId, instanceId, databaseId, backupScheduleId);
42+
projectId, multiRegionalInstanceId, databaseId, backupScheduleId);
4343
} finally {
4444
DeleteBackupScheduleSample.deleteBackupSchedule(
45-
projectId, instanceId, databaseId, backupScheduleId);
45+
projectId, multiRegionalInstanceId, databaseId, backupScheduleId);
4646
}
4747
});
4848
assertThat(out)

0 commit comments

Comments
 (0)