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

Feature/#63 validate stack configs #64

Merged
merged 5 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to `knotx-stack` will be documented in this file.

## Unreleased
List of changes that are finished but not yet released in any final version.
- [PR-64](https://github.com/Knotx/knotx-stack/pull/64) - Add Unit tests for default stack configuration files.
- [PR-59](https://github.com/Knotx/knotx-stack/pull/59) - Vert.x upgrade to 3.8.1.

## 2.0.0
Expand Down
8 changes: 6 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ steps:
displayName: "Build Docker image"
- script: |
cd knotx-repos/knotx-starter-kit
./gradlew build
displayName: "Build Starter Kit"
./gradlew build-stack
displayName: "Build Starter Kit: ZIP"
- script: |
cd knotx-repos/knotx-starter-kit
./gradlew build-docker
displayName: "Build Starter Kit: Docker"
68 changes: 66 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,77 @@ repositories {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}

apply(from = "gradle/integrationTests.gradle.kts")
sourceSets {
register("functionalTest") {
compileClasspath += sourceSets.test.get().output.classesDirs
runtimeClasspath += sourceSets.test.get().output.classesDirs
}
test {
resources {
srcDir("src/main/packaging/conf")
}
}
}

Comment on lines +38 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

apply(from = "gradle/distribution.gradle.kts")

val functionalTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.named("implementation").get()) }
val functionalTestRuntimeOnly: Configuration by configurations.getting

dependencies {
implementation(platform("io.knotx:knotx-dependencies:${project.version}"))
testImplementation(platform("io.knotx:knotx-dependencies:${project.version}"))

implementation("io.knotx:knotx-launcher:${project.version}")
implementation("io.knotx:knotx-server-http-core:${project.version}")
implementation("io.knotx:knotx-repository-connector-fs:${project.version}")
implementation("io.knotx:knotx-repository-connector-http:${project.version}")
implementation("io.knotx:knotx-fragments-supplier-html-splitter:${project.version}")
implementation("io.knotx:knotx-fragments-supplier-single-fragment:${project.version}")
implementation("io.knotx:knotx-fragments-assembler:${project.version}")
implementation("io.knotx:knotx-fragments-handler-core:${project.version}")
implementation("io.knotx:knotx-action-http:${project.version}")
implementation("io.knotx:knotx-template-engine-core:${project.version}")
implementation("io.knotx:knotx-template-engine-handlebars:${project.version}")
implementation("io.netty:netty-tcnative-boringssl-static")

testImplementation("io.knotx:knotx-junit5:${project.version}")
testImplementation(group = "io.vertx", name = "vertx-junit5")
testImplementation(group = "io.vertx", name = "vertx-unit")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
testImplementation(group = "com.github.tomakehurst", name = "wiremock")
testImplementation(group = "io.rest-assured", name = "rest-assured", version = "3.3.0")

functionalTestImplementation(platform("io.knotx:knotx-dependencies:${project.version}"))
functionalTestImplementation("io.knotx:knotx-junit5:${project.version}")
functionalTestImplementation(group = "io.vertx", name = "vertx-junit5")
functionalTestImplementation(group = "io.vertx", name = "vertx-unit")
functionalTestImplementation("org.junit.jupiter:junit-jupiter-api")
functionalTestRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
functionalTestImplementation(group = "com.github.tomakehurst", name = "wiremock")
}

tasks {
register<Test>("functionalTest") {
description = "Runs functional tests."
group = "verification"

classpath = sourceSets["functionalTest"].runtimeClasspath
testClassesDirs = sourceSets["functionalTest"].output.classesDirs

shouldRunAfter("test")
}

named("check") { dependsOn("functionalTest") }
}

// -----------------------------------------------------------------------------
// License headers validation
// -----------------------------------------------------------------------------
tasks {
named<RatTask>("rat") {
excludes.addAll("*.md", "**/*.md", "**/bin/*", "azure-pipelines.yml", "**/build/*", "**/out/*", "**/*.json", "**/*.conf", "**/*.html", "**/*.properties", ".idea", ".composite-enabled")
excludes.addAll("*.md", "**/*.md", "**/bin/*", "azure-pipelines.yml", "**/build/*", "**/out/*", "**/*.json", "**/*.conf", "**/*.html", "**/*.properties", ".idea", ".composite-enabled", "/logs/**")
}
getByName("build").dependsOn("rat")
}
Expand Down Expand Up @@ -123,3 +185,5 @@ signing {

sign(publishing.publications["knotxDistribution"])
}


19 changes: 3 additions & 16 deletions gradle/distribution.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,9 @@ val stackName = "knotx"
val stackDistribution = "knotx-stack-${version}.zip"

configurations {
register("dist")
}

