Skip to content

Commit

Permalink
Adding Indexers UT of changing batch size and max failed items (Azure…
Browse files Browse the repository at this point in the history
…#247)

* Adding Indexers UT of changing batch size and max failed items - task 1487

* moving client init to beforeTest method
  • Loading branch information
eladiw authored Nov 12, 2019
1 parent 9258b06 commit 554b4be
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
public class IndexersManagementAsyncTests extends IndexersManagementTestBase {
private SearchServiceAsyncClient client;

@Override
protected void beforeTest() {
super.beforeTest();
client = getSearchServiceClientBuilder().buildAsyncClient();
}

protected DataSource createDatasource(DataSource ds) {
return client.createOrUpdateDataSource(ds).block();
}
Expand All @@ -31,7 +37,6 @@ protected Indexer createIndexer(Indexer indexer) {

@Override
public void createIndexerReturnsCorrectDefinition() {
client = getSearchServiceClientBuilder().buildAsyncClient();
Indexer expectedIndexer = createTestIndexer("indexer");
expectedIndexer.setIsDisabled(true);
expectedIndexer.setParameters(
Expand All @@ -53,8 +58,6 @@ public void createIndexerReturnsCorrectDefinition() {

@Override
public void canCreateAndListIndexers() {
client = getSearchServiceClientBuilder().buildAsyncClient();

// Create the data source, note it a valid DS with actual
// connection string
DataSource datasource = createTestSqlDataSource();
Expand Down Expand Up @@ -84,7 +87,6 @@ public void canCreateAndListIndexers() {

@Override
public void createIndexerFailsWithUsefulMessageOnUserError() {
client = getSearchServiceClientBuilder().buildAsyncClient();
Indexer indexer = createTestIndexer("indexer");
indexer.setDataSourceName("thisdatasourcedoesnotexist");

Expand All @@ -96,37 +98,36 @@ public void createIndexerFailsWithUsefulMessageOnUserError() {

@Override
public void canUpdateIndexer() {
client = getSearchServiceClientBuilder().buildAsyncClient();

Indexer updatedExpected = changeIndexerBasic();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerFieldMapping() {
client = getSearchServiceClientBuilder().buildAsyncClient();

Indexer updatedExpected = changeIndexerFieldMapping();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerDisabled() {
client = getSearchServiceClientBuilder().buildAsyncClient();

Indexer updatedExpected = changeIndexerDisabled();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerSchedule() {
client = getSearchServiceClientBuilder().buildAsyncClient();

Indexer updatedExpected = changeIndexerSchedule();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerBatchSizeMaxFailedItems() {
Indexer updatedExpected = changeIndexerBatchSizeMaxFailedItems();

createUpdateValidateIndexer(updatedExpected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
public class IndexersManagementSyncTests extends IndexersManagementTestBase {
private SearchServiceClient client;

@Override
protected void beforeTest() {
super.beforeTest();
client = getSearchServiceClientBuilder().buildClient();
}


protected DataSource createDatasource(DataSource ds) {
return client.createOrUpdateDataSource(ds);
}
Expand All @@ -31,7 +38,6 @@ protected Indexer createIndexer(Indexer indexer) {

@Override
public void createIndexerReturnsCorrectDefinition() {
client = getSearchServiceClientBuilder().buildClient();
Indexer expectedIndexer =
createTestIndexer("indexer")
.setIsDisabled(true)
Expand All @@ -54,7 +60,6 @@ public void createIndexerReturnsCorrectDefinition() {

@Override
public void canCreateAndListIndexers() {
client = getSearchServiceClientBuilder().buildClient();

// Create the data source, note it a valid DS with actual
// connection string
Expand Down Expand Up @@ -85,7 +90,6 @@ public void canCreateAndListIndexers() {

@Override
public void createIndexerFailsWithUsefulMessageOnUserError() {
client = getSearchServiceClientBuilder().buildClient();
Indexer indexer = createTestIndexer("indexer");
indexer.setDataSourceName("thisdatasourcedoesnotexist");

Expand All @@ -97,37 +101,36 @@ public void createIndexerFailsWithUsefulMessageOnUserError() {

@Override
public void canUpdateIndexer() {
client = getSearchServiceClientBuilder().buildClient();

Indexer updatedExpected = changeIndexerBasic();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerFieldMapping() {
client = getSearchServiceClientBuilder().buildClient();

Indexer updatedExpected = changeIndexerFieldMapping();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerDisabled() {
client = getSearchServiceClientBuilder().buildClient();

Indexer updatedExpected = changeIndexerDisabled();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerSchedule() {
client = getSearchServiceClientBuilder().buildClient();

Indexer updatedExpected = changeIndexerSchedule();

createUpdateValidateIndexer(updatedExpected);
}

@Override
public void canUpdateIndexerBatchSizeMaxFailedItems() {
Indexer updatedExpected = changeIndexerBatchSizeMaxFailedItems();

createUpdateValidateIndexer(updatedExpected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.search.models.FieldMapping;
import com.azure.search.models.Index;
import com.azure.search.models.Indexer;
import com.azure.search.models.IndexingParameters;
import com.azure.search.models.IndexingSchedule;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -43,6 +44,9 @@ public abstract class IndexersManagementTestBase extends SearchServiceTestBase {
@Test
public abstract void canUpdateIndexerSchedule();

@Test
public abstract void canUpdateIndexerBatchSizeMaxFailedItems();

protected void assertIndexersEqual(Indexer expected, Indexer actual) {
expected.setETag("none");
actual.setETag("none");
Expand Down Expand Up @@ -196,10 +200,7 @@ protected Indexer changeIndexerSchedule() {
Indexer updatedExpected =
createTestIndexer("indexer");

IndexingSchedule is2 = updatedExpected.getSchedule();

IndexingSchedule is = new IndexingSchedule();
//is.setStartTime(OffsetDateTime.parse("2020-12-30T11:22:33+02:00"));
is.setInterval(Duration.ofMinutes(10));

// modify it
Expand All @@ -208,6 +209,22 @@ protected Indexer changeIndexerSchedule() {
return updatedExpected;
}

protected Indexer changeIndexerBatchSizeMaxFailedItems() {
// create another indexer object
Indexer updatedExpected =
createTestIndexer("indexer");

IndexingParameters ip = new IndexingParameters();
ip.setMaxFailedItems(121);
ip.setMaxFailedItemsPerBatch(11);

ip.setBatchSize(20);
// modify it
updatedExpected.setParameters(ip);

return updatedExpected;
}


protected abstract Index createIndex(Index index);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/datasources('azs-java-test-sql')?api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "d58de6b3-313a-42ed-b4ff-dfea3283f9b3",
"StatusCode" : "201",
"Date" : "Mon, 11 Nov 2019 15:29:46 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D766BBFBD12279\"",
"elapsed-time" : "56",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "395",
"Body" : "{\"@odata.context\":\"https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/$metadata#datasources/$entity\",\"@odata.etag\":\"\\\"0x8D766BBFBD12279\\\"\",\"name\":\"azs-java-test-sql\",\"description\":\"Some data source\",\"type\":\"azuresql\",\"subtype\":null,\"credentials\":{\"connectionString\":null},\"container\":{\"name\":\"GeoNamesRI\",\"query\":null},\"dataChangeDetectionPolicy\":null,\"dataDeletionDetectionPolicy\":null}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal",
"Location" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/datasources('azs-java-test-sql')?api-version=2019-05-06"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/indexes('indexforindexers')?allowIndexDowntime=false&api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "6c5e99d5-ef6e-451a-bec4-0212feb6512b",
"StatusCode" : "201",
"Date" : "Mon, 11 Nov 2019 15:29:46 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D766BBFC5BF3E2\"",
"elapsed-time" : "729",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "982",
"Body" : "{\"@odata.context\":\"https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/$metadata#indexes/$entity\",\"@odata.etag\":\"\\\"0x8D766BBFC5BF3E2\\\"\",\"name\":\"indexforindexers\",\"defaultScoringProfile\":null,\"fields\":[{\"name\":\"county_name\",\"type\":\"Edm.String\",\"searchable\":false,\"filterable\":true,\"retrievable\":true,\"sortable\":true,\"facetable\":true,\"key\":false,\"indexAnalyzer\":null,\"searchAnalyzer\":null,\"analyzer\":null,\"synonymMaps\":[]},{\"name\":\"state\",\"type\":\"Edm.String\",\"searchable\":true,\"filterable\":true,\"retrievable\":true,\"sortable\":true,\"facetable\":true,\"key\":false,\"indexAnalyzer\":null,\"searchAnalyzer\":null,\"analyzer\":null,\"synonymMaps\":[]},{\"name\":\"feature_id\",\"type\":\"Edm.String\",\"searchable\":true,\"filterable\":false,\"retrievable\":true,\"sortable\":true,\"facetable\":true,\"key\":true,\"indexAnalyzer\":null,\"searchAnalyzer\":null,\"analyzer\":null,\"synonymMaps\":[]}],\"scoringProfiles\":[],\"corsOptions\":null,\"suggesters\":[],\"analyzers\":[],\"tokenizers\":[],\"tokenFilters\":[],\"charFilters\":[]}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal",
"Location" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/indexes('indexforindexers')?allowIndexDowntime=false&api-version=2019-05-06"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/indexers('indexer')?api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "4d5c6464-dfd3-4815-ac16-3db47c1f5ac3",
"StatusCode" : "201",
"Date" : "Mon, 11 Nov 2019 15:29:47 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D766BBFC8F6ADE\"",
"elapsed-time" : "47",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "417",
"Body" : "{\"@odata.context\":\"https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/$metadata#indexers/$entity\",\"@odata.etag\":\"\\\"0x8D766BBFC8F6ADE\\\"\",\"name\":\"indexer\",\"description\":null,\"dataSourceName\":\"azs-java-test-sql\",\"skillsetName\":null,\"targetIndexName\":\"indexforindexers\",\"disabled\":true,\"schedule\":{\"interval\":\"P1D\",\"startTime\":\"0001-01-01T00:00:00Z\"},\"parameters\":null,\"fieldMappings\":[],\"outputFieldMappings\":[]}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal",
"Location" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/indexers('indexer')?api-version=2019-05-06"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/indexers('indexer')?api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "8221ad5e-50dc-4941-ba2b-9d712301ae9d",
"StatusCode" : "200",
"Date" : "Mon, 11 Nov 2019 15:29:47 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D766BBFD175567\"",
"elapsed-time" : "823",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "521",
"Body" : "{\"@odata.context\":\"https://azs-sdk4d53646984a0.search-dogfood.windows-int.net/$metadata#indexers/$entity\",\"@odata.etag\":\"\\\"0x8D766BBFD175567\\\"\",\"name\":\"indexer\",\"description\":null,\"dataSourceName\":\"azs-java-test-sql\",\"skillsetName\":null,\"targetIndexName\":\"indexforindexers\",\"disabled\":null,\"schedule\":{\"interval\":\"P1D\",\"startTime\":\"0001-01-01T00:00:00Z\"},\"parameters\":{\"batchSize\":20,\"maxFailedItems\":121,\"maxFailedItemsPerBatch\":11,\"base64EncodeKeys\":null,\"configuration\":{}},\"fieldMappings\":[],\"outputFieldMappings\":[]}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal"
},
"Exception" : null
} ],
"variables" : [ ]
}

0 comments on commit 554b4be

Please sign in to comment.