Skip to content

Commit b17ec61

Browse files
committed
Added jython test framework
1 parent 3afd7b6 commit b17ec61

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: java
2+
script: ./travis.sh
23
deploy:
34
provider: releases
45
api_key:

build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ dependencies {
3131
jython ":delphixpy:1.10.0.0"
3232
}
3333

34+
if (!project.hasProperty('jythonInterpreter')) {
35+
project.ext['jythonInterpreter'] = "jython"
36+
}
37+
38+
sourceSets.main.resources.srcDirs = ["src/main/jython", "src/main/resources"]
39+
sourceSets.test.resources.srcDirs = ["src/test/jython", "src/test/resources"]
40+
41+
42+
task testJython(type: Exec, dependsOn: ['testClasses']) {
43+
environment = ["itest_conf_file": "$projectDir/src/test/jython/itests/itest-conf.json","CLASSPATH": sourceSets.test.runtimeClasspath.asPath, "PATH": System.getenv("PATH"), "HOME": System.getenv("HOME")]
44+
commandLine jythonInterpreter, "-Dpython.path=/opt/xlr/server/plugins/xlr-xld-plugin-7.1.0.jar", "-m", "unittest", "discover", "-s", "./src/test/jython", "-p", "*_test.py", "-v"
45+
workingDir = projectDir
46+
}
47+
48+
test.dependsOn testJython
49+
3450
license {
3551
header rootProject.file('License.md')
3652
strictCheck true

src/test/jython/itests/__init__.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Copyright 2018 XEBIALABS
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
#
6+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
#
8+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
#
10+
11+
12+
import os
13+
import json
14+
15+
16+
class ItestConf(object):
17+
def __init__(self):
18+
file_location = os.getenv('itest_conf_file')
19+
if not file_location:
20+
raise Exception("No environment variable named 'itest_conf_file' set." +
21+
" This variable should point to the file containing connection info.")
22+
23+
with open(file_location) as data_file:
24+
data = json.load(data_file)
25+
self.settings = {o['name']: o for o in data}
26+
27+
def apply_settings(self, name, target, expects_params):
28+
if name not in self.settings:
29+
raise Exception("'%s' is not found in the itest_conf_file" % name)
30+
settings = self.settings[name]
31+
for k, v in settings.items():
32+
target.__dict__[k] = v
33+
for p in expects_params:
34+
if target.__dict__[p] is None:
35+
raise Exception("%s is a required property missing from '%s' in the itest_conf_file" % (p, name))
36+
37+
38+
itest_conf = ItestConf()
39+
40+
41+
class CiStub(object):
42+
def getProperty(self, name):
43+
return self.__dict__[name]
44+
45+
def setProperty(self, name, value):
46+
self.__dict__[name] = value
47+
48+
def __getitem__(self, key):
49+
return self.__dict__[key]
50+
51+
52+
class DelphixServerCi(CiStub):
53+
def __init__(self):
54+
itest_conf.apply_settings("delphix_server", self, ["url"])
55+
self.name = "delphix"
56+
self.id = "Configuration/Custom/%s" % self.name
57+
self.type = "delphix.Server"
58+
self.title = self.name
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[{
2+
"name" : "delphix_server",
3+
"url" : "delphix:8080",
4+
}]

travis.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -ev
3+
4+
docker run --rm -d -p 28080:8080 --name delphix xebialabsunsupported/xl-docker-demo-delphix:latest
5+
./gradlew compileDocker
6+
docker stop delphix

0 commit comments

Comments
 (0)