Skip to content

Commit e961b54

Browse files
test: Refactor teardown (#424)
* chore: disabling ITs to reduce cost & resolve quota issue * revert getTrainingsample changes * chore: refactored teardown part * lint * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md * test: fixed teardown part Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 4111e25 commit e961b54

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

aiplatform/snippets/src/test/java/aiplatform/CreateHyperparameterTuningJobPythonPackageSampleTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.junit.After;
3232
import org.junit.Before;
3333
import org.junit.BeforeClass;
34+
import org.junit.Ignore;
3435
import org.junit.Test;
3536

3637
public class CreateHyperparameterTuningJobPythonPackageSampleTest {
@@ -93,6 +94,7 @@ public void tearDown()
9394
}
9495

9596
@Test
97+
@Ignore("https://github.com/googleapis/java-aiplatform/issues/420")
9698
public void testCreateHyperparameterTuningJobPythonPackageSample() throws IOException {
9799
String hyperparameterTuningJobDisplayName =
98100
String.format(

aiplatform/snippets/src/test/java/aiplatform/CreateTrainingPipelineTabularClassificationSampleTest.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static junit.framework.TestCase.assertNotNull;
2121

22+
import com.google.cloud.aiplatform.v1.PipelineServiceClient;
23+
import com.google.cloud.aiplatform.v1.PipelineServiceSettings;
24+
import com.google.cloud.aiplatform.v1.TrainingPipeline;
25+
import com.google.cloud.aiplatform.v1.TrainingPipelineName;
2226
import java.io.ByteArrayOutputStream;
2327
import java.io.IOException;
2428
import java.io.PrintStream;
@@ -72,7 +76,25 @@ public void tearDown()
7276
// Assert
7377
String cancelResponse = bout.toString();
7478
assertThat(cancelResponse).contains("Cancelled the Training Pipeline");
75-
TimeUnit.MINUTES.sleep(2);
79+
80+
PipelineServiceSettings pipelineServiceSettings =
81+
PipelineServiceSettings.newBuilder()
82+
.setEndpoint("us-central1-aiplatform.googleapis.com:443")
83+
.build();
84+
85+
try (PipelineServiceClient pipelineServiceClient =
86+
PipelineServiceClient.create(pipelineServiceSettings)) {
87+
String location = "us-central1";
88+
TrainingPipelineName trainingPipelineName =
89+
TrainingPipelineName.of(PROJECT, location, trainingPipelineId);
90+
91+
TrainingPipeline trainingPipelineResponse =
92+
pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
93+
while (!trainingPipelineResponse.getState().name().contains("STATE_CANCELLED")) {
94+
TimeUnit.SECONDS.sleep(30);
95+
trainingPipelineResponse = pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
96+
}
97+
}
7698

7799
// Delete the Training Pipeline
78100
DeleteTrainingPipelineSample.deleteTrainingPipelineSample(PROJECT, trainingPipelineId);

0 commit comments

Comments
 (0)