Skip to content

Commit

Permalink
Merge branch 'main' into spark-application
Browse files Browse the repository at this point in the history
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
  • Loading branch information
rupal-bq committed Jun 23, 2023
2 parents ec08d0b + 34cad6e commit 65e0b1c
Show file tree
Hide file tree
Showing 64 changed files with 2,014 additions and 326 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral() // For Elastic Libs that you can use to get started coding until open OpenSearch libs are available
maven { url 'https://jitpack.io' }
}

allprojects {
Expand All @@ -91,15 +92,19 @@ allprojects {
plugins.withId('java') {
sourceCompatibility = targetCompatibility = "11"
}
configurations.all {
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0"
}
}

subprojects {
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
// todo. remove this when lucene 9.4.0 is released
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url 'https://jitpack.io' }
}
}

Expand Down Expand Up @@ -180,7 +185,7 @@ configurations.all {
exclude group: "commons-logging", module: "commons-logging"
// enforce 1.1.3, https://www.whitesourcesoftware.com/vulnerability-database/WS-2019-0379
resolutionStrategy.force 'commons-codec:commons-codec:1.13'
resolutionStrategy.force 'com.google.guava:guava:31.0.1-jre'
resolutionStrategy.force 'com.google.guava:guava:32.0.1-jre'
}

// updateVersion: Task to auto increment to the next development iteration
Expand Down
21 changes: 21 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,30 @@ dependencies {
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.17.1'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
api group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.3'
implementation 'com.github.babbel:okhttp-aws-signer:1.0.2'
api group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.12.1'
api group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: '1.12.1'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
testImplementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.12.4'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '4.9.3'
}


configurations.all {
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}"
resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
resolutionStrategy.force "com.squareup.okhttp3:okhttp:4.9.3"
resolutionStrategy.force "org.apache.httpcomponents:httpcore:4.4.13"
resolutionStrategy.force "joda-time:joda-time:2.10.12"
resolutionStrategy.force "org.slf4j:slf4j-api:1.7.36"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

package org.opensearch.sql.prometheus.authinterceptors;
package org.opensearch.sql.common.authinterceptors;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

package org.opensearch.sql.prometheus.authinterceptors;
package org.opensearch.sql.common.authinterceptors;

import java.io.IOException;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ public enum Key {
*/
QUERY_MEMORY_LIMIT("plugins.query.memory_limit"),
QUERY_SIZE_LIMIT("plugins.query.size_limit"),
ENCYRPTION_MASTER_KEY("plugins.query.datasources.encryption.masterkey"),
DATASOURCES_URI_ALLOWHOSTS("plugins.query.datasources.uri.allowhosts"),

METRICS_ROLLING_WINDOW("plugins.query.metrics.rolling_window"),
METRICS_ROLLING_INTERVAL("plugins.query.metrics.rolling_interval");
METRICS_ROLLING_INTERVAL("plugins.query.metrics.rolling_interval"),

CLUSTER_NAME("cluster.name");

@Getter
private final String keyValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

package org.opensearch.sql.prometheus.authinterceptors;
package org.opensearch.sql.common.authinterceptors;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -15,7 +15,6 @@
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
import com.amazonaws.auth.STSSessionCredentialsProvider;
import lombok.SneakyThrows;
import okhttp3.Interceptor;
import okhttp3.Request;
Expand All @@ -25,7 +24,9 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opensearch.sql.common.authinterceptors.AwsSigningInterceptor;

@ExtendWith(MockitoExtension.class)
public class AwsSigningInterceptorTest {
Expand Down Expand Up @@ -54,15 +55,15 @@ void testConstructors() {
@Test
@SneakyThrows
void testIntercept() {
when(chain.request()).thenReturn(new Request.Builder()
Mockito.when(chain.request()).thenReturn(new Request.Builder()
.url("http://localhost:9090")
.build());
AwsSigningInterceptor awsSigningInterceptor
= new AwsSigningInterceptor(
getStaticAWSCredentialsProvider("testAccessKey", "testSecretKey"),
"us-east-1", "aps");
awsSigningInterceptor.intercept(chain);
verify(chain).proceed(requestArgumentCaptor.capture());
Mockito.verify(chain).proceed(requestArgumentCaptor.capture());
Request request = requestArgumentCaptor.getValue();
Assertions.assertNotNull(request.headers("Authorization"));
Assertions.assertNotNull(request.headers("x-amz-date"));
Expand All @@ -73,16 +74,16 @@ void testIntercept() {
@Test
@SneakyThrows
void testSTSCredentialsProviderInterceptor() {
when(chain.request()).thenReturn(new Request.Builder()
Mockito.when(chain.request()).thenReturn(new Request.Builder()
.url("http://localhost:9090")
.build());
when(stsAssumeRoleSessionCredentialsProvider.getCredentials())
Mockito.when(stsAssumeRoleSessionCredentialsProvider.getCredentials())
.thenReturn(getAWSSessionCredentials());
AwsSigningInterceptor awsSigningInterceptor
= new AwsSigningInterceptor(stsAssumeRoleSessionCredentialsProvider,
"us-east-1", "aps");
awsSigningInterceptor.intercept(chain);
verify(chain).proceed(requestArgumentCaptor.capture());
Mockito.verify(chain).proceed(requestArgumentCaptor.capture());
Request request = requestArgumentCaptor.getValue();
Assertions.assertNotNull(request.headers("Authorization"));
Assertions.assertNotNull(request.headers("x-amz-date"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*
*/

package org.opensearch.sql.prometheus.authinterceptors;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package org.opensearch.sql.common.authinterceptors;

import java.util.Collections;
import lombok.SneakyThrows;
Expand All @@ -21,7 +18,7 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.internal.matchers.Null;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
Expand All @@ -45,13 +42,13 @@ void testConstructors() {
@Test
@SneakyThrows
void testIntercept() {
when(chain.request()).thenReturn(new Request.Builder()
Mockito.when(chain.request()).thenReturn(new Request.Builder()
.url("http://localhost:9090")
.build());
BasicAuthenticationInterceptor basicAuthenticationInterceptor
= new BasicAuthenticationInterceptor("testAdmin", "testPassword");
basicAuthenticationInterceptor.intercept(chain);
verify(chain).proceed(requestArgumentCaptor.capture());
Mockito.verify(chain).proceed(requestArgumentCaptor.capture());
Request request = requestArgumentCaptor.getValue();
Assertions.assertEquals(
Collections.singletonList(Credentials.basic("testAdmin", "testPassword")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class Cast extends UnresolvedExpression {
private final UnresolvedExpression expression;

/**
* Expression that represents ELSE statement result.
* Expression that represents name of the target type.
*/
private final UnresolvedExpression convertedType;

Expand Down
Loading

0 comments on commit 65e0b1c

Please sign in to comment.