Merge branch 'implement_kusto_query_object' into azure-identity
This commit is contained in:
Коммит
1f9c56926a
|
@ -38,21 +38,21 @@ public abstract class BaseClient implements Client, StreamingClient {
|
|||
}
|
||||
}
|
||||
|
||||
protected Mono<String> postAsync(HttpRequest request) {
|
||||
// Execute and get the response
|
||||
return httpClient.send(request)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
.flatMap(this::processResponseAsync)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
}
|
||||
|
||||
public Mono<String> processResponseAsync(HttpResponse response) {
|
||||
try {
|
||||
return Mono.just(Objects.requireNonNull(processResponseBody(response)));
|
||||
} catch (Exception e) {
|
||||
return Mono.error(new RuntimeException("Error processing response", e));
|
||||
}
|
||||
}
|
||||
// protected Mono<String> postAsync(HttpRequest request) {
|
||||
// // Execute and get the response
|
||||
// return httpClient.send(request)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
// .flatMap(this::processResponseAsync)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
// }
|
||||
//
|
||||
// public Mono<String> processResponseAsync(HttpResponse response) {
|
||||
// try {
|
||||
// return Mono.just(Objects.requireNonNull(processResponseBody(response)));
|
||||
// } catch (Exception e) {
|
||||
// return Mono.error(new RuntimeException("Error processing response", e));
|
||||
// }
|
||||
// }
|
||||
|
||||
private String processResponseBody(HttpResponse response) throws DataServiceException {
|
||||
String responseBody = Utils.isGzipResponse(response) ? Utils.gzipedInputToString(response.getBodyAsBinaryData().toStream())
|
||||
|
|
|
@ -9,11 +9,11 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
public interface Client {
|
||||
|
||||
Mono<KustoOperationResult> executeQueryAsync(String database, String command, ClientRequestProperties properties);
|
||||
|
||||
Mono<KustoOperationResult> executeMgmtAsync(String database, String command, ClientRequestProperties properties);
|
||||
|
||||
Mono<String> executeToJsonAsync(String database, String command, ClientRequestProperties properties);
|
||||
// Mono<KustoOperationResult> executeQueryAsync(String database, String command, ClientRequestProperties properties);
|
||||
//
|
||||
// Mono<KustoOperationResult> executeMgmtAsync(String database, String command, ClientRequestProperties properties);
|
||||
//
|
||||
// Mono<String> executeToJsonAsync(String database, String command, ClientRequestProperties properties);
|
||||
|
||||
@Deprecated
|
||||
KustoOperationResult executeQuery(String command) throws DataServiceException, DataClientException;
|
||||
|
|
|
@ -19,13 +19,11 @@ import com.microsoft.azure.kusto.data.req.KustoRequestContext;
|
|||
import com.microsoft.azure.kusto.data.res.JsonResult;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -37,7 +35,6 @@ class ClientImpl extends BaseClient {
|
|||
public static final String STREAMING_VERSION = "v1";
|
||||
private static final String DEFAULT_DATABASE_NAME = "NetDefaultDb";
|
||||
|
||||
public static final String FEDERATED_SECURITY_SUFFIX = ";fed=true";
|
||||
private final TokenProviderBase aadAuthenticationHelper;
|
||||
|
||||
private final String clusterUrl;
|
||||
|
@ -54,97 +51,76 @@ class ClientImpl extends BaseClient {
|
|||
|
||||
public ClientImpl(ConnectionStringBuilder csb, HttpClient httpClient) throws URISyntaxException {
|
||||
super(httpClient);
|
||||
|
||||
URI clusterUrlForParsing = new URI(csb.getClusterUrl());
|
||||
String host = clusterUrlForParsing.getHost();
|
||||
Objects.requireNonNull(clusterUrlForParsing.getAuthority(), "clusterUri must have uri authority component");
|
||||
String auth = clusterUrlForParsing.getAuthority().toLowerCase();
|
||||
if (host == null) {
|
||||
host = StringUtils.removeEndIgnoreCase(auth, FEDERATED_SECURITY_SUFFIX);
|
||||
}
|
||||
URIBuilder uriBuilder = new URIBuilder()
|
||||
.setScheme(clusterUrlForParsing.getScheme())
|
||||
.setHost(host);
|
||||
String path = clusterUrlForParsing.getPath();
|
||||
if (path != null && !path.isEmpty()) {
|
||||
path = StringUtils.removeEndIgnoreCase(path, FEDERATED_SECURITY_SUFFIX);
|
||||
path = StringUtils.removeEndIgnoreCase(path, "/");
|
||||
|
||||
uriBuilder.setPath(path);
|
||||
}
|
||||
|
||||
if (clusterUrlForParsing.getPort() != -1) {
|
||||
uriBuilder.setPort(clusterUrlForParsing.getPort());
|
||||
}
|
||||
csb.setClusterUrl(uriBuilder.build().toString());
|
||||
String clusterURL = UriUtils.createClusterURLFrom(csb.getClusterUrl());
|
||||
csb.setClusterUrl(clusterURL);
|
||||
|
||||
clusterUrl = csb.getClusterUrl();
|
||||
aadAuthenticationHelper = clusterUrl.toLowerCase().startsWith(CloudInfo.LOCALHOST) ? null : TokenProviderFactory.createTokenProvider(csb, httpClient);
|
||||
clientDetails = new ClientDetails(csb.getApplicationNameForTracing(), csb.getUserNameForTracing(), csb.getClientVersionForTracing());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<KustoOperationResult> executeQueryAsync(String database, String command, ClientRequestProperties properties) {
|
||||
KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
return executeQueryAsync(kr);
|
||||
}
|
||||
|
||||
Mono<KustoOperationResult> executeQueryAsync(@NotNull KustoRequest kr) {
|
||||
if (kr.getCommandType() != CommandType.QUERY) {
|
||||
kr.setCommandType(CommandType.QUERY);
|
||||
}
|
||||
return executeAsync(kr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<KustoOperationResult> executeMgmtAsync(String database, String command, ClientRequestProperties properties) {
|
||||
KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
return executeMgmtAsync(kr);
|
||||
}
|
||||
|
||||
public Mono<KustoOperationResult> executeMgmtAsync(@NotNull KustoRequest kr) {
|
||||
if (kr.getCommandType() != CommandType.ADMIN_COMMAND) {
|
||||
kr.setCommandType(CommandType.ADMIN_COMMAND);
|
||||
}
|
||||
return executeAsync(kr);
|
||||
}
|
||||
|
||||
private Mono<KustoOperationResult> executeAsync(KustoRequest kr) {
|
||||
|
||||
Mono<String> resultMono = executeToJsonAsync(kr)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
Mono<String> endpointMono = Mono.just(String.format(kr.getCommandType().getEndpoint(), clusterUrl))
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
|
||||
return Mono.zip(resultMono, endpointMono)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
.map(tuple2 -> new JsonResult(tuple2.getT1(), tuple2.getT2()))
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
.flatMap(this::processJsonResultAsync)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
}
|
||||
|
||||
public Mono<KustoOperationResult> processJsonResultAsync(JsonResult res) {
|
||||
try {
|
||||
return Mono.just(processJsonResult(res));
|
||||
} catch (Exception e) {
|
||||
return Mono.error(new RuntimeException("Error processing json result", e));
|
||||
}
|
||||
}
|
||||
|
||||
public Mono<String> executeToJsonAsync(String database, String command, ClientRequestProperties properties) {
|
||||
KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
return executeToJsonAsync(kr)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
}
|
||||
|
||||
Mono<String> executeToJsonAsync(KustoRequest kr) {
|
||||
return just(kr)
|
||||
.flatMap(this::prepareRequestAsync)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
.flatMap(this::processRequestAsync)
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
}
|
||||
// @Override
|
||||
// public Mono<KustoOperationResult> executeQueryAsync(String database, String command, ClientRequestProperties properties) {
|
||||
// KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
// return executeQueryAsync(kr);
|
||||
// }
|
||||
//
|
||||
// Mono<KustoOperationResult> executeQueryAsync(@NotNull KustoRequest kr) {
|
||||
// if (kr.getCommandType() != CommandType.QUERY) {
|
||||
// kr.setCommandType(CommandType.QUERY);
|
||||
// }
|
||||
// return executeAsync(kr);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Mono<KustoOperationResult> executeMgmtAsync(String database, String command, ClientRequestProperties properties) {
|
||||
// KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
// return executeMgmtAsync(kr);
|
||||
// }
|
||||
//
|
||||
// public Mono<KustoOperationResult> executeMgmtAsync(@NotNull KustoRequest kr) {
|
||||
// if (kr.getCommandType() != CommandType.ADMIN_COMMAND) {
|
||||
// kr.setCommandType(CommandType.ADMIN_COMMAND);
|
||||
// }
|
||||
// return executeAsync(kr);
|
||||
// }
|
||||
//
|
||||
// private Mono<KustoOperationResult> executeAsync(KustoRequest kr) {
|
||||
//
|
||||
// Mono<String> resultMono = executeToJsonAsync(kr)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
// Mono<String> endpointMono = Mono.just(String.format(kr.getCommandType().getEndpoint(), clusterUrl))
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
//
|
||||
// return Mono.zip(resultMono, endpointMono)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
// .map(tuple2 -> new JsonResult(tuple2.getT1(), tuple2.getT2()))
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
// .flatMap(this::processJsonResultAsync)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
// }
|
||||
//
|
||||
// public Mono<KustoOperationResult> processJsonResultAsync(JsonResult res) {
|
||||
// try {
|
||||
// return Mono.just(processJsonResult(res));
|
||||
// } catch (Exception e) {
|
||||
// return Mono.error(new RuntimeException("Error processing json result", e));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public Mono<String> executeToJsonAsync(String database, String command, ClientRequestProperties properties) {
|
||||
// KustoRequest kr = new KustoRequest(command, database, properties);
|
||||
// return executeToJsonAsync(kr)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
// }
|
||||
//
|
||||
// Mono<String> executeToJsonAsync(KustoRequest kr) {
|
||||
// return just(kr)
|
||||
// .flatMap(this::prepareRequestAsync)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err))
|
||||
// .flatMap(this::processRequestAsync)
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public KustoOperationResult executeQuery(String command) throws DataServiceException, DataClientException {
|
||||
|
@ -281,22 +257,18 @@ class ClientImpl extends BaseClient {
|
|||
request.getSdkRequest().getCommandType().getActivityTypeSuffix().concat(".executeToJsonResult"));
|
||||
}
|
||||
|
||||
public Mono<String> processRequestAsync(KustoRequestContext request) {
|
||||
return MonitoredActivity.invoke(
|
||||
(SupplierNoException<Mono<String>>) () -> postAsync(request.getHttpRequest())
|
||||
.onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err)),
|
||||
request.getSdkRequest().getCommandType().getActivityTypeSuffix().concat(".executeToJsonResult"));
|
||||
}
|
||||
// public Mono<String> processRequestAsync(KustoRequestContext request) {
|
||||
// return MonitoredActivity.invoke(
|
||||
// (SupplierNoException<Mono<String>>) () -> postAsync(request.getHttpRequest())
|
||||
// .onErrorContinue((err, src) -> LOGGER.error("Error coming from src {}", src, err)),
|
||||
// request.getSdkRequest().getCommandType().getActivityTypeSuffix().concat(".executeToJsonResult"));
|
||||
// }
|
||||
|
||||
private void validateEndpoint() throws DataServiceException, DataClientException {
|
||||
try {
|
||||
if (!endpointValidated) {
|
||||
KustoTrustedEndpoints.validateTrustedEndpoint(clusterUrl,
|
||||
CloudInfo.retrieveCloudInfoForCluster(clusterUrl).getLoginEndpoint());
|
||||
endpointValidated = true;
|
||||
}
|
||||
} catch (KustoClientInvalidConnectionStringException e) {
|
||||
throw new DataClientException(clusterUrl, e.getMessage(), e);
|
||||
if (!endpointValidated) {
|
||||
KustoTrustedEndpoints.validateTrustedEndpoint(clusterUrl,
|
||||
CloudInfo.retrieveCloudInfoForCluster(clusterUrl).getLoginEndpoint());
|
||||
endpointValidated = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,8 +449,4 @@ class ClientImpl extends BaseClient {
|
|||
return clientDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ public class ClientRequestProperties implements Serializable, TraceableAttribute
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of time a query may execute on the service before it times out, formatted as a krL timespan.
|
||||
* Gets the amount of time a query may execute on the service before it times out, formatted as a KQL timespan.
|
||||
* @param timeoutObj amount of time before timeout, which may be a Long, String or Integer.
|
||||
* Value must be between 1 minute and 1 hour, and so value below the minimum or above the maximum will be adjusted accordingly.
|
||||
*/
|
||||
|
@ -340,7 +340,7 @@ public class ClientRequestProperties implements Serializable, TraceableAttribute
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of time a query may execute on the service before it times out, formatted as a krL timespan.
|
||||
* Gets the amount of time a query may execute on the service before it times out, formatted as a KQL timespan.
|
||||
* Value must be between 1 minute and 1 hour, and so if the value had been set below the minimum or above the maximum, the value returned will be adjusted accordingly.
|
||||
*/
|
||||
String getTimeoutAsCslTimespan() {
|
||||
|
|
|
@ -6,10 +6,9 @@ package com.microsoft.azure.kusto.data;
|
|||
import com.microsoft.azure.kusto.data.exceptions.DataClientException;
|
||||
import com.microsoft.azure.kusto.data.exceptions.DataServiceException;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface StreamingClient extends Closeable {
|
||||
public interface StreamingClient {
|
||||
/**
|
||||
* <p>Ingest data from a given stream directly into Kusto database.</p>
|
||||
* This method ingests the data from a given stream directly into Kusto database, using streaming ingestion endpoint,
|
||||
|
|
|
@ -4,14 +4,44 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.http.client.utils.URIBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
|
||||
public class UriUtils {
|
||||
|
||||
public static final String FEDERATED_SECURITY_SUFFIX = ";fed=true";
|
||||
|
||||
private UriUtils() {
|
||||
// Providing hidden constructor to hide default public constructor in utils class
|
||||
}
|
||||
|
||||
public static String createClusterURLFrom(final String clusterURI) throws URISyntaxException {
|
||||
URI clusterUrlForParsing = new URI(clusterURI);
|
||||
String host = clusterUrlForParsing.getHost();
|
||||
Objects.requireNonNull(clusterUrlForParsing.getAuthority(), "clusterUri must have uri authority component");
|
||||
String auth = clusterUrlForParsing.getAuthority().toLowerCase();
|
||||
if (host == null) {
|
||||
host = StringUtils.removeEndIgnoreCase(auth, FEDERATED_SECURITY_SUFFIX);
|
||||
}
|
||||
URIBuilder uriBuilder = new URIBuilder()
|
||||
.setScheme(clusterUrlForParsing.getScheme())
|
||||
.setHost(host);
|
||||
String path = clusterUrlForParsing.getPath();
|
||||
if (path != null && !path.isEmpty()) {
|
||||
path = StringUtils.removeEndIgnoreCase(path, FEDERATED_SECURITY_SUFFIX);
|
||||
path = StringUtils.removeEndIgnoreCase(path, "/");
|
||||
|
||||
uriBuilder.setPath(path);
|
||||
}
|
||||
|
||||
if (clusterUrlForParsing.getPort() != -1) {
|
||||
uriBuilder.setPort(clusterUrlForParsing.getPort());
|
||||
}
|
||||
return uriBuilder.build().toString();
|
||||
}
|
||||
|
||||
public static String setPathForUri(String uri, String path, boolean ensureTrailingSlash) throws URISyntaxException {
|
||||
path = StringUtils.prependIfMissing(path, "/");
|
||||
|
||||
|
|
|
@ -124,10 +124,11 @@ public class CloudInfo implements TraceableAttributes, Serializable {
|
|||
HttpClient localHttpClient = givenHttpClient == null ? HttpClientFactory.create(null) : givenHttpClient;
|
||||
try {
|
||||
HttpRequest request = new HttpRequest(HttpMethod.GET, UriUtils.appendPathToUri(clusterUrl, METADATA_ENDPOINT));
|
||||
request.setHeader(HttpHeaderName.ACCEPT_ENCODING, "gzip");
|
||||
request.setHeader(HttpHeaderName.ACCEPT_ENCODING, "gzip,deflate");
|
||||
request.setHeader(HttpHeaderName.ACCEPT, "application/json");
|
||||
|
||||
// trace CloudInfo.httpCall
|
||||
// Fixme: Make this async in the future
|
||||
try (HttpResponse response = MonitoredActivity.invoke(
|
||||
(SupplierOneException<HttpResponse, IOException>) () -> localHttpClient.sendSync(request, Context.NONE),
|
||||
"CloudInfo.httpCall")) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class KustoTrustedEndpoints {
|
|||
try {
|
||||
validateTrustedEndpoint(new URI(uri), loginEndpoint);
|
||||
} catch (URISyntaxException ex) {
|
||||
throw new KustoClientInvalidConnectionStringException(ex);
|
||||
throw new KustoClientInvalidConnectionStringException(uri, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,14 @@ package com.microsoft.azure.kusto.data.exceptions;
|
|||
This class represents an error that happened on the client side and is therefore considered permanent
|
||||
*/
|
||||
public class DataClientException extends KustoDataExceptionBase {
|
||||
public DataClientException(Exception ex) {
|
||||
this(ex.getMessage());
|
||||
}
|
||||
|
||||
public DataClientException(String message) {
|
||||
this(null, message);
|
||||
}
|
||||
|
||||
public DataClientException(String ingestionSource, String message) {
|
||||
this(ingestionSource, message, null);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.microsoft.azure.kusto.data.exceptions;
|
|||
/**
|
||||
* Raised when Kusto client is initialized with an invalid endpoint
|
||||
*/
|
||||
public class KustoClientInvalidConnectionStringException extends Exception {
|
||||
public class KustoClientInvalidConnectionStringException extends DataClientException {
|
||||
public KustoClientInvalidConnectionStringException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
@ -11,4 +11,8 @@ public class KustoClientInvalidConnectionStringException extends Exception {
|
|||
public KustoClientInvalidConnectionStringException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public KustoClientInvalidConnectionStringException(String clusterURL, String msg, Exception e) {
|
||||
super(clusterURL, msg, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,4 +207,4 @@ public class HeaderTest {
|
|||
return uncomplicatedHeaders;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,4 +151,4 @@ class UtilitiesTest {
|
|||
.addHeader("x-ms-activity-id", "1234")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,4 +90,4 @@ public class TestHttpResponse extends HttpResponse {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,12 +269,6 @@
|
|||
<artifactId>vavr</artifactId>
|
||||
<version>${io.vavr.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<version>${reactor.test.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.azure.kusto</groupId>
|
||||
<artifactId>kusto-data</artifactId>
|
||||
|
|
|
@ -391,6 +391,7 @@ class ResourceManager implements Closeable, IngestionResourceManager {
|
|||
public void reportIngestionResult(ResourceWithSas<?> resource, boolean success) {
|
||||
if (storageAccountSet == null) {
|
||||
log.warn("StorageAccountSet is null");
|
||||
return;
|
||||
}
|
||||
storageAccountSet.addResultToAccount(resource.getAccountName(), success);
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
// package com.microsoft.azure.kusto.ingest;
|
||||
//
|
||||
// import com.microsoft.azure.kusto.data.Client;
|
||||
// import com.microsoft.azure.kusto.data.ClientFactory;
|
||||
// import com.microsoft.azure.kusto.data.KustoOperationResult;
|
||||
// import com.microsoft.azure.kusto.data.KustoResultSetTable;
|
||||
// import com.microsoft.azure.kusto.data.auth.ConnectionStringBuilder;
|
||||
// import org.jetbrains.annotations.NotNull;
|
||||
// import org.junit.jupiter.api.Assertions;
|
||||
// import org.junit.jupiter.api.BeforeAll;
|
||||
// import org.junit.jupiter.api.Test;
|
||||
// import reactor.core.publisher.Mono;
|
||||
// import reactor.core.scheduler.Schedulers;
|
||||
// import reactor.test.StepVerifier;
|
||||
//
|
||||
// import java.net.URISyntaxException;
|
||||
//
|
||||
// public class AsyncE2ETest {
|
||||
//
|
||||
// private static Client queryClient;
|
||||
// private static String principalFqn;
|
||||
//
|
||||
// private static final String DB_NAME = System.getenv("TEST_DATABASE");
|
||||
// private static final String APP_ID = System.getenv("APP_ID");
|
||||
// private static final String APP_KEY = System.getenv("APP_KEY");
|
||||
// private static final String TENANT_ID = System.getenv().getOrDefault("TENANT_ID", "microsoft.com");
|
||||
// private static final String ENG_CONN_STR = System.getenv("ENGINE_CONNECTION_STRING");
|
||||
//
|
||||
// @BeforeAll
|
||||
// public static void setUp() {
|
||||
// principalFqn = String.format("aadapp=%s;%s", APP_ID, TENANT_ID);
|
||||
// ConnectionStringBuilder engineCsb = createConnection(ENG_CONN_STR);
|
||||
// engineCsb.setUserNameForTracing("Java_E2ETest_ø");
|
||||
// try {
|
||||
// queryClient = ClientFactory.createClient(engineCsb);
|
||||
// } catch (URISyntaxException ex) {
|
||||
// Assertions.fail("Failed to create query and streamingIngest client", ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// void testShowPrincipalsAsync() {
|
||||
// Mono<KustoOperationResult> laterResult = queryClient
|
||||
// .executeQueryAsync(DB_NAME, String.format(".show database %s principals", DB_NAME), null)
|
||||
// .subscribeOn(Schedulers.immediate());
|
||||
// StepVerifier.create(laterResult)
|
||||
// .expectNextCount(1L)
|
||||
// .expectNextMatches(this::resultContainsPrincipal)
|
||||
// .expectComplete()
|
||||
// .verify();
|
||||
// }
|
||||
//
|
||||
// private static @NotNull ConnectionStringBuilder createConnection(String connectionString) {
|
||||
// if (APP_KEY == null || APP_KEY.isEmpty()) {
|
||||
// return ConnectionStringBuilder.createWithAzureCli(connectionString);
|
||||
// }
|
||||
// return ConnectionStringBuilder.createWithAadApplicationCredentials(connectionString, APP_ID, APP_KEY, TENANT_ID);
|
||||
// }
|
||||
//
|
||||
// private boolean resultContainsPrincipal(KustoOperationResult result) {
|
||||
// boolean found = false;
|
||||
// KustoResultSetTable mainTableResultSet = result.getPrimaryResults();
|
||||
// while (mainTableResultSet.next()) {
|
||||
// if (mainTableResultSet.getString("PrincipalFQN").equals(principalFqn)) {
|
||||
// found = true;
|
||||
// }
|
||||
// }
|
||||
// return found;
|
||||
// }
|
||||
//
|
||||
// }
|
|
@ -39,9 +39,6 @@ import org.junit.jupiter.api.*;
|
|||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.Mockito;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -82,6 +79,7 @@ class E2ETest {
|
|||
private static final String TOKEN = System.getenv("TOKEN");
|
||||
private static final String PUBLIC_X509CER_FILE_LOC = System.getenv("PUBLIC_X509CER_FILE_LOC");
|
||||
private static final String PRIVATE_PKCS8_FILE_LOC = System.getenv("PRIVATE_PKCS8_FILE_LOC");
|
||||
private static final String CI_EXECUTION = System.getenv("CI_EXECUTION");
|
||||
|
||||
private static String principalFqn;
|
||||
private static String resourcesPath;
|
||||
|
@ -139,16 +137,16 @@ class E2ETest {
|
|||
@AfterAll
|
||||
public static void tearDown() {
|
||||
try {
|
||||
Assertions.assertNotNull(tableName, "Table name was not set");
|
||||
Assertions.assertNotNull(DB_NAME, "DB name was not set");
|
||||
queryClient.executeToJsonResult(DB_NAME, String.format(".drop table %s ifexists", tableName));
|
||||
ingestClient.close();
|
||||
managedStreamingIngestClient.close();
|
||||
} catch (Exception ex) {
|
||||
Assertions.fail("Failed to drop table", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isManualExecution() {
|
||||
return false;
|
||||
return CI_EXECUTION == null || !CI_EXECUTION.equals("1");
|
||||
}
|
||||
|
||||
private static void createTableAndMapping() {
|
||||
|
@ -315,9 +313,9 @@ class E2ETest {
|
|||
KustoOperationResult result = null;
|
||||
try {
|
||||
result = localQueryClient.executeMgmt(DB_NAME, String.format(".show database %s principals", DB_NAME));
|
||||
// result = localQueryClient.execute(databaseName, String.format(".show version"));
|
||||
} catch (Exception ex) {
|
||||
Assertions.fail("Failed to execute show database principals command", ex);
|
||||
Assertions.fail("Failed to execute show database principals command. " +
|
||||
"Is USERNAME_HINT set to your email in your environment variables?", ex);
|
||||
}
|
||||
return resultContainsPrincipal(result);
|
||||
}
|
||||
|
|
3
pom.xml
3
pom.xml
|
@ -35,7 +35,7 @@
|
|||
<revision>6.0.0</revision> <!-- CHANGE THIS to adjust project version-->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<azure-bom-version>1.2.24</azure-bom-version>
|
||||
<azure-bom-version>1.2.25</azure-bom-version>
|
||||
|
||||
<!-- Versions below are for several dependencies we're using in the data & ingest modules -->
|
||||
<!-- Ideally, versions below should align with latest databricks runtime dependency versions -->
|
||||
|
@ -55,7 +55,6 @@
|
|||
<jsonassert.version>1.5.0</jsonassert.version>
|
||||
<sqlite-jdbc.version>3.45.3.0</sqlite-jdbc.version>
|
||||
<annotations.version>24.1.0</annotations.version>
|
||||
<reactor.test.version>3.6.6</reactor.test.version>
|
||||
<!-- Other dependencies -->
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
|
||||
|
|
Загрузка…
Ссылка в новой задаче