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 all 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,27 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

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

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

@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("AUTOML_PROJECT_ID");
requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
}

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

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

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

// Tests for Automl natural language sentiment analysis models.
@RunWith(JUnit4.class)
@Ignore
public class LanguageSentimentAnalysisModelManagementIT {
public class UndeployModelTest {
private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
private static final String MODEL_ID = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID");
private static final String MODEL_ID = "TEN0000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

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

@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("AUTOML_PROJECT_ID");
requireEnvVar("SENTIMENT_ANALYSIS_MODEL_ID");
}

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

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

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

// Tests for Automl natural language text classification models.
@RunWith(JUnit4.class)
@Ignore
public class LanguageTextClassificationModelManagementIT {
public class VisionClassificationDeployModelNodeCountTest {
private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
private static final String MODEL_ID = System.getenv("TEXT_CLASSIFICATION_MODEL_ID");
private static final String MODEL_ID = "ICN0000000000000000000";
private ByteArrayOutputStream bout;
private PrintStream out;

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

@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("AUTOML_PROJECT_ID");
requireEnvVar("TEXT_CLASSIFICATION_MODEL_ID");
}

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

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

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

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

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

@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("AUTOML_PROJECT_ID");
requireEnvVar("OBJECT_DETECTION_MODEL_ID");
}

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

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

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

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

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