Skip to content

Commit

Permalink
Merge pull request #122 from zuliaio/test-framework
Browse files Browse the repository at this point in the history
Test framework
  • Loading branch information
mdavis95 authored Apr 18, 2024
2 parents 6d8f4f4 + cfc5b50 commit ccfe192
Show file tree
Hide file tree
Showing 69 changed files with 1,854 additions and 270 deletions.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ annontations = { module = "org.jetbrains:annotations", version = "24.0.0" }
awssdk-s3 = { module = "software.amazon.awssdk:s3" }
bson = { module = "org.mongodb:bson", version.ref = "mongodb" }
caffeine = { module = "com.github.ben-manes.caffeine:caffeine" }
commons-compress = { module = "org.apache.commons:commons-compress", version = "1.25.0" }
commons-compress = { module = "org.apache.commons:commons-compress", version = "1.26.1" }
commons-pool2 = { module = "org.apache.commons:commons-pool2", version = "2.11.1" }
flapdoodle-mongo = { module = "de.flapdoodle.embed:de.flapdoodle.embed.mongo", version = "4.11.1" }
flapdoodle-mongo = { module = "de.flapdoodle.embed:de.flapdoodle.embed.mongo", version = "4.12.2" }
guava = { module = "com.google.guava:guava", version = "32.1.3-jre" }
grpc-netty-shaded = { module = "io.grpc:grpc-netty-shaded", version.ref = "grpc" }
grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" }
grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" }
#graalvm-js = {module = "org.graalvm.js:js", version = "23.0.3"}
graalvm-js = { module = "org.graalvm.js:js", version = "23.0.3" }
gson = { module = "com.google.code.gson:gson", version = "2.10.1" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.16.1" }
jakarta-validation = { module = "jakarta.validation:jakarta.validation-api" }
jansi = { module = "org.fusesource.jansi:jansi", version = "2.4.0" }
jansi = { module = "org.fusesource.jansi:jansi", version = "2.4.1" }
javax-annotation = { module = "javax.annotation:javax.annotation-api", version = "1.3.2" }
json-io = { module = "com.cedarsoftware:json-io", version = "4.19.1" }
junit-bom = { module = "org.junit:junit-bom", version = "5.10.1" }
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProject.name = "ZuliaSearch"

include 'zulia-analyzer', 'zulia-common', 'zulia-client', 'zulia-data', 'zulia-query-parser', 'zulia-server', 'zulia-util'
include 'zulia-analyzer', 'zulia-common', 'zulia-cmd-shared', 'zulia-client', 'zulia-data', 'zulia-query-parser', 'zulia-server', 'zulia-testing', 'zulia-tools', 'zulia-util'

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
2 changes: 1 addition & 1 deletion zulia-analyzer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ val luceneVersion: String by project
defaultTasks("build", "installDist")

dependencies {
api(project(":zulia-common"))
api(projects.zuliaCommon)
api(libs.lucene.analysis.common)
}

Expand Down
4 changes: 2 additions & 2 deletions zulia-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ val okHttpVersion: String by project
val gsonVersion: String by project

dependencies {
api(project(":zulia-common"))
api(project(":zulia-util"))
api(projects.zuliaCommon)
api(projects.zuliaUtil)
implementation(libs.unirest.java.bom)
implementation(libs.unirest.core)
implementation(libs.unirest.gson)
Expand Down
13 changes: 13 additions & 0 deletions zulia-cmd-shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
`java-library`
}

description = "Zulia CMD Shared"

dependencies {
annotationProcessor(libs.picocli.codegen)
api(projects.zuliaCommon)
implementation(libs.picocli.base)
}


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.zulia.server.cmd.common;
package io.zulia.cmd.common;

import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.zulia.server.cmd.common;
package io.zulia.cmd.common;

import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.zulia.server.cmd;
package io.zulia.cmd.common;

import io.zulia.server.cmd.common.SelectiveStackTraceHandler;
import picocli.CommandLine;
import picocli.CommandLine.Help.Ansi.Style;
import picocli.CommandLine.Help.ColorScheme;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.zulia.server.cmd.common;
package io.zulia.cmd.common;

import io.zulia.util.ZuliaVersion;
import picocli.CommandLine;
Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions zulia-cmd-shared/src/test/resources/sample_testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
connections:
testConnection:
serverAddress: 192.168.1.30
port: 32191
indexes:
publications:
indexName: publications
connection: testConnection
queries:
pubsStar:
index: publications
query: "*:*"
pubsWithoutTitle:
index: publications
query: "-title:*"
pubsTest:
index: publications
query: "title:*"
amount: 1
facets:
- field: pubYear
topN: 10
- field: journalName
topN: 10
statFacets:
- facetField: pubYear
numericField: rcr
topN: 10
tests:
pubsCount:
expr: pubsStar.count > 200000
pubsWithTitleCount:
expr: pubsWithoutTitle.count < pubsStar.count * 0.01
test1:
expr: pubsTest.count > 1
test2:
expr: pubsTest.doc[0]["authors"][0]["lastName"] == "Abumere"
test3:
expr: pubsTest.facet["pubYear"][0].label == "2022" && pubsTest.facet["pubYear"][0].count > 1000000



2 changes: 1 addition & 1 deletion zulia-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {

protobuf(libs.sketches.java)

api(project(":zulia-util"))
api(projects.zuliaUtil)
}


Expand Down
2 changes: 1 addition & 1 deletion zulia-data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
api(libs.bundles.poi)
api(libs.univocity.parsers)
api(libs.jackson.databind)
api(project(":zulia-util"))
api(projects.zuliaUtil)
}


