Skip to content

Commit d29b832

Browse files
committed
implement delya on VR tests
1 parent d54c081 commit d29b832

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

examples/IBM.WatsonDeveloperCloud.VisualRecognition.v3.Example/VisualRecognitionServiceExample.cs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ public VisualRecognitionServiceExample(string apikey)
6262
IsClassifierReady(_createdClassifierId);
6363
autoEvent.WaitOne();
6464
UpdateClassifier();
65-
GetCollections();
66-
67-
DeleteDotnetCollections();
68-
69-
CreateCollection();
70-
GetCollection();
71-
GetCollectionImages();
72-
AddCollectionImages();
73-
GetCollectionImage();
74-
GetCollectionImageMetadata();
75-
AddCollectionImageMetadata();
76-
DeleteCollectionImageMetadata();
77-
FindSimilar();
78-
DeleteCollectionImage();
79-
DeleteCollection();
65+
//GetCollections();
66+
67+
//DeleteDotnetCollections();
68+
69+
//CreateCollection();
70+
//GetCollection();
71+
//GetCollectionImages();
72+
//AddCollectionImages();
73+
//GetCollectionImage();
74+
//GetCollectionImageMetadata();
75+
//AddCollectionImageMetadata();
76+
//DeleteCollectionImageMetadata();
77+
//FindSimilar();
78+
//DeleteCollectionImage();
79+
//DeleteCollection();
8080
DeleteClassifier();
8181

8282
Console.WriteLine("\n\nOperation complete");
@@ -262,6 +262,10 @@ private void DeleteClassifier()
262262
if (string.IsNullOrEmpty(_createdClassifierId))
263263
throw new ArgumentNullException(nameof(_createdClassifierId));
264264

265+
#region Delay
266+
Delay(_delayTime);
267+
#endregion
268+
265269
Console.WriteLine(string.Format("\nCalling DeleteClassifier(\"{0}\")...", _createdClassifierId));
266270

267271
var result = _visualRecognition.DeleteClassifier(_createdClassifierId);
@@ -674,5 +678,16 @@ private void DeleteDotnetCollections()
674678
Console.WriteLine("There are no matching collections to delete.");
675679
}
676680
}
681+
682+
#region Delay
683+
// Introducing a delay because of a known issue with Visual Recognition where newly created classifiers
684+
// will disappear without being deleted if a delete is attempted less than ~10 seconds after creation.
685+
private int _delayTime = 15000;
686+
private void Delay(int delayTime)
687+
{
688+
Console.WriteLine(string.Format("Delaying for {0} ms", delayTime));
689+
Thread.Sleep(delayTime);
690+
}
691+
#endregion
677692
}
678693
}

test/IBM.WatsonDeveloperCloud.VisualRecognition.v3.IntegrationTests/VisualRecognitionServiceIntegrationTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ public void t21_DeleteClassifier_Success()
390390
VisualRecognitionService service = new VisualRecognitionService();
391391
service.SetCredential(apikey);
392392

393+
#region Delay
394+
Delay(_delayTime);
395+
#endregion
396+
393397
var result = service.DeleteClassifier(_createdClassifierId);
394398

395399
Assert.IsNotNull(result);
@@ -456,5 +460,16 @@ private bool ContainsClass(GetClassifiersPerClassifierVerbose result, string cla
456460

457461
return containsClass;
458462
}
463+
464+
#region Delay
465+
// Introducing a delay because of a known issue with Visual Recognition where newly created classifiers
466+
// will disappear without being deleted if a delete is attempted less than ~10 seconds after creation.
467+
private int _delayTime = 15000;
468+
private void Delay(int delayTime)
469+
{
470+
Console.WriteLine(string.Format("Delaying for {0} ms", delayTime));
471+
Thread.Sleep(delayTime);
472+
}
473+
#endregion
459474
}
460475
}

0 commit comments

Comments
 (0)