1
0
mirror of https://github.com/google/nomulus synced 2026-05-24 08:41:48 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Lai Jiang
c4721121eb Move soyutils_usegoog.js out of node_modules (#342)
* Move soyutils_usegoog.js out of node_modules

Everytime the npmInstall runs, it removes this file from node_modules.
Move it outside the folder to prevent this from happening.

* Move karma.conf.js and soyutils_usegooge.js

* Move karma.conf.js to be under core
2019-11-04 15:22:32 -05:00
Weimin Yu
37b9999cfc Release SQL schema in Cloud Build (#341)
* Release SQL schema in Cloud Build

Tentatively release SQL schema at the same time as the server release.
Publish schema jar to gs://domain-registry-maven-repository/nomulus
and also upload it with server artifacts.

Also removed the Gradle 'version' variable which is not used.

Tested=On cloud-build with a simplified version of
cloudbuild-nomulus.yaml.
2019-11-04 10:22:05 -05:00
Ben McIlwain
5f62f91cd5 Don't wrap exceptions thrown inside Cloud SQL transactions (#338)
* Don't wrap exceptions thrown inside Cloud SQL transactions

There's no reason to wrap them in PersistenceException, and it makes dealing
with thrown exceptions harder as seen in the diffs on test classes in this
commit.
2019-11-03 14:08:31 -05:00
13 changed files with 34 additions and 37 deletions

1
.gitignore vendored
View File

@@ -98,7 +98,6 @@ nomulus.iws
.gradle/
**/build
node_modules/**
!node_modules/soyutils_usegoog.js
/repos/
# Compiled JS/CSS code

View File

@@ -80,7 +80,7 @@ PRESUBMITS = {
".git", "/build/", "/generated/", "node_modules/",
"JUnitBackports.java", "registrar_bin.", "registrar_dbg.",
"google-java-format-diff.py",
"nomulus.golden.sql"
"nomulus.golden.sql", "soyutils_usegoog.js"
}, REQUIRED):
"File did not include the license header.",

View File

@@ -523,7 +523,7 @@ task compileProdJS(type: JavaExec) {
// manually include all the required js files
closureArgs << "--js=${nodeModulesDir}/google-closure-library/**.js"
closureArgs << "--js=${nodeModulesDir}/soyutils_usegoog.js"
closureArgs << "--js=${jsDir}/soyutils_usegoog.js"
closureArgs << "--js=${cssSourceDir}/registrar_bin.css.js"
closureArgs << "--js=${jsSourceDir}/**.js"
// TODO(shicong) Verify the compiled JS file works in Alpha
@@ -555,7 +555,7 @@ task karmaTest(type: Exec) {
dependsOn ':npmInstall'
workingDir rootProject.projectDir
executable 'node_modules/karma/bin/karma'
args('start')
args('start', "${project.projectDir}/karma.conf.js")
}
test.dependsOn karmaTest

View File

@@ -16,6 +16,7 @@ process.env.CHROME_BIN = require('puppeteer').executablePath()
module.exports = function(config) {
config.set({
basePath: '..',
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {

View File

@@ -41,6 +41,7 @@ public final class RegistryLockDao {
Long.class)
.setParameter("verificationCode", verificationCode)
.getSingleResult();
// TODO(gbrodman): Don't throw NPE here. Maybe NoResultException fits better?
checkNotNull(revisionId, "No registry lock with this code");
return em.find(RegistryLock.class, revisionId);
});

View File

@@ -79,17 +79,14 @@ public class JpaTransactionManagerImpl implements JpaTransactionManager {
T result = work.run();
txn.commit();
return result;
} catch (Throwable transactionException) {
String rollbackMessage;
} catch (RuntimeException e) {
try {
txn.rollback();
rollbackMessage = "transaction rolled back";
logger.atWarning().log("Error during transaction; transaction rolled back");
} catch (Throwable rollbackException) {
logger.atSevere().withCause(rollbackException).log("Rollback failed, suppressing error");
rollbackMessage = "transaction rollback failed";
logger.atSevere().withCause(rollbackException).log("Rollback failed; suppressing error");
}
throw new PersistenceException(
"Error during transaction, " + rollbackMessage, transactionException);
throw e;
} finally {
txnInfo.clear();
}

View File

@@ -25,7 +25,6 @@ import google.registry.schema.domain.RegistryLock.Action;
import google.registry.testing.AppEngineRule;
import java.util.Optional;
import java.util.UUID;
import javax.persistence.PersistenceException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,15 +53,11 @@ public final class RegistryLockDaoTest {
public void testSaveAndLoad_failure_differentCode() {
RegistryLock lock = createLock();
RegistryLockDao.save(lock);
PersistenceException exception =
NullPointerException thrown =
assertThrows(
PersistenceException.class,
NullPointerException.class,
() -> RegistryLockDao.getByVerificationCode(UUID.randomUUID().toString()));
assertThat(exception)
.hasCauseThat()
.hasMessageThat()
.isEqualTo("No registry lock with this code");
assertThat(exception).hasCauseThat().isInstanceOf(NullPointerException.class);
assertThat(thrown).hasMessageThat().isEqualTo("No registry lock with this code");
}
@Test

View File

@@ -22,7 +22,6 @@ import google.registry.model.transaction.JpaTransactionManagerRule;
import google.registry.schema.tmch.ClaimsList;
import google.registry.testing.FakeClock;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,9 +70,7 @@ public class ClaimsListDaoTest {
@Test
public void getCurrent_throwsNoResultExceptionIfTableIsEmpty() {
PersistenceException thrown =
assertThrows(PersistenceException.class, () -> ClaimsListDao.getCurrent());
assertThat(thrown).hasCauseThat().isInstanceOf(NoResultException.class);
assertThrows(NoResultException.class, ClaimsListDao::getCurrent);
}
@Test

View File

@@ -75,11 +75,7 @@ public class CurrencyUnitConverterTest {
jpaTm()
.transact(
() -> jpaTm().getEntityManager().find(TestEntity.class, "id").currency));
assertThat(thrown)
.hasCauseThat()
.hasCauseThat()
.hasMessageThat()
.isEqualTo("Unknown currency 'XXXX'");
assertThat(thrown).hasCauseThat().hasMessageThat().isEqualTo("Unknown currency 'XXXX'");
}
@Entity(name = "TestEntity") // Override entity name to avoid the nested class reference.

View File

@@ -21,7 +21,6 @@ import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableMap;
import google.registry.model.transaction.JpaTransactionManagerRule;
import java.math.BigDecimal;
import javax.persistence.PersistenceException;
import org.joda.money.CurrencyUnit;
import org.junit.Rule;
import org.junit.Test;
@@ -68,16 +67,13 @@ public class PremiumListDaoTest {
@Test
public void saveNew_throwsWhenPremiumListAlreadyExists() {
PremiumListDao.saveNew(PremiumList.create("testlist", CurrencyUnit.USD, TEST_PRICES));
PersistenceException thrown =
IllegalArgumentException thrown =
assertThrows(
PersistenceException.class,
IllegalArgumentException.class,
() ->
PremiumListDao.saveNew(
PremiumList.create("testlist", CurrencyUnit.USD, TEST_PRICES)));
assertThat(thrown)
.hasCauseThat()
.hasMessageThat()
.contains("A premium list of this name already exists");
assertThat(thrown).hasMessageThat().contains("A premium list of this name already exists");
}
@Test

View File

@@ -54,7 +54,6 @@ tasks.withType(JavaCompile).configureEach {
}
}
version = '1.0'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

View File

@@ -65,7 +65,22 @@ steps:
# Build and package the deployment files for production.
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
args: ['release/build_nomulus_for_env.sh', 'production', 'output']
# The tarballs to upload to GCS.
# Tentatively build and publish Cloud SQL schema jar here, before schema release
# process is finalized.
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: /bin/bash
args:
- -c
- |
set -e
./gradlew \
:db:publish \
-PmavenUrl=https://storage.googleapis.com/domain-registry-maven-repository/maven \
-PpluginsUrl=https://storage.googleapis.com/domain-registry-maven-repository/plugins \
-Pschema_publish_repo=gcs://domain-registry-maven-repository/nomulus \
-Pschema_version=${TAG_NAME}
cp db/build/libs/schema.jar output/
# The tarballs and jars to upload to GCS.
artifacts:
objects:
location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}'
@@ -73,6 +88,7 @@ artifacts:
- 'output/*.tar'
- 'output/tag_name'
- 'output/nomulus.jar'
- 'output/schema.jar'
- 'release/cloudbuild-tag.yaml'
- 'release/cloudbuild-sync.yaml'
- 'release/cloudbuild-deploy-*.yaml'