Skip to content

automl: use fake model ids for deployment testing so that tests do no… #1929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions automl/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,17 @@
</parent>

<properties>
<maven.compiler.target>1.11</maven.compiler.target>
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- [START automl_java_dependencies] -->
<!-- Using libraries-bom to manage versions.
See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- [START automl_java_dependencies] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-automl</artifactId>
<version>0.115.1-beta</version>
</dependency>
<!-- [END automl_java_dependencies] -->
<dependency>
Expand All @@ -77,7 +64,5 @@
<version>1.0</version>
<scope>test</scope>
</dependency>
<!-- [START automl_java_dependencies] -->
</dependencies>
<!-- [END automl_java_dependencies] -->
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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<BatchPredictResult, OperationMetadata> future =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

// Tests for Automl natural language entity extraction models.
@RunWith(JUnit4.class)
public class LanguageEntityExtractionModelManagementIT {
public class DeployModelTest {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String MODEL_ID = "TEN1974951581904273408";
private static final String MODEL_ID = "TEN0000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

private static void requireEnvVar(String varName) {
assertNotNull(
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName)
);
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName));
}

@BeforeClass
Expand All @@ -65,14 +63,16 @@ public void tearDown() {
}

@Test
public void testDeployUndeployModel()
throws IOException, ExecutionException, InterruptedException {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("Model undeployment finished");

DeployModel.deployModel(PROJECT_ID, MODEL_ID);
got = bout.toString();
assertThat(got).contains("Model deployment finished");
public void testDeployModel() {
// As model deployment can take a long time, instead try to deploy a
// nonexistent model and confirm that the model was not found, but other
// elements of the request were valid.
try {
DeployModel.deployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("The model does not exist");
} catch (IOException | ExecutionException | InterruptedException e) {
assertThat(e.getMessage()).contains("The model does not exist");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

// Tests for Automl natural language text classification models.
@RunWith(JUnit4.class)
public class LanguageTextClassificationModelManagementIT {
public class UndeployModelTest {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String MODEL_ID = "TCN6871084728972835631";
private static final String MODEL_ID = "TEN0000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

private static void requireEnvVar(String varName) {
assertNotNull(
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName)
);
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName));
}

@BeforeClass
Expand All @@ -65,14 +63,16 @@ public void tearDown() {
}

@Test
public void testDeployUndeployModel()
throws IOException, ExecutionException, InterruptedException {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("Model undeployment finished");

DeployModel.deployModel(PROJECT_ID, MODEL_ID);
got = bout.toString();
assertThat(got).contains("Model deployment finished");
public void testUndeployModel() {
// As model deployment can take a long time, instead try to deploy a
// nonexistent model and confirm that the model was not found, but other
// elements of the request were valid.
try {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("The model does not exist");
} catch (IOException | ExecutionException | InterruptedException e) {
assertThat(e.getMessage()).contains("The model does not exist");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

// Tests for Automl natural language sentiment analysis models.
@RunWith(JUnit4.class)
public class LanguageSentimentAnalysisModelManagementIT {
public class VisionClassificationDeployModelNodeCountTest {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String MODEL_ID = "TST864310464894223026";
private static final String MODEL_ID = "ICN0000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

private static void requireEnvVar(String varName) {
assertNotNull(
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName)
);
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName));
}

@BeforeClass
Expand All @@ -65,14 +63,17 @@ public void tearDown() {
}

@Test
public void testDeployUndeployModel()
throws IOException, ExecutionException, InterruptedException {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("Model undeployment finished");

DeployModel.deployModel(PROJECT_ID, MODEL_ID);
got = bout.toString();
assertThat(got).contains("Model deployment finished");
public void testDeployModelWithNodeCount() {
// As model deployment can take a long time, instead try to deploy a
// nonexistent model and confirm that the model was not found, but other
// elements of the request were valid.
try {
VisionClassificationDeployModelNodeCount.visionClassificationDeployModelNodeCount(
PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("The model does not exist");
} catch (IOException | ExecutionException | InterruptedException e) {
assertThat(e.getMessage()).contains("The model does not exist");
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

// Tests for Automl vision object detection models.
@RunWith(JUnit4.class)
public class VisionObjectDetectionModelManagementIT {
public class VisionObjectDetectionDeployModelNodeCountTest {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String MODEL_ID = "IOD1854128448151224320";
private static final String MODEL_ID = "0000000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

private static void requireEnvVar(String varName) {
assertNotNull(
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName)
);
System.getenv(varName),
"Environment variable '%s' is required to perform these tests.".format(varName));
}

@BeforeClass
Expand All @@ -65,27 +63,17 @@ public void tearDown() {
}

@Test
public void testDeployUndeployModel()
throws IOException, ExecutionException, InterruptedException {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("Model undeployment finished");

DeployModel.deployModel(PROJECT_ID, MODEL_ID);
got = bout.toString();
assertThat(got).contains("Model deployment finished");
}

@Test
public void testDeployUndeployModelWithNodeCount()
throws IOException, ExecutionException, InterruptedException {
UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("Model undeployment finished");

VisionObjectDetectionDeployModelNodeCount.visionObjectDetectionDeployModelNodeCount(
PROJECT_ID, MODEL_ID);
got = bout.toString();
assertThat(got).contains("Model deployment finished");
public void testDeployModelWithNodeCount() {
// As model deployment can take a long time, instead try to deploy a
// nonexistent model and confirm that the model was not found, but other
// elements of the request were valid.
try {
VisionObjectDetectionDeployModelNodeCount.visionObjectDetectionDeployModelNodeCount(
PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("The model does not exist");
} catch (IOException | ExecutionException | InterruptedException e) {
assertThat(e.getMessage()).contains("The model does not exist");
}
}
}