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

Log Level Test Fix + Removed Direct HTTPs mode tests + Authorization Token Type Invalid Fix #23120

Merged
merged 5 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.GatewayConnectionConfig;
import com.azure.cosmos.encryption.TestNGLogListener;
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.cosmos.encryption.TestNGLogListener;
import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.ConnectionPolicy;
import com.azure.cosmos.implementation.InternalObjectNode;
Expand Down Expand Up @@ -141,7 +141,7 @@ protected static CosmosAsyncContainer getSharedSinglePartitionCosmosContainer(Co
allEqualOrLowerConsistencies(accountConsistency)));
preferredLocations = immutableListOrNull(parsePreferredLocation(TestConfigurations.PREFERRED_LOCATIONS));
protocols = ObjectUtils.defaultIfNull(immutableListOrNull(parseProtocols(TestConfigurations.PROTOCOLS)),
ImmutableList.of(Protocol.HTTPS, Protocol.TCP));
ImmutableList.of(Protocol.TCP));

// Object mapper configurations
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand Down Expand Up @@ -846,7 +846,6 @@ public static Object[][] clientBuilders() {
@DataProvider
public static Object[][] clientBuildersWithSessionConsistency() {
return new Object[][]{
{createDirectRxDocumentClient(ConsistencyLevel.SESSION, Protocol.HTTPS, false, null, true)},
{createDirectRxDocumentClient(ConsistencyLevel.SESSION, Protocol.TCP, false, null, true)},
{createGatewayRxDocumentClient(ConsistencyLevel.SESSION, false, null, true)}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ private RxDocumentClientImpl(URI serviceEndpoint,

if (this.credential != null) {
hasAuthKeyResourceToken = false;
this.authorizationTokenType = AuthorizationTokenType.PrimaryMasterKey;
this.authorizationTokenProvider = new BaseAuthorizationTokenProvider(this.credential);
} else if (masterKeyOrResourceToken != null && ResourceTokenAuthorizationHelper.isResourceToken(masterKeyOrResourceToken)) {
this.authorizationTokenProvider = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/**
* HttpClient that is implemented using reactor-netty.
*/
class ReactorNettyClient implements HttpClient {
public class ReactorNettyClient implements HttpClient {

private static final String REACTOR_NETTY_REQUEST_RECORD_KEY = "reactorNettyRequestRecordKey";

Expand Down Expand Up @@ -379,4 +379,25 @@ private enum ReactorNettyResponseState {
CANCELLED,
ERROR;
}

/**
* DO NOT USE
*
* This API is only for testing purposes, don't use it anywhere else in the code.
* This changes the logging level of Reactor Netty Http Client.
*/
public void enableNetworkLogging() {
Logger logger = LoggerFactory.getLogger(REACTOR_NETWORK_LOG_CATEGORY);
if (logger.isTraceEnabled()) {
this.httpClient = this.httpClient.wiretap(REACTOR_NETWORK_LOG_CATEGORY, LogLevel.TRACE);
simplynaveen20 marked this conversation as resolved.
Show resolved Hide resolved
} else if (logger.isInfoEnabled()) {
this.httpClient = this.httpClient.wiretap(REACTOR_NETWORK_LOG_CATEGORY, LogLevel.INFO);
} else if (logger.isDebugEnabled()) {
this.httpClient = this.httpClient.wiretap(REACTOR_NETWORK_LOG_CATEGORY, LogLevel.DEBUG);
} else if (logger.isWarnEnabled()) {
this.httpClient = this.httpClient.wiretap(REACTOR_NETWORK_LOG_CATEGORY, LogLevel.WARN);
} else if (logger.isErrorEnabled()) {
this.httpClient = this.httpClient.wiretap(REACTOR_NETWORK_LOG_CATEGORY, LogLevel.ERROR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -335,11 +334,6 @@ public void invalidSecondaryKey() throws Exception {
client.getDatabase(databaseDefinition.getId());
}

@BeforeMethod(groups = { "simple" }, timeOut = TIMEOUT)
public void beforeMethod() throws Exception {
Thread.sleep(TIMEOUT / 2);
}

@AfterMethod(groups = { "simple" }, timeOut = SETUP_TIMEOUT)
public void afterMethod() {
// Set back master getKey before every test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class GoneAndRetryPolicyWithSpyClientTest extends TestSuiteBase {

@DataProvider
public static Object[][] directClientBuilder() {
return new Object[][] { { createDCBuilder(Protocol.HTTPS) }, { createDCBuilder(Protocol.TCP) } };
return new Object[][] { { createDCBuilder(Protocol.TCP) } };
}

static Builder createDCBuilder(Protocol protocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
// Licensed under the MIT License.
package com.azure.cosmos.implementation;

import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.GatewayConnectionConfig;
import com.azure.cosmos.TestNGLogListener;
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.cosmos.implementation.AsyncDocumentClient.Builder;
import com.azure.cosmos.implementation.directconnectivity.Protocol;
import com.azure.cosmos.implementation.guava25.base.CaseFormat;
import com.azure.cosmos.implementation.guava25.collect.ImmutableList;
import com.azure.cosmos.models.CompositePath;
import com.azure.cosmos.models.CompositePathSortOrder;
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.models.CosmosQueryRequestOptions;
import com.azure.cosmos.models.FeedResponse;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKey;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.cosmos.models.SqlQuerySpec;
import com.azure.cosmos.TestNGLogListener;
import com.azure.cosmos.implementation.AsyncDocumentClient.Builder;
import com.azure.cosmos.implementation.directconnectivity.Protocol;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.azure.cosmos.implementation.guava25.base.CaseFormat;
import com.azure.cosmos.implementation.guava25.collect.ImmutableList;
import io.reactivex.subscribers.TestSubscriber;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -90,7 +90,7 @@ private static <T> ImmutableList<T> immutableListOrNull(List<T> list) {
allEqualOrLowerConsistencies(accountConsistency)));
preferredLocations = immutableListOrNull(parsePreferredLocation(TestConfigurations.PREFERRED_LOCATIONS));
protocols = ObjectUtils.defaultIfNull(immutableListOrNull(parseProtocols(TestConfigurations.PROTOCOLS)),
ImmutableList.of(Protocol.HTTPS, Protocol.TCP));
ImmutableList.of(Protocol.TCP));
kushagraThapar marked this conversation as resolved.
Show resolved Hide resolved
// Object mapper configuration
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class DCDocumentCrudTest extends TestSuiteBase {

@DataProvider
public static Object[][] directClientBuilder() {
return new Object[][] { { createDCBuilder(Protocol.HTTPS) }, { createDCBuilder(Protocol.TCP) } };
return new Object[][] { { createDCBuilder(Protocol.TCP) } };
}

static Builder createDCBuilder(Protocol protocol) {
Expand Down
Loading