From 3f98186a0d5840c94b48aca8eacc5c043c1c45c3 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 09:38:04 -0700 Subject: [PATCH 1/6] automl: break tests into individual files --- ...ManagementIT.java => DeleteModelTest.java} | 65 +-------------- .../automl/GetModelEvaluationTest.java | 82 +++++++++++++++++++ .../java/com/example/automl/GetModelTest.java | 71 ++++++++++++++++ .../automl/GetOperationStatusTest.java | 80 ++++++++++++++++++ .../automl/ListModelEvaluationsTest.java | 71 ++++++++++++++++ .../com/example/automl/ListModelsTest.java | 70 ++++++++++++++++ .../automl/ListOperationStatusTest.java | 70 ++++++++++++++++ 7 files changed, 448 insertions(+), 61 deletions(-) rename automl/cloud-client/src/test/java/com/example/automl/{GenericModelManagementIT.java => DeleteModelTest.java} (53%) create mode 100644 automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java diff --git a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java similarity index 53% rename from automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java index 6813cf04bd9..fece3f4d6f0 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Google LLC + * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,20 +31,16 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl models. @RunWith(JUnit4.class) -public class GenericModelManagementIT { +public class DeleteModelTest { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private String modelId; - private String modelEvaluationId; 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 @@ -65,59 +61,6 @@ public void tearDown() { System.setOut(null); } - @Test - public void testModelApi() throws IOException { - // LIST MODELS - ListModels.listModels(PROJECT_ID); - String got = bout.toString(); - modelId = got.split("Model id: ")[1].split("\n")[0]; - assertThat(got).contains("Model id:"); - - // GET MODEL - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - GetModel.getModel(PROJECT_ID, modelId); - got = bout.toString(); - assertThat(got).contains("Model id: " + modelId); - - // LIST MODEL EVALUATIONS - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - ListModelEvaluations.listModelEvaluations(PROJECT_ID, modelId); - got = bout.toString(); - modelEvaluationId = got.split(modelId + "/modelEvaluations/")[1].split("\n")[0]; - assertThat(got).contains("Model Evaluation Name:"); - - // GET MODEL EVALUATION - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - GetModelEvaluation.getModelEvaluation(PROJECT_ID, modelId, modelEvaluationId); - got = bout.toString(); - assertThat(got).contains("Model Evaluation Name:"); - } - - @Test - public void testOperationStatus() throws IOException { - // Act - ListOperationStatus.listOperationStatus(PROJECT_ID); - - // Assert - String got = bout.toString(); - String operationId = got.split("\n")[1].split(":")[1].trim(); - assertThat(got).contains("Operation details:"); - - // Act - bout.reset(); - GetOperationStatus.getOperationStatus(operationId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Operation details:"); - } - @Test public void testDeleteModel() { // As model creation can take many hours, instead try to delete a diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java new file mode 100644 index 00000000000..94b11758d1e --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class GetModelEvaluationTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String MODEL_ID = "TEN1974951581904273408"; + private String modelEvaluationId; + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() throws IOException { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + + // Get a model evaluation ID from the List request first to be used in the Get call + ListModelEvaluations.listModelEvaluations(PROJECT_ID, MODEL_ID); + String got = bout.toString(); + modelEvaluationId = got.split(MODEL_ID + "/modelEvaluations/")[1].split("\n")[0]; + assertThat(got).contains("Model Evaluation Name:"); + + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testGetModelEvaluation() throws IOException { + GetModelEvaluation.getModelEvaluation(PROJECT_ID, MODEL_ID, modelEvaluationId); + String got = bout.toString(); + assertThat(got).contains("Model Evaluation Name:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java new file mode 100644 index 00000000000..d17d97de6f3 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class GetModelTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String MODEL_ID = "TEN1974951581904273408"; + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testGetModel() throws IOException { + GetModel.getModel(PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("Model id: " + MODEL_ID); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java new file mode 100644 index 00000000000..ceac4152af3 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java @@ -0,0 +1,80 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class GetOperationStatusTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private String operationId; + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() throws IOException { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + + ListOperationStatus.listOperationStatus(PROJECT_ID); + String got = bout.toString(); + operationId = got.split("\n")[1].split(":")[1].trim(); + assertThat(got).contains("Operation details:"); + + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testGetOperationStatus() throws IOException { + GetOperationStatus.getOperationStatus(operationId); + String got = bout.toString(); + assertThat(got).contains("Operation details:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java new file mode 100644 index 00000000000..16fcab427b1 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ListModelEvaluationsTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String MODEL_ID = "TEN1974951581904273408"; + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testListModelEvaluations() throws IOException { + ListModelEvaluations.listModelEvaluations(PROJECT_ID, MODEL_ID); + String got = bout.toString(); + assertThat(got).contains("Model Evaluation Name:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java new file mode 100644 index 00000000000..bca40e93629 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ListModelsTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testListModels() throws IOException { + ListModels.listModels(PROJECT_ID); + String got = bout.toString(); + assertThat(got).contains("Model id:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java new file mode 100644 index 00000000000..c436d4c47d4 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2020 Google LLC + * + * 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 com.example.automl; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ListOperationStatusTest { + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + 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) + ); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testOperationStatus() throws IOException { + ListOperationStatus.listOperationStatus(PROJECT_ID); + String got = bout.toString(); + assertThat(got).contains("Operation details:"); + } +} From abb2318b4af425d6c6861cb978db1fa95740da5e Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 09:39:27 -0700 Subject: [PATCH 2/6] remove bom from automl until bom is released with v1 of client library --- automl/cloud-client/pom.xml | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/automl/cloud-client/pom.xml b/automl/cloud-client/pom.xml index cd7ec71a4f3..27d243ff225 100644 --- a/automl/cloud-client/pom.xml +++ b/automl/cloud-client/pom.xml @@ -27,30 +27,17 @@ - 1.11 - 1.11 + 11 + 11 UTF-8 - - - - - - com.google.cloud - libraries-bom - 3.0.0 - pom - import - - - - + com.google.cloud google-cloud-automl + 0.115.1-beta @@ -77,7 +64,5 @@ 1.0 test - - \ No newline at end of file From c0bf3b43b1c1385f500745430dfad3673c099387 Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Fri, 3 Jan 2020 09:43:26 -0700 Subject: [PATCH 3/6] Update DeleteModelTest.java --- .../src/test/java/com/example/automl/DeleteModelTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java b/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java index fece3f4d6f0..789cbf90f13 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/DeleteModelTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 Google LLC + * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From f474d48d8105de044aae24a9f41a4730efb2be0c Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 09:46:13 -0700 Subject: [PATCH 4/6] run code formatter --- .../test/java/com/example/automl/GetModelEvaluationTest.java | 5 ++--- .../src/test/java/com/example/automl/GetModelTest.java | 5 ++--- .../test/java/com/example/automl/GetOperationStatusTest.java | 5 ++--- .../java/com/example/automl/ListModelEvaluationsTest.java | 5 ++--- .../src/test/java/com/example/automl/ListModelsTest.java | 5 ++--- .../java/com/example/automl/ListOperationStatusTest.java | 5 ++--- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java index 94b11758d1e..049efc4972b 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java @@ -40,9 +40,8 @@ public class GetModelEvaluationTest { 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 diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java index d17d97de6f3..eda27554d78 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java @@ -39,9 +39,8 @@ public class GetModelTest { 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 diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java index ceac4152af3..95f97fd08e6 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java @@ -39,9 +39,8 @@ public class GetOperationStatusTest { 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 diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java index 16fcab427b1..14f8265901f 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java @@ -39,9 +39,8 @@ public class ListModelEvaluationsTest { 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 diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java index bca40e93629..dcb83d4ea4a 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java @@ -38,9 +38,8 @@ public class ListModelsTest { 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 diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java index c436d4c47d4..26a0ff26c1c 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java @@ -38,9 +38,8 @@ public class ListOperationStatusTest { 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 From f01d3c8c06080488925132cdcb67615acea5e3e1 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 11:53:15 -0700 Subject: [PATCH 5/6] Remove file that has been replaced by VisionClassificationDeployModelNodeCountTest --- ...VisionClassificationModelManagementIT.java | 94 ------------------- 1 file changed, 94 deletions(-) delete mode 100644 automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java deleted file mode 100644 index cf1ab01076c..00000000000 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * 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 com.example.automl; - -import static com.google.common.truth.Truth.assertThat; -import static junit.framework.TestCase.assertNotNull; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; - -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 image classification models. -@RunWith(JUnit4.class) -@Ignore -public class VisionClassificationModelManagementIT { - private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String MODEL_ID = System.getenv("VISION_CLASSIFICATION_MODEL_ID"); - 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) - ); - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("AUTOML_PROJECT_ID"); - requireEnvVar("VISION_CLASSIFICATION_MODEL_ID"); - } - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @After - public void tearDown() { - System.setOut(null); - } - - @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"); - - VisionClassificationDeployModelNodeCount.visionClassificationDeployModelNodeCount( - PROJECT_ID, MODEL_ID); - got = bout.toString(); - assertThat(got).contains("Model deployment finished"); - } -} From f8528299f54e1776a5e508eac8ebbae1049718d3 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 11:57:17 -0700 Subject: [PATCH 6/6] Update tests to use centralized automl testing project --- .../java/com/example/automl/GetModelEvaluationTest.java | 7 ++++--- .../src/test/java/com/example/automl/GetModelTest.java | 7 ++++--- .../java/com/example/automl/GetOperationStatusTest.java | 4 ++-- .../java/com/example/automl/ListModelEvaluationsTest.java | 7 ++++--- .../src/test/java/com/example/automl/ListModelsTest.java | 4 ++-- .../java/com/example/automl/ListOperationStatusTest.java | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java index 049efc4972b..41c393e402b 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelEvaluationTest.java @@ -32,8 +32,8 @@ @RunWith(JUnit4.class) public class GetModelEvaluationTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "TEN1974951581904273408"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); private String modelEvaluationId; private ByteArrayOutputStream bout; private PrintStream out; @@ -47,7 +47,8 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java index eda27554d78..977c95d076e 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetModelTest.java @@ -32,8 +32,8 @@ @RunWith(JUnit4.class) public class GetModelTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "TEN1974951581904273408"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -46,7 +46,8 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java index 95f97fd08e6..7093cf354cb 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetOperationStatusTest.java @@ -32,7 +32,7 @@ @RunWith(JUnit4.class) public class GetOperationStatusTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); private String operationId; private ByteArrayOutputStream bout; private PrintStream out; @@ -46,7 +46,7 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java index 14f8265901f..d9fd170eef6 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelEvaluationsTest.java @@ -32,8 +32,8 @@ @RunWith(JUnit4.class) public class ListModelEvaluationsTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "TEN1974951581904273408"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -46,7 +46,8 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java index dcb83d4ea4a..eec6778539d 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListModelsTest.java @@ -32,7 +32,7 @@ @RunWith(JUnit4.class) public class ListModelsTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -45,7 +45,7 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java index 26a0ff26c1c..6e78ae5fb11 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListOperationStatusTest.java @@ -32,7 +32,7 @@ @RunWith(JUnit4.class) public class ListOperationStatusTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -45,7 +45,7 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); } @Before