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

#969: Use new CTPG parser in java vm #455

Merged
merged 43 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
77e9955
#969: Use new CTPG parser in java vm
tomuben Oct 2, 2024
780ff35
Added CTPG specific tests
tomuben Oct 10, 2024
6739678
Findings from review
tomuben Oct 11, 2024
3c66a0b
Limit max recursion for script importer and added a test.
tomuben Oct 11, 2024
ba28b85
Added valgrind/asan tests
tomuben Oct 11, 2024
fa1ccb9
Fixed GH Workflow
tomuben Oct 11, 2024
dfdda46
Fixed GH Workflow
tomuben Oct 11, 2024
79553b2
Fixed GH Workflow
tomuben Oct 11, 2024
b3c1c7c
Fixed GH Workflow
tomuben Oct 11, 2024
25e21e9
Fixed GH Workflow
tomuben Oct 11, 2024
0ef2b94
Fixed GH Workflow
tomuben Oct 11, 2024
9be6303
Fixed GH Workflow
tomuben Oct 11, 2024
ee31d02
Fixed memory allocation/deallocation issue reported by ASAN in tests
tomuben Oct 11, 2024
f9663d1
Upload test logs only in error case
tomuben Oct 11, 2024
c53ce9e
Deactivate slow tests under valgrind
tomuben Oct 11, 2024
9dba9d2
Inject a memory problem....let's see which checks find the problem....
tomuben Oct 11, 2024
cd61bc0
Removed memory corruption
tomuben Oct 13, 2024
a145b98
Added bazel config for valgrind
tomuben Oct 13, 2024
a01b4fd
Removed (unnecessary) timeout for asan test
tomuben Oct 13, 2024
4607321
Added builder for JavaVM
tomuben Oct 13, 2024
3be1631
Added description to ctpg_script_importer_test.cc
tomuben Oct 14, 2024
60915e5
Optimization in script_option_lines_ctpg.cc
tomuben Oct 14, 2024
9dd5a31
Added performance tests
tomuben Oct 14, 2024
85ca346
Activated valgrind memory leak check
tomuben Oct 14, 2024
56c94fc
Install R for test_package_management_scripts.yaml
tomuben Oct 14, 2024
967c71f
Added comment in parser_ctpg_script_importer.cc
tomuben Oct 14, 2024
8dc5834
Move SwigFactory creation from udf client into JavaContainerBuilder c…
tomuben Oct 14, 2024
f1b1940
Fixed JavaContainerBuilder::useCtpgParser
tomuben Oct 14, 2024
a846279
Added virtual destructor to SwigFactory.
tomuben Oct 14, 2024
ef099fd
Fixed compiler errors
tomuben Oct 15, 2024
e63355c
Added a bazl build check
tomuben Oct 15, 2024
5bd6219
Fixed formatting in check_bazel_tests.yml
tomuben Oct 15, 2024
66afcb0
Fixed formatting in check_bazel_tests.yml
tomuben Oct 15, 2024
f6ebc7e
Removed Java from bazel build (dependencies not installed)
tomuben Oct 15, 2024
8f570d6
Added Python env variables in check_bazel_tests.yml
tomuben Oct 15, 2024
89f29f2
fixed Python env variables in check_bazel_tests.yml
tomuben Oct 15, 2024
c6ca998
Added protobuf compiler to build job in check_bazel_tests.yml
tomuben Oct 15, 2024
53c9606
Created installUdfClientDeps.sh
tomuben Oct 15, 2024
d69208b
Run installUdfClientDeps.sh as sudo
tomuben Oct 15, 2024
f09a77d
Update exaudfclient/base/javacontainer/script_options/parser_ctpg_scr…
tomuben Oct 15, 2024
4287b0e
Don't use installUdfClientDeps.sh for bazel test
tomuben Oct 15, 2024
e39d4c7
Fixed installation of bazel in check_bazel_tests.yml
tomuben Oct 15, 2024
c812821
Fixed execution of bazel tests in check_bazel_tests.yml
tomuben Oct 15, 2024
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
100 changes: 72 additions & 28 deletions .github/workflows/check_bazel_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,82 @@ on:
- master
pull_request:


env:
USE_BAZEL_VERSION: 7.2.1
jobs:
build:
runs-on: ubuntu-latest

env:
USE_BAZEL_VERSION: 7.2.1
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
- name: Search for duplicated error codes
run: bash find_duplicate_error_codes.sh

- name: Search for duplicated error codes
run: bash find_duplicate_error_codes.sh
- name: Install bazel
run: |
curl -L -o bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
chmod +x bazel
- name: Install JDK and ZMQ
run: |
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk libzmq3-dev
- name: Build
run: |
bazel build --lockfile_mode=off --config no-tty -c dbg --config python --config fast-binary --verbose_failures
tomuben marked this conversation as resolved.
Show resolved Hide resolved
working-directory: ./exaudfclient/