2 changes: 1 addition & 1 deletion zulia-query-parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ val luceneVersion: String by project
defaultTasks("build", "installDist")

dependencies {
api(project(":zulia-analyzer"))
api(projects.zuliaAnalyzer)
api(libs.lucene.queryparser)
}

Expand Down
172 changes: 7 additions & 165 deletions zulia-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ tasks.withType<Test> {
}

dependencies {
implementation(project(":zulia-client")) //needed for admin tools
implementation(project(":zulia-query-parser"))
implementation(projects.zuliaQueryParser)
implementation(projects.zuliaCmdShared)
annotationProcessor(libs.micronaut.http.validation)
annotationProcessor(libs.micronaut.openapi)
annotationProcessor(libs.micronaut.serde.processor)
Expand Down Expand Up @@ -73,214 +73,56 @@ dependencies {
testImplementation(libs.flapdoodle.mongo)
testImplementation(libs.micronaut.http.client)
testImplementation(libs.micronaut.test.junit5)
testImplementation(project(":zulia-client"))
}
tasks.withType<JavaCompile> {
options.isFork = true
options.forkOptions.jvmArgs?.addAll(listOf("-Dmicronaut.openapi.views.spec=swagger-ui.enabled=true,swagger-ui.theme=flattop"))
}

val zuliaScriptTask = tasks.getByName<CreateStartScripts>("startScripts")


zuliaScriptTask.applicationName = "zulia"
zuliaScriptTask.mainClass.set("io.zulia.server.cmd.Zulia")
val zuliaAdminScriptTask = tasks.register<CreateStartScripts>("createZuliaAdminScript") {
applicationName = "zuliaadmin"
mainClass.set("io.zulia.server.cmd.ZuliaAdmin")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

val zuliaDScriptTask = tasks.register<CreateStartScripts>("createZuliaDScript") {
val zuliaScriptTask = tasks.getByName<CreateStartScripts>("startScripts") {
applicationName = "zuliad"
mainClass.set("io.zulia.server.cmd.ZuliaD")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
val newText = text.replace("exec ", "export APP_HOME\nexec ")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

val zuliaDumpScriptTask = tasks.register<CreateStartScripts>("createZuliaDumpScript") {
applicationName = "zuliadump"
mainClass.set("io.zulia.server.cmd.ZuliaDump")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

val zuliaRestoreScriptTask = tasks.register<CreateStartScripts>("createZuliaRestoreScript") {
applicationName = "zuliarestore"
mainClass.set("io.zulia.server.cmd.ZuliaRestore")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

val zuliaExportScriptTask = tasks.register<CreateStartScripts>("createZuliaExportScript") {
applicationName = "zuliaexport"
mainClass.set("io.zulia.server.cmd.ZuliaExport")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

val zuliaImportScriptTask = tasks.register<CreateStartScripts>("createZuliaImportScript") {
applicationName = "zuliaimport"
mainClass.set("io.zulia.server.cmd.ZuliaImport")
outputDir = zuliaScriptTask.outputDir
classpath = zuliaScriptTask.classpath

doLast {
val unixScriptFile = file(unixScript)
val text = unixScriptFile.readText(Charsets.UTF_8)
val newText = text.replace("APP_HOME=\"`pwd -P`\"", "export APP_HOME=\"`pwd -P`\"")
unixScriptFile.writeText(newText, Charsets.UTF_8)
}
}

tasks.register("autocompleteDir") {
doLast {
mkdir("${layout.buildDirectory.get()}/autocomplete")
}
}

task("picoCliZuliaAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf("--force", "--completionScript", "${layout.buildDirectory.get()}/autocomplete/zulia.sh", "io.zulia.server.cmd.Zulia")
}

task("picoCliZuliaDAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf("--force", "--completionScript", "${layout.buildDirectory.get()}/autocomplete/zuliad.sh", "io.zulia.server.cmd.ZuliaD")
}

task("picoCliZuliaAdminAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf(
"--force",
"--completionScript",
"${layout.buildDirectory.get()}/autocomplete/zuliaadmin.sh",
"io.zulia.server.cmd.ZuliaAdmin"
"${layout.buildDirectory.get()}/autocomplete/zuliad.sh",
"io.zulia.server.cmd.ZuliaD"
)
}

task("picoCliZuliaDumpAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args =
listOf("--force", "--completionScript", "${layout.buildDirectory.get()}/autocomplete/zuliadump.sh", "io.zulia.server.cmd.ZuliaDump")
}



task("picoCliZuliaRestoreAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf(
"--force",
"--completionScript",
"${layout.buildDirectory.get()}/autocomplete/zuliarestore.sh",
"io.zulia.server.cmd.ZuliaRestore"
)
}


task("picoCliZuliaImportAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf(
"--force",
"--completionScript",
"${layout.buildDirectory.get()}/autocomplete/zuliaimport.sh",
"io.zulia.server.cmd.ZuliaImport"
)
}

task("picoCliZuliaExportAutoComplete", JavaExec::class) {
dependsOn("autocompleteDir")
mainClass.set("picocli.AutoComplete")
classpath = sourceSets["main"].runtimeClasspath
args = listOf(
"--force",
"--completionScript",
"${layout.buildDirectory.get()}/autocomplete/zuliaexport.sh",
"io.zulia.server.cmd.ZuliaExport"
)
}

tasks.withType<AbstractArchiveTask> {
dependsOn(
"picoCliZuliaAutoComplete",
"picoCliZuliaDAutoComplete",
"picoCliZuliaAdminAutoComplete",
"picoCliZuliaDumpAutoComplete",
"picoCliZuliaRestoreAutoComplete",
"picoCliZuliaImportAutoComplete",
"picoCliZuliaExportAutoComplete"
)
}


distributions {
main {
contents {
from(zuliaAdminScriptTask) {
into("bin")
}
from(zuliaDScriptTask) {
into("bin")
}
from(zuliaDumpScriptTask) {
into("bin")
}
from(zuliaRestoreScriptTask) {
into("bin")
}
from(zuliaExportScriptTask) {
into("bin")
}
from(zuliaImportScriptTask) {
into("bin")
}
from("${layout.buildDirectory.get()}/autocomplete/") {
into("bin/autocomplete")
}
Expand Down
Loading

0 comments on commit ccfe192

Please sign in to comment.