dependencies {
"dist"("io.knotx:knotx-launcher:${project.version}")
"dist"("io.knotx:knotx-server-http-core:${project.version}")
"dist"("io.knotx:knotx-repository-connector-fs:${project.version}")
"dist"("io.knotx:knotx-repository-connector-http:${project.version}")
"dist"("io.knotx:knotx-fragments-supplier-html-splitter:${project.version}")
"dist"("io.knotx:knotx-fragments-supplier-single-fragment:${project.version}")
"dist"("io.knotx:knotx-fragments-assembler:${project.version}")
"dist"("io.knotx:knotx-fragments-handler-core:${project.version}")
"dist"("io.knotx:knotx-action-http:${project.version}")
"dist"("io.knotx:knotx-template-engine-core:${project.version}")
"dist"("io.knotx:knotx-template-engine-handlebars:${project.version}")
"dist"("io.netty:netty-tcnative-boringssl-static:2.0.17.Final")
create("dist") {
extendsFrom(configurations.named("implementation").get())
}
}

val cleanDistribution = tasks.register<Delete>("cleanDistribution") {
Expand Down
42 changes: 0 additions & 42 deletions gradle/integrationTests.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand All @@ -24,6 +24,7 @@
import io.knotx.junit5.KnotxExtension;
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.Vertx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -23,6 +23,7 @@
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.util.FileReader;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.vertx.core.json.JsonObject;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.Vertx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import com.github.tomakehurst.wiremock.WireMockServer;
import io.knotx.junit5.KnotxApplyConfiguration;
import io.knotx.junit5.KnotxExtension;
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.Vertx;
import org.junit.jupiter.api.DisplayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand All @@ -24,6 +24,7 @@
import io.knotx.junit5.KnotxExtension;
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.Vertx;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -32,6 +33,7 @@
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.ExtendWith;


@ExtendWith(KnotxExtension.class)
@TestInstance(Lifecycle.PER_CLASS)
class LongRunningHttpServiceWithCircuitBreakerIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand All @@ -27,6 +27,7 @@
import io.knotx.junit5.KnotxExtension;
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.MultiMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack.functional;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand All @@ -25,6 +25,7 @@
import io.knotx.junit5.KnotxExtension;
import io.knotx.junit5.RandomPort;
import io.knotx.junit5.wiremock.ClasspathResourcesMockServer;
import io.knotx.stack.KnotxServerTester;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.junit5.VertxTestContext;
import io.vertx.reactivex.core.Vertx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.knotx.stack.it;
package io.knotx.stack;

import static io.knotx.junit5.util.RequestUtil.subscribeToResult_shouldSucceed;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -31,28 +31,28 @@
import io.vertx.reactivex.ext.web.client.WebClient;
import java.util.Map;

final class KnotxServerTester {
public final class KnotxServerTester {

private static final int KNOTX_TESTS_SERVER_PORT_DEFAULT = 8092;
private static final String KNOTX_TESTS_SERVER_ADDRESS_DEFAULT = "localhost";

private final String serverHost;
private final int serverPort;

KnotxServerTester(String serverHost, int serverPort) {
private KnotxServerTester(String serverHost, int serverPort) {
this.serverHost = serverHost;
this.serverPort = serverPort;
}

static KnotxServerTester defaultInstance() {
public static KnotxServerTester defaultInstance() {
return defaultInstance(KNOTX_TESTS_SERVER_PORT_DEFAULT);
}

static KnotxServerTester defaultInstance(int port) {
public static KnotxServerTester defaultInstance(int port) {
return new KnotxServerTester(KNOTX_TESTS_SERVER_ADDRESS_DEFAULT, port);
}

void testPostRequest(VertxTestContext context, Vertx vertx, String url,
public void testPostRequest(VertxTestContext context, Vertx vertx, String url,
Map<String, Object> formData, String expectedResponseFile) {

WebClient client = WebClient.create(vertx);
Expand All @@ -67,7 +67,7 @@ void testPostRequest(VertxTestContext context, Vertx vertx, String url,
});
}

void testGetRequest(VertxTestContext context, Vertx vertx, String url,
public void testGetRequest(VertxTestContext context, Vertx vertx, String url,
String expectedResponseFile) {
testGet(context, vertx, url, resp -> {
assertEquals(HttpResponseStatus.OK.code(), resp.statusCode());
Expand All @@ -76,14 +76,14 @@ void testGetRequest(VertxTestContext context, Vertx vertx, String url,
});
}

void testGetServerError(VertxTestContext context, Vertx vertx, String url,
public void testGetServerError(VertxTestContext context, Vertx vertx, String url,
int expectedError) {
testGet(context, vertx, url, resp -> {
assertEquals(expectedError, resp.statusCode());
});
}

void testGet(VertxTestContext context, Vertx vertx, String url,
public void testGet(VertxTestContext context, Vertx vertx, String url,
Consumer<HttpResponse<Buffer>> assertions) {
WebClient client = WebClient.create(vertx);
Single<HttpResponse<Buffer>> httpResponseSingle = client
Expand Down
Loading