- name: Install bazel
run: |
curl -L -o bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
chmod +x bazel
- name: Install JDK and ZMQ
run: |
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk libzmq3-dev
- name: Java Tests
run: |
bazel test //base/javacontainer/test/...
working-directory: ./exaudfclient/
- name: ExaudfLib Tests
run: |
bazel test //base/exaudflib/test/...
working-directory: ./exaudfclient/
- name: Script Options Parser Tests
run: |
bazel test //base/script_options_parser/...
working-directory: ./exaudfclient/
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- test: "//base/javacontainer/test:ExaStackTraceCleanerTest"
name: "ExaStackTraceCleanerTest"
- test: "//base/javacontainer/test:javacontainer-test-legacy-parser"
name: "javacontainer-test-legacy-parser"
- test: "//base/javacontainer/test:javacontainer-test-ctpg-parser"
name: "javacontainer-test-ctpg-parser"
- test: "//base/javacontainer/script_options/..."
name: "javacontainer-script_options"
- test: "//base/exaudflib/test/..."
name: "exaudflib"
- test: "//base/script_options_parser/ctpg/..."
name: "script_options_parser_ctpg"
- test: "//base/script_options_parser/legacy/..."
name: "script_options_parser_legacy"
- test: "--run_under='valgrind --leak-check=yes' --config=valgrind //base/javacontainer/test:javacontainer-test-legacy-parser"
name: "javacontainer-test-legacy-parser-with-valgrind"
- test: "--run_under='valgrind --leak-check=yes' --config=valgrind //base/javacontainer/test:javacontainer-test-ctpg-parser"
name: "javacontainer-test-ctpg-parser-with-valgrind"
- test: "--run_under='valgrind --leak-check=yes' --config=valgrind //base/script_options_parser/ctpg/..."
name: "script_options_parser_ctpg_with_valgrind"
- test: "--run_under='valgrind --leak-check=yes' --config=valgrind //base/script_options_parser/legacy/..."
name: "script_options_parser_legacy_with_valgrind"
- test: "--config=asan //base/javacontainer/test:javacontainer-test-legacy-parser"
name: "javacontainer-test-legacy-parser-with-asan"
- test: "--config=asan //base/javacontainer/test:javacontainer-test-ctpg-parser"
name: "javacontainer-test-ctpg-parser-with-asan"
- test: "--config=asan //base/script_options_parser/ctpg/..."
name: "script_options_parser_ctpg_with_asan"
- test: "--config=asan //base/script_options_parser/legacy/..."
name: "script_options_parser_legacy_with_asan"
steps:
- uses: actions/checkout@v4
- name: Install bazel
run: |
curl -L -o bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
chmod +x bazel
- name: Install JDK and ZMQ
run: |
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk libzmq3-dev valgrind
- name: Run tests
run: |
bazel test ${{ matrix.additional_args }} ${{ matrix.test }}
working-directory: ./exaudfclient/

- uses: actions/upload-artifact@v4
if: failure()
with:
name: "${{ matrix.name }}"
path: /home/runner/.cache/bazel/_bazel_runner/*/execroot/_main/bazel-out/k8-dbg/testlogs/**/test.log
2 changes: 2 additions & 0 deletions .github/workflows/test_package_management_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
with:
python-version: "3.10"

- uses: r-lib/actions/setup-r@v2

- name: Init submodules
run: git submodule update --init --recursive

