mirror of
https://github.com/google/nomulus
synced 2026-01-03 03:35:42 +00:00
Hardcode beam pipelines to use GKE for tasks (#2753)
This commit is contained in:
@@ -61,6 +61,7 @@ def fragileTestPatterns = [
|
|||||||
// Currently changes a global configuration parameter that for some reason
|
// Currently changes a global configuration parameter that for some reason
|
||||||
// results in timestamp inversions for other tests. TODO(mmuller): fix.
|
// results in timestamp inversions for other tests. TODO(mmuller): fix.
|
||||||
"google/registry/flows/host/HostInfoFlowTest.*",
|
"google/registry/flows/host/HostInfoFlowTest.*",
|
||||||
|
"google/registry/beam/common/RegistryPipelineWorkerInitializerTest.*",
|
||||||
] + dockerIncompatibleTestPatterns
|
] + dockerIncompatibleTestPatterns
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class RegistryPipelineWorkerInitializer implements JvmInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeProcessing(PipelineOptions options) {
|
public void beforeProcessing(PipelineOptions options) {
|
||||||
|
// TODO(b/416299900): remove next line after GAE is removed.
|
||||||
|
System.setProperty("google.registry.jetty", "true");
|
||||||
RegistryPipelineOptions registryOptions = options.as(RegistryPipelineOptions.class);
|
RegistryPipelineOptions registryOptions = options.as(RegistryPipelineOptions.class);
|
||||||
RegistryEnvironment environment = registryOptions.getRegistryEnvironment();
|
RegistryEnvironment environment = registryOptions.getRegistryEnvironment();
|
||||||
if (environment == null || environment.equals(RegistryEnvironment.UNITTEST)) {
|
if (environment == null || environment.equals(RegistryEnvironment.UNITTEST)) {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// Copyright 2025 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.beam.common;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import google.registry.util.RegistryEnvironment;
|
||||||
|
import org.apache.beam.sdk.options.PipelineOptionsFactory;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class RegistryPipelineWorkerInitializerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test() {
|
||||||
|
RegistryPipelineOptions options =
|
||||||
|
PipelineOptionsFactory.fromArgs(
|
||||||
|
"--registryEnvironment=ALPHA", "--isolationOverride=TRANSACTION_SERIALIZABLE")
|
||||||
|
.withValidation()
|
||||||
|
.as(RegistryPipelineOptions.class);
|
||||||
|
new RegistryPipelineWorkerInitializer().beforeProcessing(options);
|
||||||
|
assertThat(RegistryEnvironment.isOnJetty()).isTrue();
|
||||||
|
System.clearProperty("google.registry.jetty");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,9 +61,6 @@ public enum RegistryEnvironment {
|
|||||||
/** Name of the environmental variable of the container name. */
|
/** Name of the environmental variable of the container name. */
|
||||||
private static final String CONTAINER_ENV = "CONTAINER_NAME";
|
private static final String CONTAINER_ENV = "CONTAINER_NAME";
|
||||||
|
|
||||||
private static final boolean ON_JETTY =
|
|
||||||
Boolean.parseBoolean(System.getProperty(JETTY_PROPERTY, "false"));
|
|
||||||
|
|
||||||
private static final boolean IS_CANARY =
|
private static final boolean IS_CANARY =
|
||||||
System.getenv().getOrDefault(CONTAINER_ENV, "").endsWith("-canary");
|
System.getenv().getOrDefault(CONTAINER_ENV, "").endsWith("-canary");
|
||||||
|
|
||||||
@@ -100,8 +97,9 @@ public enum RegistryEnvironment {
|
|||||||
return valueOf(Ascii.toUpperCase(System.getProperty(PROPERTY, UNITTEST.name())));
|
return valueOf(Ascii.toUpperCase(System.getProperty(PROPERTY, UNITTEST.name())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(b/416299900): remove method after GAE is removed.
|
||||||
public static boolean isOnJetty() {
|
public static boolean isOnJetty() {
|
||||||
return ON_JETTY;
|
return Boolean.parseBoolean(System.getProperty(JETTY_PROPERTY, "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCanary() {
|
public static boolean isCanary() {
|
||||||
|
|||||||
Reference in New Issue
Block a user