2727import org .junit .After ;
2828import org .junit .Before ;
2929import org .junit .BeforeClass ;
30- import org .junit .Ignore ;
3130import org .junit .Test ;
3231import org .junit .runner .RunWith ;
3332import org .junit .runners .JUnit4 ;
3433
35- // Tests for Automl vision object detection models.
3634@ RunWith (JUnit4 .class )
37- @ Ignore
38- public class VisionObjectDetectionModelManagementIT {
35+ public class VisionObjectDetectionDeployModelNodeCountTest {
3936 private static final String PROJECT_ID = System .getenv ("AUTOML_PROJECT_ID" );
40- private static final String MODEL_ID = System . getenv ( "OBJECT_DETECTION_MODEL_ID" ) ;
37+ private static final String MODEL_ID = "0000000000000000000000" ;
4138 private ByteArrayOutputStream bout ;
4239 private PrintStream out ;
4340
4441 private static void requireEnvVar (String varName ) {
4542 assertNotNull (
46- System .getenv (varName ),
47- "Environment variable '%s' is required to perform these tests." .format (varName )
48- );
43+ System .getenv (varName ),
44+ "Environment variable '%s' is required to perform these tests." .format (varName ));
4945 }
5046
5147 @ BeforeClass
5248 public static void checkRequirements () {
5349 requireEnvVar ("GOOGLE_APPLICATION_CREDENTIALS" );
5450 requireEnvVar ("AUTOML_PROJECT_ID" );
55- requireEnvVar ("OBJECT_DETECTION_MODEL_ID" );
5651 }
5752
5853 @ Before
@@ -68,27 +63,17 @@ public void tearDown() {
6863 }
6964
7065 @ Test
71- public void testDeployUndeployModel ()
72- throws IOException , ExecutionException , InterruptedException {
73- UndeployModel .undeployModel (PROJECT_ID , MODEL_ID );
74- String got = bout .toString ();
75- assertThat (got ).contains ("Model undeployment finished" );
76-
77- DeployModel .deployModel (PROJECT_ID , MODEL_ID );
78- got = bout .toString ();
79- assertThat (got ).contains ("Model deployment finished" );
80- }
81-
82- @ Test
83- public void testDeployUndeployModelWithNodeCount ()
84- throws IOException , ExecutionException , InterruptedException {
85- UndeployModel .undeployModel (PROJECT_ID , MODEL_ID );
86- String got = bout .toString ();
87- assertThat (got ).contains ("Model undeployment finished" );
88-
89- VisionObjectDetectionDeployModelNodeCount .visionObjectDetectionDeployModelNodeCount (
90- PROJECT_ID , MODEL_ID );
91- got = bout .toString ();
92- assertThat (got ).contains ("Model deployment finished" );
66+ public void testDeployModelWithNodeCount () {
67+ // As model deployment can take a long time, instead try to deploy a
68+ // nonexistent model and confirm that the model was not found, but other
69+ // elements of the request were valid.
70+ try {
71+ VisionObjectDetectionDeployModelNodeCount .visionObjectDetectionDeployModelNodeCount (
72+ PROJECT_ID , MODEL_ID );
73+ String got = bout .toString ();
74+ assertThat (got ).contains ("The model does not exist" );
75+ } catch (IOException | ExecutionException | InterruptedException e ) {
76+ assertThat (e .getMessage ()).contains ("The model does not exist" );
77+ }
9378 }
9479}
0 commit comments