Expand Down
13 changes: 13 additions & 0 deletions exaudfclient/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ build:optimize --copt="-g0" --copt="-DNDEBUG" --copt=-fstack-protector-strong --
build:no-tty --curses=no --color=no
build:debug-build --sandbox_debug --config=verbose
build:no-symlinks --symlink_prefix=/
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -O1
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
build:asan -c dbg
build:valgrind --copt -O1
build:valgrind -c dbg
build:valgrind --copt -g
build:valgrind --strip=never
build:valgrind --copt -DVALGRIND_ACTIVE
4 changes: 2 additions & 2 deletions exaudfclient/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cc_binary(
srcs = ["exaudfclient.cc", "//base:load_dynamic"],
linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace
deps = ["//base/exaudflib:header", "//base/utils:utils"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+
["//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory"],
["//base/exaudflib:exaudflib-deps"],
defines = VM_ENABLED_DEFINES,
data = ["//base:libexaudflib_complete.so"]
)
Expand All @@ -101,7 +101,7 @@ cc_binary(
srcs = ["exaudfclient.cc", "//base:load_dynamic"],
linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace
deps = ["//base/exaudflib:header", "//base/utils:utils"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+
["//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory"] +
["//base/exaudflib:exaudflib-deps"] +
[ "@zmq//:zmq", "@protobuf//:protobuf"],
defines = VM_ENABLED_DEFINES,
data = ["//base:libexaudflib_complete.so"],
Expand Down
7 changes: 4 additions & 3 deletions exaudfclient/base/javacontainer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ cc_library(

cc_library(
name = "javacontainer",
srcs = [":javacontainer.cc", ":javacontainer.h", ":javacontainer_impl.cc", ":javacontainer_impl.h", ":dummy"],
srcs = [":javacontainer.cc", ":javacontainer.h", ":javacontainer_impl.cc", ":javacontainer_impl.h",
":javacontainer_builder.h", ":javacontainer_builder.cc", ":dummy"],
hdrs = [":filter_swig_code_exascript_java_h", "exascript_java_jni_decl.h"],
deps = ["@ssl//:ssl","@java//:java", ":exascript_java", "//base/exaudflib:header",
deps = ["@java//:java", ":exascript_java", "//base/exaudflib:header",
"//base/utils:utils","//base/javacontainer/script_options:java_script_option_lines",
"//base/swig_factory:swig_factory_if"],
"//base/swig_factory:swig_factory"],
# copts= ["-O0","-fno-lto"],
alwayslink=True,
)
Expand Down
5 changes: 3 additions & 2 deletions exaudfclient/base/javacontainer/javacontainer.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "base/javacontainer/javacontainer.h"
#include "base/javacontainer/javacontainer_impl.h"
#include "base/javacontainer/script_options/parser.h"

using namespace SWIGVMContainers;
using namespace std;

JavaVMach::JavaVMach(bool checkOnly, SwigFactory& swigFactory) {
JavaVMach::JavaVMach(bool checkOnly, std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser) {
try {
m_impl = new JavaVMImpl(checkOnly, false, swigFactory);
m_impl = new JavaVMImpl(checkOnly, false, std::move(scriptOptionsParser));
} catch (std::exception& err) {
lock_guard<mutex> lock(exception_msg_mtx);
exception_msg = "F-UDF-CL-SL-JAVA-1000: "+std::string(err.what());
Expand Down
13 changes: 11 additions & 2 deletions exaudfclient/base/javacontainer/javacontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@

#include "base/exaudflib/vm/swig_vm.h"
#include <string.h>
#include <memory>

#ifdef ENABLE_JAVA_VM

namespace SWIGVMContainers {

class JavaVMImpl;
class SwigFactory;

namespace JavaScriptOptions {

struct ScriptOptionsParser;

}

class JavaVMach: public SWIGVM {
public:
JavaVMach(bool checkOnly, SwigFactory& swigFactory);
/*
* scriptOptionsParser: JavaVMach takes ownership of ScriptOptionsParser pointer.
*/
JavaVMach(bool checkOnly, std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser);
virtual ~JavaVMach() {}
virtual void shutdown();
virtual bool run();
Expand Down
32 changes: 32 additions & 0 deletions exaudfclient/base/javacontainer/javacontainer_builder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "base/javacontainer/javacontainer_builder.h"
#include "base/javacontainer/script_options/parser_ctpg.h"
#include "base/javacontainer/script_options/parser_legacy.h"
#include "base/swig_factory/swig_factory_impl.h"

#ifdef ENABLE_JAVA_VM

namespace SWIGVMContainers {

JavaContainerBuilder::JavaContainerBuilder()
: m_useCtpgParser(false) {}

JavaContainerBuilder& JavaContainerBuilder::useCtpgParser(const bool useCtpgParser) {
m_useCtpgParser = useCtpgParser;
return *this;
}

JavaVMach* JavaContainerBuilder::build() {
std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> parser;
if (m_useCtpgParser) {
parser = std::make_unique<JavaScriptOptions::ScriptOptionLinesParserCTPG>(std::make_unique<SwigFactoryImpl>());
} else {
parser = std::make_unique<JavaScriptOptions::ScriptOptionLinesParserLegacy>(std::make_unique<SwigFactoryImpl>());
}
return new JavaVMach(false, std::move(parser));
}


} //namespace SWIGVMContainers


#endif //ENABLE_JAVA_VM
35 changes: 35 additions & 0 deletions exaudfclient/base/javacontainer/javacontainer_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef JAVACONTAINER_BUILDER_H
#define JAVACONTAINER_BUILDER_H

#include <memory>
#include "base/javacontainer/javacontainer.h"

#ifdef ENABLE_JAVA_VM

namespace SWIGVMContainers {

namespace JavaScriptOptions {

struct ScriptOptionsParser;

}

class JavaContainerBuilder {
public:
JavaContainerBuilder();

JavaContainerBuilder& useCtpgParser(const bool value);

JavaVMach* build();

private:
bool m_useCtpgParser;
};

} //namespace SWIGVMContainers


#endif //ENABLE_JAVA_VM


#endif //JAVACONTAINER_BUILDER_H
37 changes: 19 additions & 18 deletions exaudfclient/base/javacontainer/javacontainer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include "base/javacontainer/javacontainer.h"
#include "base/javacontainer/javacontainer_impl.h"
#include "base/javacontainer/script_options/extractor.h"
#include "base/javacontainer/script_options/parser_legacy.h"
#include "base/swig_factory/swig_factory.h"
#include "base/javacontainer/script_options/parser.h"


using namespace SWIGVMContainers;
using namespace std;

JavaVMImpl::JavaVMImpl(bool checkOnly, bool noJNI, SwigFactory& swigFactory)
JavaVMImpl::JavaVMImpl(bool checkOnly, bool noJNI,
std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser)
: m_checkOnly(checkOnly)
, m_exaJavaPath("")
, m_localClasspath("/tmp") // **IMPORTANT**: /tmp needs to be in the classpath, otherwise ExaCompiler crashe with com.exasol.ExaCompilationException: /DATE_STRING.java:3: error: error while writing DATE_STRING: could not create parent directories
Expand All @@ -28,26 +28,12 @@ JavaVMImpl::JavaVMImpl(bool checkOnly, bool noJNI, SwigFactory& swigFactory)
, m_jvm(NULL)
, m_env(NULL)
, m_needsCompilation(true)
, m_swigFactory(swigFactory)
{

stringstream ss;
m_exaJavaPath = "/exaudf/base/javacontainer"; // TODO hardcoded path

JavaScriptOptions::ScriptOptionLinesParserLegacy scriptOptionsParser;

JavaScriptOptions::Extractor extractor(scriptOptionsParser, swigFactory);

DBG_FUNC_CALL(cerr,extractor.extract(m_scriptCode)); // To be called before scripts are imported. Otherwise, the script classname from an imported script could be used

DBG_FUNC_CALL(cerr,setClasspath());

m_jvmOptions = std::move(extractor.moveJvmOptions());

for (set<string>::iterator it = extractor.getJarPaths().begin(); it != extractor.getJarPaths().end();
++it) {
addJarToClasspath(*it);
}
parseScriptOptions(std::move(scriptOptionsParser));

m_needsCompilation = checkNeedsCompilation();
if (m_needsCompilation) {
Expand All @@ -64,6 +50,21 @@ JavaVMImpl::JavaVMImpl(bool checkOnly, bool noJNI, SwigFactory& swigFactory)
}
}

void JavaVMImpl::parseScriptOptions(std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser) {
JavaScriptOptions::Extractor extractor(*scriptOptionsParser);

DBG_FUNC_CALL(cerr,extractor.extract(m_scriptCode));

DBG_FUNC_CALL(cerr,setClasspath());

m_jvmOptions = std::move(extractor.moveJvmOptions());

for (set<string>::iterator it = extractor.getJarPaths().begin(); it != extractor.getJarPaths().end();
++it) {
addJarToClasspath(*it);
}
}

void JavaVMImpl::shutdown() {
if (m_checkOnly)
throwException("F-UDF.CL.SL.JAVA-1159: Java VM in check only mode");
Expand Down
13 changes: 11 additions & 2 deletions exaudfclient/base/javacontainer/javacontainer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include <set>
#include <memory>

#include "base/exaudflib/vm/swig_vm.h"
#include <jni.h>
Expand All @@ -14,10 +15,18 @@ class JavaVMTest;

namespace SWIGVMContainers {

namespace JavaScriptOptions {
struct ScriptOptionsParser;
}

class JavaVMImpl {
public:
friend class ::JavaVMTest;
JavaVMImpl(bool checkOnly, bool noJNI, SwigFactory& swigFactory);
/*
* scriptOptionsParser: JavaVMImpl takes ownership of ScriptOptionsParser pointer.
*/
JavaVMImpl(bool checkOnly, bool noJNI,
std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser);
~JavaVMImpl() {}
void shutdown();
bool run();
Expand All @@ -37,6 +46,7 @@ class JavaVMImpl {
void throwException(const std::string& ex);
void setJvmOptions();
void addJarToClasspath(const std::string& path);
void parseScriptOptions(std::unique_ptr<JavaScriptOptions::ScriptOptionsParser> scriptOptionsParser);
bool m_checkOnly;
std::string m_exaJavaPath;
std::string m_localClasspath;
Expand All @@ -48,7 +58,6 @@ class JavaVMImpl {
JavaVM *m_jvm;
JNIEnv *m_env;
bool m_needsCompilation;
SwigFactory& m_swigFactory;
};

} //namespace SWIGVMContainers
Expand Down
Loading
Loading