-
Notifications
You must be signed in to change notification settings - Fork 8
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
Enriching export #16
base: master
Are you sure you want to change the base?
Enriching export #16
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.linked.project.id="gradle-test-export-plugin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.ullink.gradle" external.system.module.version="0.2" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build" /> | ||
<excludeFolder url="file://$MODULE_DIR$/out" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,7 @@ import org.gradle.api.tasks.Optional | |
import org.gradle.api.tasks.testing.Test | ||
import org.gradle.api.tasks.testing.TestResult | ||
|
||
import java.nio.file.Paths | ||
import java.security.MessageDigest | ||
import java.text.SimpleDateFormat | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
|
@@ -51,6 +49,10 @@ class TestExportTask extends Exec { | |
@Optional | ||
def enrichment | ||
|
||
@Input | ||
@Optional | ||
def featureExport | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add another task instead of export using a closure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As in a new FeatureExportTask class inside the project that just prompts the ullink plugin to export the feature? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a new task depends on this task, exporting the feature is ok |
||
|
||
@Input | ||
@Optional | ||
def type = "testcase" | ||
|
@@ -63,21 +65,25 @@ class TestExportTask extends Exec { | |
@Optional | ||
String indexTimestampPattern = "yyyy-MM" | ||
|
||
@Input | ||
@Optional | ||
String buildTime = LocalDateTime.now().toString() | ||
|
||
@Internal | ||
BulkProcessor processor | ||
@Internal | ||
TransportClient client | ||
|
||
def overrideDefaultProperties(Properties properties) { | ||
if (getHost() != null) { | ||
log.error "setting host " + getHost() | ||
properties.setProperty('host', getHost()) | ||
static def overrideDefaultProperties(TestExportTask task, Properties properties) { | ||
if (task.host != null) { | ||
log.info "setting host ${task.host}" + | ||
properties.setProperty('host', task.host) | ||
} | ||
if (getClusterName() != null) { | ||
properties.setProperty('clusterName', getClusterName()) | ||
if (task.clusterName != null) { | ||
properties.setProperty('clusterName', task.clusterName) | ||
} | ||
if (getPort() != null) { | ||
properties.setProperty('port', getPort()) | ||
if (task.port != null) { | ||
properties.setProperty('port', task.port) | ||
} | ||
|
||
return properties | ||
|
@@ -86,7 +92,7 @@ class TestExportTask extends Exec { | |
@Override | ||
void exec() { | ||
ElasticSearchProcessor elasticSearchProcessor = new ElasticSearchProcessor() | ||
Properties parameters = overrideDefaultProperties(elasticSearchProcessor.getParameters()) | ||
Properties parameters = overrideDefaultProperties(this, elasticSearchProcessor.getParameters()) | ||
|
||
def bulkProcessorListener = elasticSearchProcessor.buildBulkProcessorListener() | ||
client = elasticSearchProcessor.buildTransportClient(parameters) | ||
|
@@ -114,7 +120,7 @@ class TestExportTask extends Exec { | |
def list = parseTestFiles(files) | ||
list.each { | ||
def output = JsonOutput.toJson(it) | ||
output= new JsonSlurper().parseText(output) | ||
output = new JsonSlurper().parseText(output) | ||
assert output instanceof Map | ||
output.remove("timestamp") | ||
|
||
|
@@ -143,17 +149,9 @@ class TestExportTask extends Exec { | |
} | ||
} | ||
|
||
def InputJSONFile = getEnrichment().featureJsonParser('getFeatureJsonFile') | ||
def InputJSON = getEnrichment().featureJsonParser('getFeatureJsonParseText') | ||
|
||
def indexFeature = "feature-" + indexPrefix + new SimpleDateFormat(indexTimestampPattern).format(InputJSONFile.lastModified()) | ||
String typeFinal = "feature" | ||
|
||
for (object in InputJSON) { | ||
String id = sha1Hashed(object.toString()) | ||
IndexRequest indexObjFeature = new IndexRequest(indexFeature, typeFinal, id) | ||
object.productName= getProperties().product.name | ||
processor.add(indexObjFeature.source(object, XContentType.JSON)) | ||
if (featureExport) { | ||
featureExport.exportFeature(this) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part should not be done in here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the internal one |
||
|
||
processor.close() | ||
|
@@ -170,26 +168,26 @@ class TestExportTask extends Exec { | |
files.each { | ||
def xmlDoc = new XmlSlurper().parse(it) | ||
def fileName = (xmlDoc.@name) | ||
String timestamp = xmlDoc.@timestamp | ||
def solutions = getEnrichment().testCaseJsonParser(fileName) | ||
|
||
def filePath = Paths.get("src", "test", "groovy", fileName.toString().replace(".", File.separator) + ".groovy") | ||
|
||
xmlDoc.children().each { | ||
if (it.name() == "testcase") { | ||
Result result = parseTestCase(it,solutions) | ||
result.timestamp = timestamp | ||
result.filePath = filePath | ||
Result result = parseTestCase(it) | ||
|
||
if (enrichment) { | ||
result = enrichment.enrichJson(result, it, fileName) | ||
} | ||
|
||
list << result | ||
} | ||
} | ||
} | ||
list | ||
} | ||
|
||
def parseTestCase(def p, def solution) { | ||
String testname = p.@name | ||
Result result = new Result(name: testname) | ||
def parseTestCase(def p) { | ||
String testName = p.@name | ||
Result result = new Result(name: testName) | ||
result.timestamp = buildTime | ||
def time = Float.parseFloat([email protected]()) * 1000 | ||
result.with { | ||
classname = p.@classname | ||
|
@@ -209,10 +207,8 @@ class TestExportTask extends Exec { | |
result.resultType = TestResult.ResultType.SKIPPED | ||
} | ||
} | ||
result.feature = getEnrichment().resolveFeature(p, solution) | ||
result.steps = getEnrichment().resolveSteps(p,solution) | ||
result.properties = resolveProperties(p) | ||
result.projectName= project.getName() | ||
result.projectName = project.getName() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, it should be done in enrichment |
||
result | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't have to commit this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted