Skip to content

Commit

Permalink
Merge pull request cdapio#243 from Vipinofficial11/bqmt
Browse files Browse the repository at this point in the history
Update run_e2e_test.py to upload required drivers for non-module based repositories.
  • Loading branch information
GnsP authored Jan 16, 2024
2 parents 5ce1478 + 41cbf3f commit f45aac1
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/scripts/run_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import argparse
import urllib.request
import yaml
import re


def run_shell_command(cmd):
process = subprocess.run(cmd.split(" "), stderr=subprocess.PIPE)
Expand Down Expand Up @@ -95,6 +97,7 @@ def run_shell_command(cmd):
run_shell_command("mvn clean package -DskipTests")

# Get plugin artifact name and version from pom.xml.
plugin_name = ""
root = ET.parse('pom.xml').getroot()
plugin_version = root.find('{http://maven.apache.org/POM/4.0.0}version').text
if module_to_build:
Expand Down Expand Up @@ -124,8 +127,7 @@ def run_shell_command(cmd):
res=requests.put(f"http://localhost:11015/v3/namespaces/default/artifacts/{plugin_name}/versions/{plugin_version}/properties", json=plugin_properties)
assert res.ok or print(res.text)

if module_to_build:
os.chdir("../../..")
def upload_drivers(module_to_build):
driver_details_file = open(os.path.join('e2e', 'src', 'main', 'scripts', 'driver_details.yaml'))
driver_details = yaml.load(driver_details_file, Loader=yaml.FullLoader)
if module_to_build in driver_details['modules']:
Expand All @@ -137,11 +139,29 @@ def run_shell_command(cmd):
assert get_driver_jar.ok or print(get_driver_jar.text)
driverData = get_driver_jar.content
print(f"Installing {artifact_name} driver")
res=requests.post(f"http://localhost:11015/v3/namespaces/default/artifacts/{artifact_name}", headers={"Content-Type": "application/octet-stream", "Artifact-Version": artifact_version, "Artifact-Plugins": driver_prop }, data=driverData)
res=requests.post(f"http://localhost:11015/v3/namespaces/default/artifacts/{artifact_name}", headers={"Content-Type": "application/octet-stream", "Artifact-Version": artifact_version, "Artifact-Plugins": driver_prop}, data=driverData)
assert res.ok or print(res.text)

if module_to_build:
os.chdir("../../..")
upload_drivers(module_to_build)
else:
os.chdir("../..")

# Uploading MySQL Driver while building BQMT-Plugin in Google Cloud repo.
# Checking if the submodule to build is BigQuery Multi Table, only then driver should be downloaded.
if plugin_name == 'google-cloud':
input_string = args.testRunner
pattern = r'bigquerymultitable'
submodule = re.search(pattern, input_string)
desired_module = ''
if submodule:
desired_module = submodule.group(0)
if desired_module == 'bigquerymultitable':
os.chdir("../../..")
print("Uploading MySql Driver..")
upload_drivers('mysql-plugin')

print("cwd:", os.getcwd())
print("ls:", os.listdir())

Expand Down

0 comments on commit f45aac1

Please sign in to comment.