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

Merge py integration tests into the main suite #2834

Merged
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
6 changes: 0 additions & 6 deletions Integrations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,8 @@ Closure composeConfig = { task ->
}

def pyTest = runInDocker('test-py-deephaven', '../py/server', ['python3', '-m', 'xmlrunner', 'discover', '-s', 'tests', '-t', '.', '-v', '-o', '/out/report'], composeConfig)
def pyTestIntegration = runInDocker('test-py-deephaven-integration', '../py/server', ['/bin/bash', '-c', 'PYTHONPATH=/python integration-tests/run-tests.sh'], composeConfig)

pyTest.configure({
onlyIf { TestTools.shouldRunTests(project) }
})
tasks.getByName('check').dependsOn(pyTest)

pyTestIntegration.configure({
onlyIf { TestTools.shouldRunTests(project) }
})
tasks.getByName('check').dependsOn(pyTestIntegration)
23 changes: 0 additions & 23 deletions py/server/integration-tests/null_integers_test.py

This file was deleted.

42 changes: 0 additions & 42 deletions py/server/integration-tests/numbers_from_list_and_func_test.py

This file was deleted.

24 changes: 0 additions & 24 deletions py/server/integration-tests/perfmon_test.py

This file was deleted.

24 changes: 0 additions & 24 deletions py/server/integration-tests/pylong_conv_test.py

This file was deleted.

34 changes: 0 additions & 34 deletions py/server/integration-tests/pyobj_field_access_test.py

This file was deleted.

14 changes: 0 additions & 14 deletions py/server/integration-tests/run-tests.sh

This file was deleted.

35 changes: 34 additions & 1 deletion py/server/tests/test_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from dataclasses import dataclass

from deephaven import DHError, dtypes, new_table
from deephaven.jcompat import j_array_list
from deephaven import empty_table
from deephaven.column import byte_col, char_col, short_col, bool_col, int_col, long_col, float_col, double_col, \
string_col, datetime_col, jobj_col, ColumnType
from deephaven.constants import MAX_BYTE, MAX_SHORT, MAX_INT, MAX_LONG
from deephaven.jcompat import j_array_list
from tests.testbase import BaseTestCase


Expand Down Expand Up @@ -70,6 +72,37 @@ def test_array_column(self):
self.assertIsNone(test_table.columns[0].component_type)
self.assertEqual(test_table.columns[1].component_type, dtypes.double)

def test_numeric_columns(self):
x = [MAX_BYTE, MAX_SHORT, MAX_INT, MAX_LONG, 0.98888, 999999.888888]
n = len(x)

def get_x(i):
return x[i]

t_list = empty_table(n).update(["X = x[i]"])
t_func = empty_table(n).update(["X = get_x(i)"])
# We want to test that casting on both PyObject and JObject works as expected.
self.assertEqual(t_list.columns[0].data_type, dtypes.PyObject)
self.assertEqual(t_func.columns[0].data_type, dtypes.JObject)

t_list_integers = t_list.update(
["A = (byte)X", "B = (short)X", "C = (int)X", "D = (long)X", "E = (float)X", "F = (double)X"])
self.assertEqual(t_list_integers.columns[1].data_type, dtypes.byte)
self.assertEqual(t_list_integers.columns[2].data_type, dtypes.short)
self.assertEqual(t_list_integers.columns[3].data_type, dtypes.int32)
self.assertEqual(t_list_integers.columns[4].data_type, dtypes.long)
self.assertEqual(t_list_integers.columns[5].data_type, dtypes.float32)
self.assertEqual(t_list_integers.columns[6].data_type, dtypes.double)

t_func_integers = t_func.update(
["A = (byte)X", "B = (short)X", "C = (int)X", "D = (long)X", "E = (float)X", "F = (double)X"])
self.assertEqual(t_func_integers.columns[1].data_type, dtypes.byte)
self.assertEqual(t_func_integers.columns[2].data_type, dtypes.short)
self.assertEqual(t_func_integers.columns[3].data_type, dtypes.int32)
self.assertEqual(t_func_integers.columns[4].data_type, dtypes.long)
self.assertEqual(t_list_integers.columns[5].data_type, dtypes.float32)
self.assertEqual(t_list_integers.columns[6].data_type, dtypes.float64)


@dataclass
class CustomClass:
Expand Down
14 changes: 14 additions & 0 deletions py/server/tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
#

