From 6d4cdaf27155a905df488d971bb1fddf142d4943 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 11:10:52 -0700 Subject: [PATCH 01/10] automl: break up and simplify dataset tests --- .../com/example/automl/DeleteDatasetTest.java | 88 ++++++++++ ...nagementIT.java => ExportDatasetTest.java} | 85 ++-------- .../com/example/automl/GetDatasetTest.java | 72 ++++++++ ...nagementIT.java => ImportDatasetTest.java} | 100 ++--------- ...uageEntityExtractionCreateDatasetTest.java | 83 +++++++++ ...ageSentimentAnalysisCreateDatasetTest.java | 83 +++++++++ ...eSentimentAnalysisDatasetManagementIT.java | 157 ------------------ ...geTextClassificationCreateDatasetTest.java | 83 +++++++++ .../com/example/automl/ListDatasetsTest.java | 74 +++++++++ ...T.java => TranslateCreateDatasetTest.java} | 91 +--------- ...VisionClassificationCreateDatasetTest.java | 83 +++++++++ ...sionClassificationDatasetManagementIT.java | 156 ----------------- ...isionObjectDetectionCreateDatasetTest.java | 83 +++++++++ ...ionObjectDetectionDatasetManagementIT.java | 157 ------------------ 14 files changed, 690 insertions(+), 705 deletions(-) create mode 100644 automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java rename automl/cloud-client/src/test/java/com/example/automl/{LanguageTextClassificationDatasetManagementIT.java => ExportDatasetTest.java} (59%) create mode 100644 automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java rename automl/cloud-client/src/test/java/com/example/automl/{LanguageEntityExtractionDatasetManagementIT.java => ImportDatasetTest.java} (53%) create mode 100644 automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java delete mode 100644 automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java rename automl/cloud-client/src/test/java/com/example/automl/{TranslateDatasetManagementIT.java => TranslateCreateDatasetTest.java} (51%) create mode 100644 automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java delete mode 100644 automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java create mode 100644 automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java delete mode 100644 automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java diff --git a/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java new file mode 100644 index 00000000000..5327a8fd3cd --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java @@ -0,0 +1,88 @@ +/* + * 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 java.util.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class DeleteDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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 InterruptedException, ExecutionException, IOException { + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + + // Create a fake dataset to be deleted + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName); + String got = bout.toString(); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + } + + @After + public void tearDown() { + System.setOut(null); + } + + @Test + public void testDeleteDataset() throws IOException, ExecutionException, InterruptedException { + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + String got = bout.toString(); + assertThat(got).contains("Dataset deleted."); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java similarity index 59% rename from automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java index 54dcaacc429..7a3c53448fb 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.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. @@ -27,7 +27,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.util.UUID; import java.util.concurrent.ExecutionException; import org.junit.After; @@ -37,23 +36,21 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl natural language text classification datasets. @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") -public class LanguageTextClassificationDatasetManagementIT { +public class ExportDatasetTest { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String DATASET_ID = "TEN477786180780294144"; private static final String BUCKET_ID = PROJECT_ID + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; private ByteArrayOutputStream bout; private PrintStream out; - private String getdatasetId = "TCN2551826603472450019"; 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 @@ -71,68 +68,7 @@ public void setUp() { @After public void tearDown() { - System.setOut(null); - } - - @Test - public void testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { - // Create a random dataset name with a length of 32 characters (max allowed by AutoML) - // To prevent name collisions when running tests in multiple java versions at once. - // AutoML doesn't allow "-", but accepts "_" - String datasetName = - String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act - LanguageTextClassificationCreateDataset.createDataset(PROJECT_ID, datasetName); - - // Assert - String got = bout.toString(); - String datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - - // Act - ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/happiness.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); - } - - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert - String got = bout.toString(); - - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - String got = bout.toString(); - assertThat(got).contains("Dataset exported."); - + // Delete the created files from GCS Storage storage = StorageOptions.getDefaultInstance().getService(); Page blobs = storage.list( @@ -152,5 +88,14 @@ public void testExportDataset() throws IOException, ExecutionException, Interrup } } } + + System.setOut(null); + } + + @Test + public void testExportDataset() throws IOException, ExecutionException, InterruptedException { + ExportDataset.exportDataset(PROJECT_ID, DATASET_ID, BUCKET + "/TEST_EXPORT_OUTPUT/"); + String got = bout.toString(); + assertThat(got).contains("Dataset exported."); } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java new file mode 100644 index 00000000000..db8ba97bf94 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java @@ -0,0 +1,72 @@ +/* + * 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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class GetDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String DATASET_ID = "TEN477786180780294144"; + 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 testGetDataset() throws IOException { + GetDataset.getDataset(PROJECT_ID, DATASET_ID); + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java similarity index 53% rename from automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java index 550ff61e31e..1b77f0597e9 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.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. @@ -19,11 +19,6 @@ import static com.google.common.truth.Truth.assertThat; import static junit.framework.TestCase.assertNotNull; -import com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; @@ -37,23 +32,21 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl natural language entity extraction datasets @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") -public class LanguageEntityExtractionDatasetManagementIT { +public class ImportDatasetTest { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); private static final String BUCKET_ID = PROJECT_ID + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; + private String datasetId; private ByteArrayOutputStream bout; private PrintStream out; - private String getdatasetId = "TEN477786180780294144"; 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 @@ -63,94 +56,37 @@ public static void checkRequirements() { } @Before - public void setUp() { + public void setUp() throws InterruptedException, ExecutionException, IOException { bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); - } - @After - public void tearDown() { - System.setOut(null); - } - - @Test - public void testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { + // Create a dataset that can be used for the import test // Create a random dataset name with a length of 32 characters (max allowed by AutoML) // To prevent name collisions when running tests in multiple java versions at once. // AutoML doesn't allow "-", but accepts "_" String datasetName = String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName); - - // Assert String got = bout.toString(); - String datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - // Act - ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity_extraction/dataset.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); } - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); + @After + public void tearDown() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); } @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert + public void testImportDataset() throws IOException, ExecutionException, InterruptedException { + ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity_extraction/dataset.csv"); String got = bout.toString(); - assertThat(got).contains("Dataset id:"); } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - String got = bout.toString(); - assertThat(got).contains("Dataset exported."); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - Page blobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/")); - - for (Blob blob : blobs.iterateAll()) { - Page fileBlobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - for (Blob fileBlob : fileBlobs.iterateAll()) { - if (!fileBlob.isDirectory()) { - fileBlob.delete(); - } - } - } - } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java new file mode 100644 index 00000000000..9425f0641d1 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java @@ -0,0 +1,83 @@ +/* + * 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.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class LanguageEntityExtractionCreateDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); + } + + @Test + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName); + + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java new file mode 100644 index 00000000000..18a6bc6302e --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java @@ -0,0 +1,83 @@ +/* + * 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.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class LanguageSentimentAnalysisCreateDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); + } + + @Test + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + LanguageSentimentAnalysisCreateDataset.createDataset(PROJECT_ID, datasetName); + + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java deleted file mode 100644 index 64e07c3b349..00000000000 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java +++ /dev/null @@ -1,157 +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 com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -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; - -// Tests for Automl natural language sentiment analysis datasets. -@RunWith(JUnit4.class) -@SuppressWarnings("checkstyle:abbreviationaswordinname") -public class LanguageSentimentAnalysisDatasetManagementIT { - - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-lcm"; - private static final String BUCKET = "gs://" + BUCKET_ID; - private ByteArrayOutputStream bout; - private PrintStream out; - private String getdatasetId = "TST3960250460385409610"; - - 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 testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { - // Create a random dataset name with a length of 32 characters (max allowed by AutoML) - // To prevent name collisions when running tests in multiple java versions at once. - // AutoML doesn't allow "-", but accepts "_" - String datasetName = - String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act - LanguageSentimentAnalysisCreateDataset.createDataset(PROJECT_ID, datasetName); - - // Assert - String got = bout.toString(); - String datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - - // Act - ImportDataset.importDataset( - PROJECT_ID, datasetId, BUCKET + "/automl-sentiment/sentiment_dataset.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); - } - - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert - String got = bout.toString(); - - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - String got = bout.toString(); - assertThat(got).contains("Dataset exported."); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - Page blobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/")); - - for (Blob blob : blobs.iterateAll()) { - Page fileBlobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - for (Blob fileBlob : fileBlobs.iterateAll()) { - if (!fileBlob.isDirectory()) { - fileBlob.delete(); - } - } - } - } -} diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java new file mode 100644 index 00000000000..e76f7b7bae4 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java @@ -0,0 +1,83 @@ +/* + * 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.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class LanguageTextClassificationCreateDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); + } + + @Test + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + LanguageTextClassificationCreateDataset.createDataset(PROJECT_ID, datasetName); + + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java new file mode 100644 index 00000000000..c16fae2c2d0 --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java @@ -0,0 +1,74 @@ +/* + * 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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class ListDatasetsTest { + + 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 testListDataset() throws IOException { + // Act + ListDatasets.listDatasets(PROJECT_ID); + + // Assert + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java similarity index 51% rename from automl/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java rename to automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java index 62d8ea87e08..a798c3f9c23 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java @@ -19,11 +19,6 @@ import static com.google.common.truth.Truth.assertThat; import static junit.framework.TestCase.assertNotNull; -import com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; @@ -37,23 +32,19 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -// Tests for Automl translation datasets @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") -public class TranslateDatasetManagementIT { +public class TranslateCreateDatasetTest { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET = "gs://" + PROJECT_ID + "-vcm"; private ByteArrayOutputStream bout; private PrintStream out; private String datasetId; - private String getdatasetId = "TRL3946265060617537378"; 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 @@ -70,89 +61,23 @@ public void setUp() { } @After - public void tearDown() { + public void tearDown() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); System.setOut(null); } @Test - public void testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { // Create a random dataset name with a length of 32 characters (max allowed by AutoML) // To prevent name collisions when running tests in multiple java versions at once. // AutoML doesn't allow "-", but accepts "_" String datasetName = String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act TranslateCreateDataset.createDataset(PROJECT_ID, datasetName); - // Assert - String got = bout.toString(); - datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - - // Act - ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/en-ja-short.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); - } - - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - - String got = bout.toString(); - - assertThat(got).contains("Dataset exported."); - - Page blobs = - storage.list( - PROJECT_ID + "-vcm", - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/")); - - for (Blob blob : blobs.iterateAll()) { - Page fileBlobs = - storage.list( - PROJECT_ID + "-vcm", - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - for (Blob fileBlob : fileBlobs.iterateAll()) { - if (!fileBlob.isDirectory()) { - fileBlob.delete(); - } - } - } + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; } } diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java new file mode 100644 index 00000000000..3ac7b1d814f --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java @@ -0,0 +1,83 @@ +/* + * 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.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class VisionClassificationCreateDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); + } + + @Test + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + VisionClassificationCreateDataset.createDataset(PROJECT_ID, datasetName); + + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java deleted file mode 100644 index 90873692297..00000000000 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java +++ /dev/null @@ -1,156 +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 com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -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; - -// Tests for Automl vision image classification datasets. -@RunWith(JUnit4.class) -@SuppressWarnings("checkstyle:abbreviationaswordinname") -public class VisionClassificationDatasetManagementIT { - - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-vcm"; - private static final String BUCKET = "gs://" + BUCKET_ID; - private ByteArrayOutputStream bout; - private PrintStream out; - private String getdatasetId = "ICN3876092572857648864"; - - 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 testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { - // Create a random dataset name with a length of 32 characters (max allowed by AutoML) - // To prevent name collisions when running tests in multiple java versions at once. - // AutoML doesn't allow "-", but accepts "_" - String datasetName = - String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act - VisionClassificationCreateDataset.createDataset(PROJECT_ID, datasetName); - - // Assert - String got = bout.toString(); - String datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - - // Act - ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/flower_traindata.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); - } - - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert - String got = bout.toString(); - - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - String got = bout.toString(); - assertThat(got).contains("Dataset exported."); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - Page blobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/")); - - for (Blob blob : blobs.iterateAll()) { - Page fileBlobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - for (Blob fileBlob : fileBlobs.iterateAll()) { - if (!fileBlob.isDirectory()) { - fileBlob.delete(); - } - } - } - } -} diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java new file mode 100644 index 00000000000..c89abd8279b --- /dev/null +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java @@ -0,0 +1,83 @@ +/* + * 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.UUID; +import java.util.concurrent.ExecutionException; + +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) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class VisionObjectDetectionCreateDatasetTest { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private ByteArrayOutputStream bout; + private PrintStream out; + private String datasetId; + + 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() throws InterruptedException, ExecutionException, IOException { + // Delete the created dataset + DeleteDataset.deleteDataset(PROJECT_ID, datasetId); + System.setOut(null); + } + + @Test + public void testCreateDataset() throws IOException, ExecutionException, InterruptedException { + // Create a random dataset name with a length of 32 characters (max allowed by AutoML) + // To prevent name collisions when running tests in multiple java versions at once. + // AutoML doesn't allow "-", but accepts "_" + String datasetName = + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + VisionObjectDetectionCreateDataset.createDataset(PROJECT_ID, datasetName); + + String got = bout.toString(); + assertThat(got).contains("Dataset id:"); + datasetId = got.split("Dataset id: ")[1].split("\n")[0]; + } +} diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java deleted file mode 100644 index 0feb2187a6f..00000000000 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java +++ /dev/null @@ -1,157 +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 com.google.api.gax.paging.Page; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.UUID; -import java.util.concurrent.ExecutionException; - -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; - -// Tests for Automl vision object detection datasets. -@RunWith(JUnit4.class) -@SuppressWarnings("checkstyle:abbreviationaswordinname") -public class VisionObjectDetectionDatasetManagementIT { - - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-vcm"; - private static final String BUCKET = "gs://" + BUCKET_ID; - private ByteArrayOutputStream bout; - private PrintStream out; - private String getdatasetId = "IOD2036031651850485760"; - - 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 testCreateImportDeleteDataset() - throws IOException, ExecutionException, InterruptedException { - // Create a random dataset name with a length of 32 characters (max allowed by AutoML) - // To prevent name collisions when running tests in multiple java versions at once. - // AutoML doesn't allow "-", but accepts "_" - String datasetName = - String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - - // Act - VisionObjectDetectionCreateDataset.createDataset(PROJECT_ID, datasetName); - - // Assert - String got = bout.toString(); - String datasetId = got.split("Dataset id: ")[1].split("\n")[0]; - - // Act - ImportDataset.importDataset( - PROJECT_ID, datasetId, "gs://cloud-ml-data/img/openimage/csv/salads_ml_use.csv"); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset id:"); - - // Act - DeleteDataset.deleteDataset(PROJECT_ID, datasetId); - - // Assert - got = bout.toString(); - assertThat(got).contains("Dataset deleted."); - } - - @Test - public void testListDataset() throws IOException { - // Act - ListDatasets.listDatasets(PROJECT_ID); - - // Assert - String got = bout.toString(); - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testGetDataset() throws IOException { - // Act - GetDataset.getDataset(PROJECT_ID, getdatasetId); - - // Assert - String got = bout.toString(); - - assertThat(got).contains("Dataset id:"); - } - - @Test - public void testExportDataset() throws IOException, ExecutionException, InterruptedException { - ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/"); - - String got = bout.toString(); - assertThat(got).contains("Dataset exported."); - - Storage storage = StorageOptions.getDefaultInstance().getService(); - Page blobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/")); - - for (Blob blob : blobs.iterateAll()) { - Page fileBlobs = - storage.list( - BUCKET_ID, - Storage.BlobListOption.currentDirectory(), - Storage.BlobListOption.prefix(blob.getName())); - for (Blob fileBlob : fileBlobs.iterateAll()) { - if (!fileBlob.isDirectory()) { - fileBlob.delete(); - } - } - } - } -} From 52c2ebc40e67b277731212ecc04d7de58018fad6 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 11:11:08 -0700 Subject: [PATCH 02/10] 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 ccdd2c3421738f2ba50faaa0abe8d4c79c892771 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 11:25:26 -0700 Subject: [PATCH 03/10] Fix assert statement --- .../src/test/java/com/example/automl/ImportDatasetTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java index 1b77f0597e9..68c3c7a0ad5 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java @@ -87,6 +87,6 @@ public void tearDown() throws InterruptedException, ExecutionException, IOExcept public void testImportDataset() throws IOException, ExecutionException, InterruptedException { ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity_extraction/dataset.csv"); String got = bout.toString(); - assertThat(got).contains("Dataset id:"); + assertThat(got).contains("Dataset imported."); } } From 8549165a2fcaec31ee1df866548408130bcaef86 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 16:33:50 -0700 Subject: [PATCH 04/10] Update license years and clean up comments --- .../automl/LanguageEntityExtractionCreateDatasetTest.java | 2 +- .../automl/LanguageSentimentAnalysisCreateDatasetTest.java | 2 +- .../automl/LanguageTextClassificationCreateDatasetTest.java | 2 +- .../src/test/java/com/example/automl/ListDatasetsTest.java | 3 --- .../example/automl/VisionClassificationCreateDatasetTest.java | 2 +- .../example/automl/VisionObjectDetectionCreateDatasetTest.java | 2 +- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java index 9425f0641d1..5a7898c007a 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.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. diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java index 18a6bc6302e..a0f69b68b4f 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.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. diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java index e76f7b7bae4..bc9ad86fb68 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.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. diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java index c16fae2c2d0..f6a093d02b8 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java @@ -64,10 +64,7 @@ public void tearDown() { @Test public void testListDataset() throws IOException { - // Act ListDatasets.listDatasets(PROJECT_ID); - - // Assert String got = bout.toString(); assertThat(got).contains("Dataset id:"); } diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java index 3ac7b1d814f..9747870a2e3 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.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. diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java index c89abd8279b..6fac5440efd 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.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. From 528d07ee3f34f07275c010562c87b1120ed4afc3 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 16:34:32 -0700 Subject: [PATCH 05/10] Remove score_threshold from Batch Predict --- .../src/main/java/com/example/automl/BatchPredict.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java b/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java index 3eb4d9beaa8..3144f863544 100644 --- a/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java +++ b/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java @@ -62,8 +62,6 @@ static void batchPredict(String projectId, String modelId, String inputUri, Stri .setName(name.toString()) .setInputConfig(inputConfig) .setOutputConfig(outputConfig) - // [0.0-1.0] Only produce results higher than this value - .putParams("score_threshold", "0.8") .build(); OperationFuture future = From 05f8d25bbce72190d8cedab8063af850ae8c312a Mon Sep 17 00:00:00 2001 From: nnegrey Date: Fri, 3 Jan 2020 16:34:54 -0700 Subject: [PATCH 06/10] Fix typo in test --- .../com/example/automl/LanguageEntityExtractionPredictIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java index 7c9af56b6a6..2b84c67e90b 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java @@ -78,7 +78,7 @@ public void testPredict() throws IOException { // Assert String got = bout.toString(); - assertThat(got).contains("Text Extract Entity Types:"); + assertThat(got).contains("Text Extract Entity Type:"); } @Test From f2af154ce1eec361254ecddccdc273c0843e4698 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 10:26:44 -0700 Subject: [PATCH 07/10] Switch tests to use centralized automl project, temporarily ignore long running tests until fixed in following PRs --- .kokoro/tests/run_tests.sh | 1 + .../java/com/example/automl/DeleteDatasetTest.java | 4 ++-- .../java/com/example/automl/ExportDatasetTest.java | 3 ++- .../com/example/automl/GenericModelManagementIT.java | 4 ++-- .../test/java/com/example/automl/GetDatasetTest.java | 7 ++++--- .../java/com/example/automl/ImportDatasetTest.java | 5 +++-- .../LanguageEntityExtractionCreateDatasetTest.java | 4 ++-- .../LanguageEntityExtractionModelManagementIT.java | 9 ++++++--- .../automl/LanguageEntityExtractionPredictIT.java | 11 +++++++---- .../LanguageSentimentAnalysisCreateDatasetTest.java | 4 ++-- .../LanguageSentimentAnalysisModelManagementIT.java | 9 ++++++--- .../automl/LanguageSentimentAnalysisPredictIT.java | 7 ++++--- .../LanguageTextClassificationCreateDatasetTest.java | 4 ++-- .../LanguageTextClassificationModelManagementIT.java | 9 ++++++--- .../automl/LanguageTextClassificationPredictIT.java | 7 ++++--- .../java/com/example/automl/ListDatasetsTest.java | 4 ++-- .../example/automl/TranslateCreateDatasetTest.java | 4 ++-- .../example/automl/TranslateModelManagementIT.java | 7 ++++--- .../java/com/example/automl/TranslatePredictIT.java | 7 ++++--- .../automl/VisionClassificationCreateDatasetTest.java | 4 ++-- .../automl/VisionClassificationModelManagementIT.java | 9 ++++++--- .../example/automl/VisionClassificationPredictIT.java | 11 +++++++---- .../VisionObjectDetectionCreateDatasetTest.java | 4 ++-- .../VisionObjectDetectionModelManagementIT.java | 9 ++++++--- .../automl/VisionObjectDetectionPredictIT.java | 11 +++++++---- 25 files changed, 95 insertions(+), 63 deletions(-) diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh index 8035afe15b9..2b160c72cff 100755 --- a/.kokoro/tests/run_tests.sh +++ b/.kokoro/tests/run_tests.sh @@ -65,6 +65,7 @@ if [[ "$SCRIPT_DEBUG" != "true" ]]; then source "${KOKORO_GFILE_DIR}/storage-hmac-credentials.sh" source "${KOKORO_GFILE_DIR}/dlp_secrets.txt" source "${KOKORO_GFILE_DIR}/bigtable_secrets.txt" + source "${KOKORO_GFILE_DIR}/automl_secrets.txt" # Activate service account gcloud auth activate-service-account \ --key-file="$GOOGLE_APPLICATION_CREDENTIALS" \ diff --git a/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java index 5327a8fd3cd..f54201f500c 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class DeleteDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/ExportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java index 7a3c53448fb..3fd849ad02c 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java @@ -41,7 +41,7 @@ public class ExportDatasetTest { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String DATASET_ID = "TEN477786180780294144"; + private static final String DATASET_ID = System.getenv("ENTITY_EXTRACTION_DATASET_ID"); private static final String BUCKET_ID = PROJECT_ID + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; private ByteArrayOutputStream bout; @@ -57,6 +57,7 @@ private static void requireEnvVar(String varName) { public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("ENTITY_EXTRACTION_DATASET_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java index 6813cf04bd9..a2facbb6140 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java @@ -34,7 +34,7 @@ // Tests for Automl models. @RunWith(JUnit4.class) public class GenericModelManagementIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); private String modelId; private String modelEvaluationId; private ByteArrayOutputStream bout; @@ -50,7 +50,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/GetDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java index db8ba97bf94..1bc25813a89 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java @@ -34,8 +34,8 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class GetDatasetTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String DATASET_ID = "TEN477786180780294144"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String DATASET_ID = System.getenv("ENTITY_EXTRACTION_DATASET_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -48,7 +48,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_DATASET_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java index 68c3c7a0ad5..03dc5d656fe 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java @@ -36,8 +36,8 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class ImportDatasetTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-lcm"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; private String datasetId; private ByteArrayOutputStream bout; @@ -53,6 +53,7 @@ private static void requireEnvVar(String varName) { 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/LanguageEntityExtractionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java index 5a7898c007a..2773d606d32 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageEntityExtractionCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/LanguageEntityExtractionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java index 3c460343346..36730d3863f 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java @@ -27,15 +27,17 @@ 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 { - 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; @@ -49,7 +51,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/LanguageEntityExtractionPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java index 2b84c67e90b..701143c0e86 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java @@ -31,6 +31,7 @@ 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; @@ -39,9 +40,9 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageEntityExtractionPredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-lcm"; - private static final String modelId = "TEN1974951581904273408"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-lcm"; + private static final String modelId = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) { public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("ENTITY_EXTRACTION_MODEL_ID"); } @Before @@ -81,7 +84,7 @@ public void testPredict() throws IOException { assertThat(got).contains("Text Extract Entity Type:"); } - @Test + @Ignore public void testBatchPredict() throws IOException, ExecutionException, InterruptedException { String inputUri = String.format("gs://%s/entity_extraction/input.jsonl", BUCKET_ID); String outputUri = String.format("gs://%s/TEST_BATCH_PREDICT/", BUCKET_ID); diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java index a0f69b68b4f..2a9878f6a11 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageSentimentAnalysisCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/LanguageSentimentAnalysisModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java index 0bc7f68f6c7..72e495c73d9 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java @@ -27,15 +27,17 @@ 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 { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "TST864310464894223026"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -49,7 +51,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("SENTIMENT_ANALYSIS_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java index d0613385ffb..13627760f92 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java @@ -34,8 +34,8 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageSentimentAnalysisPredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String modelId = "TST864310464894223026"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String modelId = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -49,7 +49,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("SENTIMENT_ANALYSIS_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java index bc9ad86fb68..de31b016e01 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageTextClassificationCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/LanguageTextClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java index 2d630da6b6a..e0f4e5c3d2f 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java @@ -27,15 +27,17 @@ 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 { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "TCN6871084728972835631"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("TEXT_CLASSIFICATION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -49,7 +51,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("TEXT_CLASSIFICATION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java index 5034047f9c1..59dac164afc 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java @@ -34,8 +34,8 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class LanguageTextClassificationPredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String modelId = "TCN6871084728972835631"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String modelId = System.getenv("TEXT_CLASSIFICATION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -49,7 +49,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("TEXT_CLASSIFICATION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java index f6a093d02b8..4938783e0f6 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java @@ -34,7 +34,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class ListDatasetsTest { - 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; @@ -47,7 +47,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/TranslateCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java index a798c3f9c23..a1c871ff0fe 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class TranslateCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/TranslateModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java index fb416e42f10..27ab477ae27 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java @@ -36,8 +36,8 @@ // Tests for Automl translation models. @RunWith(JUnit4.class) public class TranslateModelManagementIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String DATASET_ID = "TRL3946265060617537378"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String DATASET_ID = System.getenv("TRANSLATION_DATASET_ID"); private static final String MODEL_NAME = "translation_test_create_model"; private ByteArrayOutputStream bout; private PrintStream out; @@ -54,7 +54,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("TRANSLATION_DATASET_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java index 24a0ff952f7..9f903230537 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java @@ -35,8 +35,8 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class TranslatePredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String modelId = "TRL2188848820815848149"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String modelId = System.getenv("TRANSLATION_MODEL_ID"); private static final String filePath = "./resources/input.txt"; private ByteArrayOutputStream bout; private PrintStream out; @@ -51,7 +51,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("TRANSLATION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java index 9747870a2e3..b6af9cff1d8 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class VisionClassificationCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/VisionClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java index b7f053f6e18..cf1ab01076c 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java @@ -27,15 +27,17 @@ 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("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "ICN6418888056864606028"; + 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; @@ -49,7 +51,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("VISION_CLASSIFICATION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java index ff60b569dd1..c9d7ed4bc93 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java @@ -31,6 +31,7 @@ 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; @@ -39,9 +40,9 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class VisionClassificationPredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-vcm"; - private static final String modelId = "ICN6418888056864606028"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-vcm"; + private static final String modelId = System.getenv("VISION_CLASSIFICATION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) { public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("VISION_CLASSIFICATION_MODEL_ID"); } @Before @@ -81,7 +84,7 @@ public void testPredict() throws IOException { assertThat(got).contains("Predicted class name:"); } - @Test + @Ignore public void testBatchPredict() throws IOException, ExecutionException, InterruptedException { String inputUri = String.format("gs://%s/batch_predict_test.csv", BUCKET_ID); String outputUri = String.format("gs://%s/TEST_BATCH_PREDICT/", BUCKET_ID); diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java index 6fac5440efd..1e765354db2 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java @@ -36,7 +36,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class VisionObjectDetectionCreateDatasetTest { - 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; private String datasetId; @@ -50,7 +50,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/VisionObjectDetectionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java index e77efa8d319..703ae7e12eb 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java @@ -27,15 +27,17 @@ 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 { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String MODEL_ID = "IOD1854128448151224320"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String MODEL_ID = System.getenv("OBJECT_DETECTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -49,7 +51,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("OBJECT_DETECTION_MODEL_ID"); } @Before diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java index a9f5029033d..347779037e8 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java @@ -31,6 +31,7 @@ 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; @@ -39,9 +40,9 @@ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class VisionObjectDetectionPredictIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); - private static final String BUCKET_ID = PROJECT_ID + "-vcm"; - private static final String modelId = "IOD1854128448151224320"; + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); + private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-vcm"; + private static final String modelId = System.getenv("OBJECT_DETECTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out; @@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) { public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("GOOGLE_CLOUD_PROJECT"); + requireEnvVar("AUTOML_PROJECT_ID"); + requireEnvVar("OBJECT_DETECTION_MODEL_ID"); } @Before @@ -82,7 +85,7 @@ public void testPredict() throws IOException { assertThat(got).contains("Y:"); } - @Test + @Ignore public void testBatchPredict() throws IOException, ExecutionException, InterruptedException { String inputUri = String.format("gs://%s/vision_object_detection_batch_predict_test.csv", BUCKET_ID); From 114833bc04d8d6c0e3e498713fd159f9ad351f3f Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 10:39:53 -0700 Subject: [PATCH 08/10] Fix which project is used --- .../src/test/java/com/example/automl/ExportDatasetTest.java | 4 ++-- .../src/test/java/com/example/automl/ImportDatasetTest.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java index 3fd849ad02c..9f4b221e720 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java @@ -40,7 +40,7 @@ @SuppressWarnings("checkstyle:abbreviationaswordinname") public class ExportDatasetTest { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); private static final String DATASET_ID = System.getenv("ENTITY_EXTRACTION_DATASET_ID"); private static final String BUCKET_ID = PROJECT_ID + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; @@ -56,7 +56,7 @@ 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_DATASET_ID"); } diff --git a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java index 03dc5d656fe..e00fef64dd0 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java @@ -37,7 +37,7 @@ public class ImportDatasetTest { private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID"); - private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-lcm"; + private static final String BUCKET_ID = PROJECT_ID + "-lcm"; private static final String BUCKET = "gs://" + BUCKET_ID; private String datasetId; private ByteArrayOutputStream bout; @@ -52,7 +52,6 @@ private static void requireEnvVar(String varName) { @BeforeClass public static void checkRequirements() { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - requireEnvVar("GOOGLE_CLOUD_PROJECT"); requireEnvVar("AUTOML_PROJECT_ID"); } From c4af04d0d9d2a5e4aa7a890357356b7234925957 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 10:46:45 -0700 Subject: [PATCH 09/10] Fix bucket path typo --- .../src/test/java/com/example/automl/ImportDatasetTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java index e00fef64dd0..987f35cc5a7 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java +++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java @@ -85,7 +85,7 @@ public void tearDown() throws InterruptedException, ExecutionException, IOExcept @Test public void testImportDataset() throws IOException, ExecutionException, InterruptedException { - ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity_extraction/dataset.csv"); + ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity-extraction/dataset.csv"); String got = bout.toString(); assertThat(got).contains("Dataset imported."); } From ec5cab517b7fae6b971cf8d22563684d4541900d Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 7 Jan 2020 11:13:40 -0700 Subject: [PATCH 10/10] lint: remove extra semi-colon --- .../automl/LanguageEntityExtractionModelManagementIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java index 36730d3863f..a49c8c8d4e6 100644 --- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java +++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java @@ -37,7 +37,7 @@ @Ignore public class LanguageEntityExtractionModelManagementIT { 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 = System.getenv("ENTITY_EXTRACTION_MODEL_ID"); private ByteArrayOutputStream bout; private PrintStream out;