19
19
import static com .google .common .truth .Truth .assertThat ;
20
20
21
21
import java .io .ByteArrayOutputStream ;
22
+ import java .io .IOException ;
22
23
import java .io .PrintStream ;
24
+ import java .util .concurrent .ExecutionException ;
23
25
24
26
import org .junit .After ;
25
27
import org .junit .Before ;
26
28
import org .junit .Test ;
27
29
28
30
public class ClassificationDeployModelIT {
29
31
private static final String PROJECT_ID = System .getenv ("GOOGLE_CLOUD_PROJECT" );
30
- private static final String MODEL_ID = "ICN3125115511348658176 " ;
32
+ private static final String MODEL_ID = "ICN0000000000000000000 " ;
31
33
private ByteArrayOutputStream bout ;
32
34
private PrintStream out ;
33
35
@@ -45,27 +47,44 @@ public void tearDown() {
45
47
46
48
@ Test
47
49
public void testClassificationDeployModelApi () {
48
- ClassificationDeployModel .classificationDeployModel (PROJECT_ID , MODEL_ID );
49
-
50
- String got = bout .toString ();
51
- assertThat (got ).contains ("Model deployment finished" );
50
+ // As model deployment can take a long time, instead try to deploy a
51
+ // nonexistent model and confirm that the model was not found, but other
52
+ // elements of the request were valid.
53
+ try {
54
+ ClassificationDeployModel .classificationDeployModel (PROJECT_ID , MODEL_ID );
55
+ String got = bout .toString ();
56
+ assertThat (got ).contains ("The model does not exist" );
57
+ } catch (IOException | ExecutionException | InterruptedException e ) {
58
+ assertThat (e .getMessage ()).contains ("The model does not exist" );
59
+ }
60
+ }
52
61
53
- ClassificationUndeployModel .classificationUndeployModel (PROJECT_ID , MODEL_ID );
62
+ @ Test
63
+ public void testClassificationUndeployModelApi () {
64
+ // As model deployment can take a long time, instead try to deploy a
65
+ // nonexistent model and confirm that the model was not found, but other
66
+ // elements of the request were valid.
67
+ try {
68
+ ClassificationUndeployModel .classificationUndeployModel (PROJECT_ID , MODEL_ID );
69
+ String got = bout .toString ();
70
+ assertThat (got ).contains ("The model does not exist" );
71
+ } catch (IOException | ExecutionException | InterruptedException e ) {
72
+ assertThat (e .getMessage ()).contains ("The model does not exist" );
73
+ }
54
74
55
- got = bout .toString ();
56
- assertThat (got ).contains ("Model undeploy finished" );
57
75
}
58
76
59
77
@ Test
60
78
public void testClassificationDeployModelNodeCountApi () {
61
- ClassificationDeployModelNodeCount .classificationDeployModelNodeCount (PROJECT_ID , MODEL_ID );
62
-
63
- String got = bout .toString ();
64
- assertThat (got ).contains ("Model deployment on 2 nodes finished" );
65
-
66
- ClassificationUndeployModel .classificationUndeployModel (PROJECT_ID , MODEL_ID );
67
-
68
- got = bout .toString ();
69
- assertThat (got ).contains ("Model undeploy finished" );
79
+ // As model deployment can take a long time, instead try to deploy a
80
+ // nonexistent model and confirm that the model was not found, but other
81
+ // elements of the request were valid.
82
+ try {
83
+ ClassificationDeployModelNodeCount .classificationDeployModelNodeCount (PROJECT_ID , MODEL_ID );
84
+ String got = bout .toString ();
85
+ assertThat (got ).contains ("The model does not exist" );
86
+ } catch (IOException | ExecutionException | InterruptedException e ) {
87
+ assertThat (e .getMessage ()).contains ("The model does not exist" );
88
+ }
70
89
}
71
90
}
0 commit comments