from deephaven import empty_table
from deephaven.constants import *
from tests.testbase import BaseTestCase

Expand Down Expand Up @@ -43,3 +44,16 @@ def test_constants_values(self):
self.assertEqual(NULL_SHORT, -32768)
self.assertEqual(POS_INFINITY_DOUBLE, float('inf'))
self.assertEqual(POS_INFINITY_FLOAT, float('inf'))

def test_return_null_long(self):
null_byte = NULL_BYTE
null_short = NULL_SHORT
null_int = NULL_INT
null_long = NULL_LONG

def return_null_long():
return NULL_LONG

t = empty_table(9).update(
["X = null_byte", "Y = null_short", "YY = null_int", "Z = null_long", "ZZ = (long)return_null_long()"])
self.assertEqual(t.to_string().count("null"), 45)
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

from numba import vectorize, int64

from test_helper import start_jvm
start_jvm()

from deephaven import empty_table
from deephaven.html import to_html

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

from numba import vectorize, int64, boolean, short

from test_helper import start_jvm
start_jvm()

from deephaven import empty_table
from deephaven.html import to_html

Expand Down
12 changes: 11 additions & 1 deletion py/server/tests/test_perfmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import unittest

from deephaven import empty_table

from deephaven.perfmon import process_info_log, process_metrics_log, server_state_log, \
query_operation_performance_log, query_performance_log, update_performance_log, metrics_get_counters, \
metrics_reset_counters
from deephaven.perfmon import query_update_performance, query_performance, query_operation_performance, server_state
from tests.testbase import BaseTestCase


Expand Down Expand Up @@ -54,6 +54,16 @@ def test_query_logs(self):
log_table = update_performance_log()
self.assertTrue(log_table.to_string())

def test_performance_queries(self):
q = query_performance(1)
self.assertTrue(q.to_string())
q = query_operation_performance(1)
self.assertTrue(q.to_string())
q = server_state()
self.assertTrue(q.to_string())
q = query_update_performance(1)
self.assertTrue(q.to_string())


if __name__ == '__main__':
unittest.main()
35 changes: 30 additions & 5 deletions py/server/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from deephaven import DHError, read_csv, empty_table, SortDirection, AsOfMatchRule, time_table, ugp
from deephaven.agg import sum_, weighted_avg, avg, pct, group, count_, first, last, max_, median, min_, std, abs_sum, \
var, formula, partition
from deephaven.html import to_html
from deephaven.pandas import to_pandas
from deephaven.table import Table
from tests.testbase import BaseTestCase
Expand Down Expand Up @@ -624,11 +625,12 @@ def closure_fn() -> str:

def test_nested_scopes(self):
_JExecutionContext = jpy.get_type("io.deephaven.engine.context.ExecutionContext")
context = _JExecutionContext.newBuilder() \
.captureQueryCompiler() \
.captureQueryLibrary() \
.captureQueryScope() \
.build()
context = (_JExecutionContext.newBuilder()
.captureQueryCompiler()
.captureQueryLibrary()
.captureQueryScope()
.build())

def inner_func(p) -> str:
openContext = context.open()
t = empty_table(1).update("X = p * 10")
Expand Down Expand Up @@ -724,6 +726,20 @@ def test_ticking_table_scope(self):
self.wait_ticking_table_update(rt, row_count=rt.size + 1, timeout=5)
self.verify_table_data(rt, list(range(1, 5)))

def test_long_number_conversion(self):
long_value = 2 ** 32 + 5
t = empty_table(1)
result = t.update("X = long_value").to_string(1)
self.assertEqual(long_value, int(result.split()[2]))

def test_python_field_access(self):
t = empty_table(10)
t2 = t.update(formulas=["SYM = `AAPL-` + (String)foo.name", "PRICE = i * 1000"]).where(
"PRICE > (int)foo.price + 100")
html_output = to_html(t2)
self.assertIn("AAPL-GOOG", html_output)
self.assertIn("2000", html_output)


def global_fn() -> str:
return "global str"
Expand All @@ -732,5 +748,14 @@ def global_fn() -> str:
global_int = 1001
a_number = 10001


class EmptyCls:
...


foo = EmptyCls()
foo.name = "GOOG"
foo.price = 1000

if __name__ == "__main__":
unittest.main()