diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/DeployModelTest.java similarity index 66% rename from automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/DeployModelTest.java index a49c8c8d4e6..7cc11d62395 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/DeployModelTest.java @@ -27,32 +27,27 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl natural language entity extraction models. @RunWith(JUnit4.class) -@Ignore -public class LanguageEntityExtractionModelManagementIT { +public class DeployModelTest { private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); + private static final String MODEL_ID = "TEN0000000000000000000"; private ByteArrayOutputStream bout; private PrintStream out; private static void requireEnvVar(String varName) { assertNotNull( - System.getenv(varName), - "Environment variable '%s' is required to perform these tests.".format(varName) - ); + System.getenv(varName), + "Environment variable '%s' is required to perform these tests.".format(varName)); } @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("AUTOML_PROJECT_ID"); - requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); } @Before @@ -68,14 +63,16 @@ public void tearDown() { } @Test - public void testDeployUndeployModel() - throws IOException, ExecutionException, InterruptedException { - UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); - String got = bout.toString(); - assertThat(got).contains("Model undeployment finished"); - - DeployModel.deployModel(PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); + public void testDeployModel() { + // As model deployment can take a long time, instead try to deploy a + // nonexistent model and confirm that the model was not found, but other + // elements of the request were valid. + try { + DeployModel.deployModel(PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("The model does not exist"); + } catch (IOException | ExecutionException | InterruptedException e) { + assertThat(e.getMessage()).contains("The model does not exist"); + } } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/UndeployModelTest.java similarity index 66% rename from automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/UndeployModelTest.java index 72e495c73d9..43b8485a642 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/UndeployModelTest.java @@ -27,32 +27,27 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl natural language sentiment analysis models. @RunWith(JUnit4.class) -@Ignore -public class LanguageSentimentAnalysisModelManagementIT { +public class UndeployModelTest { private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String MODEL_ID = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID"); + private static final String MODEL_ID = "TEN0000000000000000000"; private ByteArrayOutputStream bout; private PrintStream out; private static void requireEnvVar(String varName) { assertNotNull( - System.getenv(varName), - "Environment variable '%s' is required to perform these tests.".format(varName) - ); + System.getenv(varName), + "Environment variable '%s' is required to perform these tests.".format(varName)); } @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("AUTOML_PROJECT_ID"); - requireEnvVar("SENTIMENT_ANALYSIS_MODEL_ID"); } @Before @@ -68,14 +63,16 @@ public void tearDown() { } @Test - public void testDeployUndeployModel() - throws IOException, ExecutionException, InterruptedException { - UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); - String got = bout.toString(); - assertThat(got).contains("Model undeployment finished"); - - DeployModel.deployModel(PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); + public void testUndeployModel() { + // As model deployment can take a long time, instead try to deploy a + // nonexistent model and confirm that the model was not found, but other + // elements of the request were valid. + try { + UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("The model does not exist"); + } catch (IOException | ExecutionException | InterruptedException e) { + assertThat(e.getMessage()).contains("The model does not exist"); + } } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDeployModelNodeCountTest.java similarity index 65% rename from automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDeployModelNodeCountTest.java index e0f4e5c3d2f..e7f242bd159 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDeployModelNodeCountTest.java @@ -27,32 +27,27 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl natural language text classification models. @RunWith(JUnit4.class) -@Ignore -public class LanguageTextClassificationModelManagementIT { +public class VisionClassificationDeployModelNodeCountTest { private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String MODEL_ID = System.getenv("TEXT_CLASSIFICATION_MODEL_ID"); + private static final String MODEL_ID = "ICN0000000000000000000"; private ByteArrayOutputStream bout; private PrintStream out; private static void requireEnvVar(String varName) { assertNotNull( - System.getenv(varName), - "Environment variable '%s' is required to perform these tests.".format(varName) - ); + System.getenv(varName), + "Environment variable '%s' is required to perform these tests.".format(varName)); } @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("AUTOML_PROJECT_ID"); - requireEnvVar("TEXT_CLASSIFICATION_MODEL_ID"); } @Before @@ -68,14 +63,17 @@ public void tearDown() { } @Test - public void testDeployUndeployModel() - throws IOException, ExecutionException, InterruptedException { - UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); - String got = bout.toString(); - assertThat(got).contains("Model undeployment finished"); - - DeployModel.deployModel(PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); + public void testDeployModelWithNodeCount() { + // As model deployment can take a long time, instead try to deploy a + // nonexistent model and confirm that the model was not found, but other + // elements of the request were valid. + try { + VisionClassificationDeployModelNodeCount.visionClassificationDeployModelNodeCount( + PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("The model does not exist"); + } catch (IOException | ExecutionException | InterruptedException e) { + assertThat(e.getMessage()).contains("The model does not exist"); + } } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDeployModelNodeCountTest.java similarity index 56% rename from automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDeployModelNodeCountTest.java index 703ae7e12eb..bff3f83503f 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDeployModelNodeCountTest.java @@ -27,32 +27,27 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl vision object detection models. @RunWith(JUnit4.class) -@Ignore -public class VisionObjectDetectionModelManagementIT { +public class VisionObjectDetectionDeployModelNodeCountTest { private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String MODEL_ID = System.getenv("OBJECT_DETECTION_MODEL_ID"); + private static final String MODEL_ID = "0000000000000000000000"; private ByteArrayOutputStream bout; private PrintStream out; private static void requireEnvVar(String varName) { assertNotNull( - System.getenv(varName), - "Environment variable '%s' is required to perform these tests.".format(varName) - ); + System.getenv(varName), + "Environment variable '%s' is required to perform these tests.".format(varName)); } @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("AUTOML_PROJECT_ID"); - requireEnvVar("OBJECT_DETECTION_MODEL_ID"); } @Before @@ -68,27 +63,17 @@ public void tearDown() { } @Test - public void testDeployUndeployModel() - throws IOException, ExecutionException, InterruptedException { - UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); - String got = bout.toString(); - assertThat(got).contains("Model undeployment finished"); - - DeployModel.deployModel(PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); - } - - @Test - public void testDeployUndeployModelWithNodeCount() - throws IOException, ExecutionException, InterruptedException { - UndeployModel.undeployModel(PROJECT_ID, MODEL_ID); - String got = bout.toString(); - assertThat(got).contains("Model undeployment finished"); - - VisionObjectDetectionDeployModelNodeCount.visionObjectDetectionDeployModelNodeCount( - PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); + public void testDeployModelWithNodeCount() { + // As model deployment can take a long time, instead try to deploy a + // nonexistent model and confirm that the model was not found, but other + // elements of the request were valid. + try { + VisionObjectDetectionDeployModelNodeCount.visionObjectDetectionDeployModelNodeCount( + PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("The model does not exist"); + } catch (IOException | ExecutionException | InterruptedException e) { + assertThat(e.getMessage()).contains("The model does not exist"); + } } }