dependencies {
    implementation project(':envoy-control-runner')

    implementation group: 'org.assertj', name: 'assertj-core'
    implementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
    implementation group: 'org.junit.jupiter', name: 'junit-jupiter-params'
    implementation group: 'org.awaitility', name: 'awaitility'
    implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp

    implementation group: 'org.apache.httpcomponents.core5', name: 'httpcore5'
    implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5'

    implementation group: 'eu.rekawek.toxiproxy', name: 'toxiproxy-java', version: versions.toxiproxy
    runtimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine'
    implementation group: 'org.testcontainers', name: 'junit-jupiter'
    implementation group: 'org.testcontainers', name: 'testcontainers'
}

test {
    useJUnitPlatform {
        excludeTags ('reliability', 'flaky')
    }
    maxParallelForks = 1
    testClassesDirs = project.sourceSets.main.output.classesDirs
}

task reliabilityTest(type: Test) {
    systemProperty 'RELIABILITY_FAILURE_DURATION_SECONDS', System.getProperty('RELIABILITY_FAILURE_DURATION_SECONDS', '300')
    useJUnitPlatform {
        includeTags 'reliability'
    }

    testLogging {
        events "passed", "skipped", "failed"
        exceptionFormat = 'full'
    }
    testClassesDirs = project.sourceSets.main.output.classesDirs
}

task flakyTest(type: Test) {
    useJUnitPlatform {
        includeTags 'flaky'
    }

    testLogging {
        events "passed", "skipped", "failed"
        exceptionFormat = 'full'
    }
    testClassesDirs = project.sourceSets.main.output.classesDirs
}

tasks.withType(Test).configureEach {
    project.findProperty("envoyVersion")?.with { systemProperty("pl.allegro.tech.servicemesh.envoyVersion", it) }
}
