mirror of
https://github.com/google/nomulus.git
synced 2025-06-10 06:24:45 +02:00
Require explict tag when starting psql docker (#368)
* Require explict tag when starting psql docker Defined a util class to return docker tag of desired PSQL version. Class is defined in ':db' and shared by ':db' and ':core'. Used an artifact declaration to exclude unnecesary compile dependencies. Added a presubmit check for instantiations without explicit tag.
This commit is contained in:
parent
bd27840068
commit
8e3b7b4efb
10 changed files with 69 additions and 7 deletions
|
@ -92,8 +92,23 @@ task schemaJar(type: Jar) {
|
|||
}
|
||||
}
|
||||
|
||||
// Expose NomulusPostgreSql class to ':core' for compile, without leaking
|
||||
// unnecessary dependencies to the release artifacts through ':core'.
|
||||
// Jar is put in the 'compileApi' configuration.
|
||||
task compileApiJar(type: Jar) {
|
||||
archiveBaseName = 'compile'
|
||||
from(sourceSets.main.output) {
|
||||
include 'google/registry/persistence/NomulusPostgreSql**'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
compileApi
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives schemaJar
|
||||
compileApi compileApiJar
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package google.registry.persistence;
|
||||
|
||||
/** Information about Nomulus' Cloud SQL PostgreSql instance. */
|
||||
public class NomulusPostgreSql {
|
||||
|
||||
/** The current PostgreSql version in Cloud SQL. */
|
||||
// TODO(weiminyu): setup periodic checks to detect version changes in Cloud SQL.
|
||||
// TODO(weiminyu): Upgrade to 11.5, which apparently breaks JpaTransactionManagerRule.
|
||||
private static final String TARGET_VERSION = "9.6.12";
|
||||
|
||||
/** Returns the docker image tag of the targeted Postgresql server version. */
|
||||
public static String getDockerTag() {
|
||||
return "postgres:" + TARGET_VERSION;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.TextDiffSubject.assertThat;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.io.Resources;
|
||||
import google.registry.persistence.NomulusPostgreSql;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -54,7 +55,7 @@ public class SchemaTest {
|
|||
*/
|
||||
@Rule
|
||||
public PostgreSQLContainer sqlContainer =
|
||||
new PostgreSQLContainer<>("postgres:9.6.12")
|
||||
new PostgreSQLContainer<>(NomulusPostgreSql.getDockerTag())
|
||||
.withClasspathResourceMapping(
|
||||
MOUNTED_RESOURCE_PATH, CONTAINER_MOUNT_POINT, BindMode.READ_WRITE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue