Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Live TestMode and Skip Recording Concepts #6134

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
127e95c
Initial concepts of TestMode.LIVE and IgnoreRecording for live mode o…
alzimmermsft Oct 31, 2019
ba9b1dc
Merge branch 'master' into AzCore_AddLiveMode
alzimmermsft Oct 31, 2019
69ae16b
Updated to not record in live mode, added handling to skip after test…
alzimmermsft Oct 31, 2019
9cf6415
Updated annotation and added tests for TestRunVerifier
alzimmermsft Nov 1, 2019
f96dd9c
Merge branch 'master' into AzCore_AddLiveMode
alzimmermsft Nov 1, 2019
4aaa840
Added unit test for changes
alzimmermsft Nov 1, 2019
e102924
Updated KeyVault tests to use new enum
alzimmermsft Nov 1, 2019
50a7e47
Updated Storage to use new enum
alzimmermsft Nov 4, 2019
c0d374d
Merged in master
alzimmermsft Nov 5, 2019
1e7b27b
Merged in master
alzimmermsft Nov 6, 2019
c79d3b0
Merged in master and validated AppConfig and KeyVault tests
alzimmermsft Nov 8, 2019
0d321db
Verified Storage Queues tests and minor fixes
alzimmermsft Nov 8, 2019
17ea290
Merged in master
alzimmermsft Nov 11, 2019
cad11ca
Merged in master and updated Storage tests
alzimmermsft Nov 13, 2019
5da416d
Update KeyVault test records and HttpClient construction
alzimmermsft Nov 13, 2019
e181c52
Updated File Shares to use DoNotRecord
alzimmermsft Nov 13, 2019
e2373e3
Updated Blobs
alzimmermsft Nov 13, 2019
fba5a52
Merged in master, updated some playback records
alzimmermsft Nov 14, 2019
07895ec
Fixed merge conflict in tests.yml
alzimmermsft Nov 14, 2019
e67b6de
Add guard around adding record policy when using OAuth client
alzimmermsft Nov 14, 2019
9d808f3
Merged in master
alzimmermsft Nov 14, 2019
fc47263
Merged in master
alzimmermsft Nov 19, 2019
218450c
Fixed incorrect method calls introduced when merging in master
alzimmermsft Nov 19, 2019
d3e41f5
Merge branch 'master' into AzCore_AddLiveMode
alzimmermsft Nov 19, 2019
e1e188e
Merged in master
alzimmermsft Nov 20, 2019
fc9b781
Fix surefire arguments
alzimmermsft Nov 20, 2019
369551a
Merge branch 'master' into AzCore_AddLiveMode
alzimmermsft Nov 20, 2019
befb86a
Merged in master
alzimmermsft Nov 27, 2019
8e29e50
Merge branch 'master' into AzCore_AddLiveMode
alzimmermsft Dec 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package com.azure.data.appconfiguration;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.azure.core.util.CoreUtils;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Unit test for reading app config user agent properties.
*/
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@
// Licensed under the MIT License.
package com.azure.data.appconfiguration;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceExistsException;
import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingFields;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingFields;
import com.azure.data.appconfiguration.models.SettingSelector;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.net.HttpURLConnection;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class ConfigurationClientTest extends ConfigurationClientTestBase {
private final ClientLogger logger = new ClientLogger(ConfigurationClientTest.class);
Expand All @@ -40,22 +36,7 @@ protected String getTestName() {
@Override
protected void beforeTest() {
beforeTestSetup();

if (interceptorManager.isPlaybackMode()) {
client = clientSetup(credentials -> new ConfigurationClientBuilder()
.connectionString(connectionString)
.httpClient(interceptorManager.getPlaybackClient())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.buildClient());
} else {
client = clientSetup(credentials -> new ConfigurationClientBuilder()
.connectionString(connectionString)
.httpClient(new NettyAsyncHttpClientBuilder().wiretap(true).build())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.addPolicy(interceptorManager.getRecordPolicy())
.addPolicy(new RetryPolicy())
.buildClient());
}
client = clientBuilder.buildClient();
}

@Override
Expand All @@ -73,7 +54,8 @@ protected void afterTest() {
}

/**
* Tests that a configuration is able to be added, these are differentiate from each other using a key or key-label identifier.
* Tests that a configuration is able to be added, these are differentiate from each other using a key or key-label
* identifier.
*/
@Test
public void addConfigurationSetting() {
Expand Down Expand Up @@ -121,8 +103,8 @@ public void addExistingSetting() {
}

/**
* Tests that a configuration is able to be added or updated with set.
* When the configuration is read-only updates cannot happen, this will result in a 409.
* Tests that a configuration is able to be added or updated with set. When the configuration is read-only updates
* cannot happen, this will result in a 409.
*/
@Test
public void setConfigurationSetting() {
Expand Down Expand Up @@ -157,8 +139,8 @@ public void setConfigurationSettingEmptyKey() {
}

/**
* Tests that we can set configuration settings when value is not null or an empty string.
* Value is not a required property.
* Tests that we can set configuration settings when value is not null or an empty string. Value is not a required
* property.
*/
@Test
public void setConfigurationSettingEmptyValue() {
Expand Down Expand Up @@ -204,9 +186,8 @@ public void getConfigurationSettingNotFound() {
}

/**
* Tests that configurations are able to be deleted when they exist.
* After the configuration has been deleted attempting to get it will result in a 404, the same as if the
* configuration never existed.
* Tests that configurations are able to be deleted when they exist. After the configuration has been deleted
* attempting to get it will result in a 404, the same as if the configuration never existed.
*/
@Test
public void deleteConfigurationSetting() {
Expand Down Expand Up @@ -237,8 +218,8 @@ public void deleteConfigurationSettingNotFound() {
}

/**
* Tests that when an ETag is passed to delete it will only delete if the current representation of the setting has the ETag.
* If the delete ETag doesn't match anything the delete won't happen, this will result in a 412.
* Tests that when an ETag is passed to delete it will only delete if the current representation of the setting has
* the ETag. If the delete ETag doesn't match anything the delete won't happen, this will result in a 412.
*/
@Test
public void deleteConfigurationSettingWithETag() {
Expand All @@ -254,7 +235,8 @@ public void deleteConfigurationSettingWithETag() {
}

/**
* Test the API will not make a delete call without having a key passed, an IllegalArgumentException should be thrown.
* Test the API will not make a delete call without having a key passed, an IllegalArgumentException should be
* thrown.
*/
@Test
public void deleteConfigurationSettingNullKey() {
Expand All @@ -275,7 +257,7 @@ public void setReadOnly() {

// unsuccessfully delete
assertRestException(() ->
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
HttpResponseException.class, 409);
});
}
Expand All @@ -292,7 +274,7 @@ public void clearReadOnly() {

// unsuccessfully delete
assertRestException(() ->
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
HttpResponseException.class, 409);

// clear read-only setting and delete
Expand All @@ -316,7 +298,7 @@ public void setReadOnlyWithConfigurationSetting() {

// unsuccessfully delete
assertRestException(() ->
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
HttpResponseException.class, 409);
});
}
Expand All @@ -334,7 +316,7 @@ public void clearReadOnlyWithConfigurationSetting() {

// unsuccessfully deleted
assertRestException(() ->
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE),
HttpResponseException.class, 409);

// unlock setting and delete
Expand Down Expand Up @@ -380,8 +362,8 @@ public void listWithMultipleKeys() {
}

/**
* Verifies that ConfigurationSettings can be added with different labels and that we can fetch those ConfigurationSettings
* from the service when filtering by their labels.
* Verifies that ConfigurationSettings can be added with different labels and that we can fetch those
* ConfigurationSettings from the service when filtering by their labels.
*/
@Test
public void listWithMultipleLabels() {
Expand Down Expand Up @@ -542,8 +524,8 @@ public void listRevisionsAcceptDateTime() {
}

/**
* Verifies that, given a ton of revisions, we can list the revisions ConfigurationSettings using pagination
* (ie. where 'nextLink' has a URL pointing to the next page of results.)
* Verifies that, given a ton of revisions, we can list the revisions ConfigurationSettings using pagination (ie.
* where 'nextLink' has a URL pointing to the next page of results.)
*/
@Test
public void listRevisionsWithPagination() {
Expand All @@ -553,12 +535,12 @@ public void listRevisionsWithPagination() {
}

SettingSelector filter = new SettingSelector().setKeys(keyPrefix).setLabels(labelPrefix);
assertEquals(numberExpected, client.listRevisions(filter).stream().collect(Collectors.toList()).size());
assertEquals(numberExpected, (int) client.listRevisions(filter).stream().count());
}

/**
* Verifies that, given a ton of revisions, we can process {@link java.util.stream.Stream} multiple time and get same result.
* (ie. where 'nextLink' has a URL pointing to the next page of results.)
* Verifies that, given a ton of revisions, we can process {@link java.util.stream.Stream} multiple time and get
* same result. (ie. where 'nextLink' has a URL pointing to the next page of results.)
*/
@Test
public void listRevisionsWithPaginationAndRepeatStream() {
Expand All @@ -569,14 +551,14 @@ public void listRevisionsWithPaginationAndRepeatStream() {

SettingSelector filter = new SettingSelector().setKeys(keyPrefix).setLabels(labelPrefix);
PagedIterable<ConfigurationSetting> configurationSettingPagedIterable = client.listRevisions(filter);
assertEquals(numberExpected, configurationSettingPagedIterable.stream().collect(Collectors.toList()).size());
assertEquals(numberExpected, (int) configurationSettingPagedIterable.stream().count());

assertEquals(numberExpected, configurationSettingPagedIterable.stream().collect(Collectors.toList()).size());
assertEquals(numberExpected, (int) configurationSettingPagedIterable.stream().count());
}

/**
* Verifies that, given a ton of revisions, we can iterate over multiple time and get same result.
* (ie. where 'nextLink' has a URL pointing to the next page of results.)
* Verifies that, given a ton of revisions, we can iterate over multiple time and get same result. (ie. where
* 'nextLink' has a URL pointing to the next page of results.)
*/
@Test
public void listRevisionsWithPaginationAndRepeatIterator() {
Expand All @@ -591,18 +573,18 @@ public void listRevisionsWithPaginationAndRepeatIterator() {
List<ConfigurationSetting> configurationSettingList1 = new ArrayList<>();
List<ConfigurationSetting> configurationSettingList2 = new ArrayList<>();

configurationSettingPagedIterable.iterator().forEachRemaining(configurationSetting -> configurationSettingList1.add(configurationSetting));
configurationSettingPagedIterable.iterator().forEachRemaining(configurationSettingList1::add);
assertEquals(numberExpected, configurationSettingList1.size());

configurationSettingPagedIterable.iterator().forEachRemaining(configurationSetting -> configurationSettingList2.add(configurationSetting));
configurationSettingPagedIterable.iterator().forEachRemaining(configurationSettingList2::add);
assertEquals(numberExpected, configurationSettingList2.size());

equalsArray(configurationSettingList1, configurationSettingList2);
assertTrue(equalsArray(configurationSettingList1, configurationSettingList2));
}

/**
* Verifies that, given a ton of existing settings, we can list the ConfigurationSettings using pagination
* (ie. where 'nextLink' has a URL pointing to the next page of results.)
* Verifies that, given a ton of existing settings, we can list the ConfigurationSettings using pagination (ie.
* where 'nextLink' has a URL pointing to the next page of results.)
*/
@Test
public void listConfigurationSettingsWithPagination() {
Expand Down
Loading