Skip to content

Commit 4fe15ec

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

File tree

18 files changed

+84
-37
lines changed

18 files changed

+84
-37
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/pom.xml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,6 @@
352352
<scope>runtime</scope>
353353
</dependency>
354354

355-
<dependency>
356-
<groupId>org.graalvm.sdk</groupId>
357-
<artifactId>graal-sdk</artifactId>
358-
<version>${graal-sdk.version}</version>
359-
<scope>provided</scope>
360-
</dependency>
361-
<dependency>
362-
<groupId>org.graalvm.sdk</groupId>
363-
<artifactId>nativeimage</artifactId>
364-
<version>${graal-sdk.version}</version>
365-
<scope>provided</scope>
366-
</dependency>
367-
368355
<!-- Test dependencies -->
369356
<dependency>
370357
<groupId>junit</groupId>
@@ -457,6 +444,46 @@
457444
</dependency>
458445
</dependencies>
459446
<profiles>
447+
<profile>
448+
<id>graalvm</id>
449+
<activation>
450+
<jdk>[11,)</jdk>
451+
</activation>
452+
<dependencies>
453+
<dependency>
454+
<groupId>org.graalvm.sdk</groupId>
455+
<artifactId>graal-sdk</artifactId>
456+
<version>${graal-sdk.version}</version>
457+
<scope>provided</scope>
458+
</dependency>
459+
<dependency>
460+
<groupId>org.graalvm.sdk</groupId>
461+
<artifactId>nativeimage</artifactId>
462+
<version>${graal-sdk.version}</version>
463+
<scope>provided</scope>
464+
</dependency>
465+
</dependencies>
466+
</profile>
467+
<profile>
468+
<id>graalvm-java8</id>
469+
<activation>
470+
<jdk>(,11)</jdk>
471+
</activation>
472+
<build>
473+
<plugins>
474+
<plugin>
475+
<groupId>org.apache.maven.plugins</groupId>
476+
<artifactId>maven-compiler-plugin</artifactId>
477+
<version>3.13.0</version>
478+
<configuration combine.self="append">
479+
<excludes>
480+
<exclude>**/nativeimage/SpannerFeature.java</exclude>
481+
</excludes>
482+
</configuration>
483+
</plugin>
484+
</plugins>
485+
</build>
486+
</profile>
460487
<profile>
461488
<id>java9</id>
462489
<activation>

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();

0 commit comments

Comments
 (0)