8000 Disable Container Analysis (#1108) · rosekiller32/java-docs-samples@c7a8a5a · GitHub
[go: up one dir, main page]

Skip to content

Commit c7a8a5a

Browse files
daniel-sanchedzlier-gcp
authored andcommitted
Disable Container Analysis (GoogleCloudPlatform#1108)
* temporarily disable container analysis tests * misc container analysis fixes
1 parent 041d146 commit c7a8a5a

File tree

2 files changed

+21
-17
lines changed
  • container-registry/container-analysis/src

2 files changed

+21
-17
lines changed

container-registry/container-analysis/src/main/java/com/example/containeranalysis/Samples.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static void deleteOccurrence(String occurrenceName) throws Exception {
161161

162162
// [START get_occurrence]
163163
/**
164-
* Retrieves an occurrence based on it's name
164+
* Retrieves an occurrence based on its name
165165
*
166166
* @param occurrenceName the name of the occurrence to delete
167167
* format: "projects/{projectId}/occurrences/{occurrence_id}"
@@ -177,7 +177,7 @@ public static Occurrence getOccurrence(String occurrenceName) throws Exception
177177

178178
// [START get_note]
179179
/**
180-
* Retrieves a note based on it's noteId and projectId
180+
* Retrieves a note based on its noteId and projectId
181181
*
182182
* @param noteId the note's unique identifier
183183
* @param projectId the project's unique identifier
@@ -280,22 +280,22 @@ public static int getOccurrencesForImage(String imageUrl, String projectId) thro
280280
// [START pubsub]
281281
/**
282282
* Handle incoming occurrences using a pubsub subscription
283-
* @param subscriptionId the user-specified identifier for the pubsub subscription
283+
* @param subId the user-specified identifier for the pubsub subscription
284284
* @param timeout the amount of time to listen for pubsub messages (in seconds)
285285
* @param projectId the project's unique identifier
286286
* @return number of occurrence pubsub messages received
287287
* @throws Exception on errors with the subscription client
288288
*/
289-
public static int pubSub(String subscriptionId, int timeout, String projectId) throws Exception {
289+
public static int pubSub(String subId, int timeout, String projectId) throws Exception {
290290
Subscriber subscriber = null;
291291
MessageReceiverExample receiver = new MessageReceiverExample();
292292

293293
try {
294294
// subscribe to the requested pubsub channel
295-
ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of(projectId, subscriptionId);
296-
subscriber = Subscriber.newBuilder(subscriptionName, receiver).build();
295+
ProjectSubscriptionName subName = ProjectSubscriptionName.of(projectId, subId);
296+
subscriber = Subscriber.newBuilder(subName, receiver).build();
297297
subscriber.startAsync().awaitRunning();
298-
// listen to messages for 'listenTimeout' seconds
298+
// listen to messages for 'timeout' seconds
299299
for (int i = 0; i < timeout; i++) {
300300
sleep(1000);
301301
}
@@ -330,20 +330,20 @@ public synchronized void receiveMessage(PubsubMessage message, AckReplyConsumer
330330

331331
/**
332332
* Creates and returns a pubsub subscription object listening to the occurrence topic
333-
* @param subscriptionId the identifier you want to associate with the subscription
333+
* @param subId the identifier you want to associate with the subscription
334334
* @param projectId the project's unique identifier
335335
* @throws Exception on errors with the subscription client
336336
*/
337-
public static Subscription createOccurrenceSubscription(String subscriptionId, String projectId)
337+
public static Subscription createOccurrenceSubscription(String subId, String projectId)
338338
throws Exception {
339339
String topicId = "resource-notes-occurrences-v1alpha1";
340340
try (SubscriptionAdminClient client = SubscriptionAdminClient.create()) {
341341
PushConfig config = PushConfig.getDefaultInstance();
342342
ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId);
343-
ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of(projectId, subscriptionId);
344-
Subscription sub = client.createSubscription(subscriptionName, topicName, config, 0);
343+
ProjectSubscriptionName subName = ProjectSubscriptionName.of(projectId, subId);
344+
Subscription sub = client.createSubscription(subName, topicName, config, 0);
345345
return sub;
346346
}
347347
}
348348
// [END pubsub]
349-
}
349+
}

container-registry/container-analysis/src/test/java/com/example/containeranalysis/SamplesTests.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Date;
3030
import org.junit.After;
3131
import org.junit.Before;
32+
import org.junit.Ignore;
3233
import org.junit.Rule;
3334
import org.junit.Test;
3435
import org.junit.rules.TestName;
@@ -40,6 +41,7 @@
4041
*/
4142
@RunWith(JUnit4.class)
4243
@SuppressWarnings("checkstyle:abbreviationaswordinname")
44+
@Ignore
4345
public class SamplesTests {
4446

4547
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
@@ -164,6 +166,7 @@ public void testOccurrencesForImage() throws Exception {
164166
do {
165167
newCount = Samples.getOccurrencesForImage(imageUrl, PROJECT_ID);
166168
sleep(SLEEP_TIME);
169+
tries += 1;
167170
} while (newCount != 1 && tries < TRY_LIMIT);
168171
assertEquals(1, newCount);
169172
assertEquals(0, origCount);
@@ -181,6 +184,7 @@ public void testOccurrencesForNote() throws Exception {
181184
do {
182185
newCount = Samples.getOccurrencesForNote(noteId, PROJECT_ID);
183186
sleep(SLEEP_TIME);
187+
tries += 1;
184188
} while (newCount != 1 && tries < TRY_LIMIT);
185189
assertEquals(0, origCount);
186190
assertEquals(1, newCount);
@@ -193,14 +197,14 @@ public void testOccurrencesForNote() throws Exception {
193197
public void testPubSub() throws Exception {
194198
int newCount;
195199
int tries;
196-
String subscriptionId = "drydockOccurrences";
197-
ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of(PROJECT_ID, subscriptionId);
200+
String subId = "drydockOccurrences";
201+
ProjectSubscriptionName subName = ProjectSubscriptionName.of(PROJECT_ID, subId);
198202

199-
Samples.createOccurrenceSubscription(subscriptionId, PROJECT_ID);
203+
Samples.createOccurrenceSubscription(subId, PROJECT_ID);
200204
Subscriber subscriber = null;
201205
Samples.MessageReceiverExample receiver = new Samples.MessageReceiverExample();
202206
try {
203-
subscriber = Subscriber.newBuilder(subscriptionName, receiver).build();
207+
subscriber = Subscriber.newBuilder(subName, receiver).build();
204208
subscriber.startAsync().awaitRunning();
205209
// sleep so any messages in the queue can go through and be counted before we start the test
206210
sleep(SLEEP_TIME);
@@ -229,7 +233,7 @@ public void testPubSub() throws Exception {
229233
}
230234
//delete subscription now that we're done with it
231235
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
232-
subscriptionAdminClient.deleteSubscription(subscriptionName);
236+
subscriptionAdminClient.deleteSubscription(subName);
233237
}
234238
}
235239

0 commit comments

Comments
 (0)
0