Skip to content

Commit

Permalink
fix Jenkins CI pipeline for OS 3.0 version bump (#901)
Browse files Browse the repository at this point in the history
* fix Jenkins CI pipeline for OS 3.0 version bump

Signed-off-by: Sicheng Song <[email protected]>

* Remove build cache

Signed-off-by: Sicheng Song <[email protected]>

* Bug fix

Signed-off-by: Sicheng Song <[email protected]>

* Code fix on OS 3.0 major refactor

Signed-off-by: Sicheng Song <[email protected]>

---------

Signed-off-by: Sicheng Song <[email protected]>
  • Loading branch information
b4sjoo authored May 25, 2023
1 parent ce6e6c7 commit dd54ea5
Show file tree
Hide file tree
Showing 54 changed files with 383 additions and 307 deletions.
1 change: 1 addition & 0 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jacocoTestCoverageVerification {
check.dependsOn jacocoTestCoverageVerification

tasks.named("jar").configure { dependsOn("publishShadowPublicationToMavenLocal") }
tasks.named("jar").configure { dependsOn("publishShadowPublicationToStagingRepository") }

shadowJar {
archiveClassifier.set(null)
Expand Down
14 changes: 8 additions & 6 deletions common/src/test/java/org/opensearch/ml/common/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.ml.common;

import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.bytes.BytesReference;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentFactory;
Expand All @@ -16,7 +16,6 @@
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;


import java.io.IOException;
import java.util.function.Function;

Expand All @@ -26,7 +25,8 @@ public static <T> void testParse(ToXContentObject obj, Function<XContentParser,
testParse(obj, function, false);
}

public static <T> void testParse(ToXContentObject obj, Function<XContentParser, T> function, boolean wrapWithObject) throws IOException {
public static <T> void testParse(ToXContentObject obj, Function<XContentParser, T> function, boolean wrapWithObject)
throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
if (wrapWithObject) {
builder.startObject();
Expand All @@ -35,12 +35,14 @@ public static <T> void testParse(ToXContentObject obj, Function<XContentParser,
if (wrapWithObject) {
builder.endObject();
}
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
testParseFromString(obj, jsonStr, function);
}

public static <T> void testParseFromString(ToXContentObject obj, String jsonStr, Function<XContentParser, T> function) throws IOException {
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, jsonStr);
public static <T> void testParseFromString(ToXContentObject obj, String jsonStr,
Function<XContentParser, T> function) throws IOException {
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE, jsonStr);
parser.nextToken();
T parsedObj = function.apply(parser);
obj.equals(parsedObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.XContentBuilder;
Expand All @@ -31,7 +31,7 @@ public void testToXContent() throws IOException {
value.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"BOOLEAN\",\"value\":true}", jsonStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.junit.Before;
import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
Expand Down Expand Up @@ -55,7 +55,7 @@ public void testToXContent() throws IOException {
columnMeta.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"name\":\"columnMetaName\",\"column_type\":\"STRING\"}", jsonStr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -173,21 +173,21 @@ public void columnMetas_Success() {
}

@Test
public void remove_Exception_InputColumnIndexBiggerThanColumensLength(){
public void remove_Exception_InputColumnIndexBiggerThanColumensLength() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("columnIndex can't be negative or bigger than columns length:4");
defaultDataFrame.remove(4);
}

@Test
public void remove_Exception_InputColumnIndexNegtiveColumensLength(){
public void remove_Exception_InputColumnIndexNegtiveColumensLength() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("columnIndex can't be negative or bigger than columns length:4");
defaultDataFrame.remove(-1);
}

@Test
public void remove_EmptyColumnMeta(){
public void remove_EmptyColumnMeta() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("columnIndex can't be negative or bigger than columns length:0");
DefaultDataFrame dataFrame = new DefaultDataFrame(new ColumnMeta[0]);
Expand All @@ -196,31 +196,31 @@ public void remove_EmptyColumnMeta(){
}

@Test
public void remove_Success(){
public void remove_Success() {
DataFrame dataFrame = defaultDataFrame.remove(3);
assertEquals(3, dataFrame.columnMetas().length);
assertEquals(3, dataFrame.getRow(0).size());
}

@Test
public void select_Success(){
DataFrame dataFrame = defaultDataFrame.select(new int[]{1, 3});
public void select_Success() {
DataFrame dataFrame = defaultDataFrame.select(new int[] { 1, 3 });
assertEquals(2, dataFrame.columnMetas().length);
assertEquals(2, dataFrame.getRow(0).size());
}

@Test
public void select_Exception_EmptyInputColumns(){
public void select_Exception_EmptyInputColumns() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("columns can't be null or empty");
defaultDataFrame.select(new int[0]);
}

@Test
public void select_Exception_InvalidColumn(){
public void select_Exception_InvalidColumn() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("columnIndex can't be negative or bigger than columns length");
defaultDataFrame.select(new int[]{5});
defaultDataFrame.select(new int[] { 5 });
}

@Test
Expand All @@ -231,43 +231,44 @@ public void testToXContent() throws IOException {
builder.endObject();

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_metas\":[" +
"{\"name\":\"c1\",\"column_type\":\"STRING\"}," +
"{\"name\":\"c2\",\"column_type\":\"INTEGER\"}," +
"{\"name\":\"c3\",\"column_type\":\"DOUBLE\"}," +
"{\"name\":\"c4\",\"column_type\":\"BOOLEAN\"}]," +
"\"rows\":[" +
"{\"values\":[" +
"{\"column_type\":\"STRING\",\"value\":\"string\"}," +
"{\"column_type\":\"INTEGER\",\"value\":1}," +
"{\"column_type\":\"DOUBLE\",\"value\":2.0}," +
"{\"column_type\":\"BOOLEAN\",\"value\":true}]}]}", jsonStr);
"{\"name\":\"c1\",\"column_type\":\"STRING\"}," +
"{\"name\":\"c2\",\"column_type\":\"INTEGER\"}," +
"{\"name\":\"c3\",\"column_type\":\"DOUBLE\"}," +
"{\"name\":\"c4\",\"column_type\":\"BOOLEAN\"}]," +
"\"rows\":[" +
"{\"values\":[" +
"{\"column_type\":\"STRING\",\"value\":\"string\"}," +
"{\"column_type\":\"INTEGER\",\"value\":1}," +
"{\"column_type\":\"DOUBLE\",\"value\":2.0}," +
"{\"column_type\":\"BOOLEAN\",\"value\":true}]}]}", jsonStr);
}

@Test
public void testParse_EmptyDataFrame() throws IOException {
ColumnMeta[] columnMetas = new ColumnMeta[] {new ColumnMeta("test_int", ColumnType.INTEGER)};
ColumnMeta[] columnMetas = new ColumnMeta[] { new ColumnMeta("test_int", ColumnType.INTEGER) };
DefaultDataFrame dataFrame = new DefaultDataFrame(columnMetas);
TestHelper.testParse(dataFrame, function, true);
}

@Test
public void testParse_DataFrame() throws IOException {
ColumnMeta[] columnMetas = new ColumnMeta[] {new ColumnMeta("test_int", ColumnType.INTEGER)};
ColumnMeta[] columnMetas = new ColumnMeta[] { new ColumnMeta("test_int", ColumnType.INTEGER) };
DefaultDataFrame dataFrame = new DefaultDataFrame(columnMetas);
dataFrame.appendRow(new Integer[]{1});
dataFrame.appendRow(new Integer[]{2});
dataFrame.appendRow(new Integer[] { 1 });
dataFrame.appendRow(new Integer[] { 2 });
TestHelper.testParse(dataFrame, function, true);
}

@Test
public void testParse_WrongExtraField() throws IOException {
ColumnMeta[] columnMetas = new ColumnMeta[] {new ColumnMeta("test_int", ColumnType.INTEGER)};
ColumnMeta[] columnMetas = new ColumnMeta[] { new ColumnMeta("test_int", ColumnType.INTEGER) };
DefaultDataFrame dataFrame = new DefaultDataFrame(columnMetas);
dataFrame.appendRow(new Integer[]{1});
dataFrame.appendRow(new Integer[]{2});
String jsonStr = "{\"wrong_field\":{\"test\":\"abc\"},\"column_metas\":[{\"name\":\"test_int\",\"column_type\":" +
dataFrame.appendRow(new Integer[] { 1 });
dataFrame.appendRow(new Integer[] { 2 });
String jsonStr = "{\"wrong_field\":{\"test\":\"abc\"},\"column_metas\":[{\"name\":\"test_int\",\"column_type\":"
+
"\"INTEGER\"}],\"rows\":[{\"values\":[{\"column_type\":\"INTEGER\",\"value\":1}]},{\"values\":" +
"[{\"column_type\":\"INTEGER\",\"value\":2}]}]}";
TestHelper.testParseFromString(dataFrame, jsonStr, function);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void testToXContent() throws IOException {
doubleValue.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"DOUBLE\",\"value\":5.0}", jsonStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.XContentBuilder;
Expand Down Expand Up @@ -34,7 +34,7 @@ public void testToXContent() throws IOException {
floatValue.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"FLOAT\",\"value\":2.1}", jsonStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.XContentBuilder;
Expand All @@ -33,7 +33,7 @@ public void testToXContent() throws IOException {
intValue.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"INTEGER\",\"value\":2}", jsonStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.XContentBuilder;
Expand All @@ -20,20 +20,20 @@ public class LongValueTest {

@Test
public void longValue() {
LongValue longValue = new LongValue((long)2);
LongValue longValue = new LongValue((long) 2);
assertEquals(ColumnType.LONG, longValue.columnType());
assertEquals(2L, longValue.getValue());
assertEquals(2.0d, longValue.doubleValue(), 1e-5);
}

@Test
public void testToXContent() throws IOException {
LongValue longValue = new LongValue((long)2);
LongValue longValue = new LongValue((long) 2);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
longValue.toXContent(builder);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"LONG\",\"value\":2}", jsonStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.ml.common.dataframe;

import org.junit.Test;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.ToXContent;
Expand Down Expand Up @@ -34,7 +34,7 @@ public void testToXContent() throws IOException {
value.toXContent(builder, ToXContent.EMPTY_PARAMS);

assertNotNull(builder);
String jsonStr = Strings.toString(builder);
String jsonStr = org.opensearch.common.Strings.toString(builder);
assertEquals("{\"column_type\":\"NULL\"}", jsonStr);
}
}
Loading

0 comments on commit dd54ea5

Please sign in to comment.