Skip to content

Commit

Permalink
test(search): introduce retry for search test (#10206)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Apr 5, 2024
1 parent 717e40b commit e6dd0af
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.linkedin.metadata.search.SearchResult;
import com.linkedin.metadata.search.SearchService;
import io.datahubproject.metadata.context.OperationContext;
import io.datahubproject.test.SearchRetry;
import io.datahubproject.test.metadata.context.TestOperationContexts;
import io.datahubproject.test.search.SearchTestUtils;
import java.util.Collections;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void testNameMatchPetProfile() {
assertTrue(secondResultUrn.toString().contains("pet_profiles"));
}

@Test
@Test(retryAnalyzer = SearchRetry.class)
public void testGlossaryTerms() {
/*
Searching for "ReturnRate" should return all tables that have the glossary term applied before
Expand Down
26 changes: 26 additions & 0 deletions metadata-io/src/test/java/io/datahubproject/test/SearchRetry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.datahubproject.test;

import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

/** Used to retry search fixture tests 1 time after 5 seconds */
public class SearchRetry implements IRetryAnalyzer {

private int retryCount = 0;
private static final int maxRetryCount = 1;
private static final int delayMs = 5000;

@Override
public boolean retry(ITestResult result) {
if (retryCount < maxRetryCount) {
retryCount++;
try {
Thread.sleep(delayMs);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return true;
}
return false;
}
}

0 comments on commit e6dd0af

Please sign in to comment.