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

[Extensions] Enable Integration Tests for AD Extension #913

Draft
wants to merge 28 commits into
base: feature/extensions
Choose a base branch
from

Conversation

joshpalis
Copy link
Member

@joshpalis joshpalis commented May 26, 2023

Description

  1. Modifies the build.gradle of AD Extension to spin up an integration test cluster with OpenSearch, Job Scheduler and Anomaly Detector Extension (the OpenSearch distribution used for integration test clusters randomizes the http port of the OpenSearch node. Update SDKRestClient/OpenSearchAsync client with http.port setting from OpenSearch during intialization opensearch-sdk-java#788 has been merged in to enable the dynamic updating of all sdk client http hosts after extension initialization)
  2. Modifies helper classes for REST integration tests
  3. Disables BWC tests
  4. Introduces a new test case class to provide an SDKClient/RestClient for use in integration test clusters

To run integration tests, a new task named anomalyDetection has been created in place of the run task (See opensearch-project/opensearch-sdk-java#789 for more context).

  • to run Anomaly Detector : ./gradlew anomalyDetection
  • to run integration tests : ./gradlew integTest

Issues Resolved

Part of opensearch-project/opensearch-sdk-java#724

Active WIP

All REST integration tests use an SDKRestClient to invoke all the exposed REST APIs of AD Extension. The tests then validate the behavior of each API by checking the response string/ exception type. Though the requests successfully invokes the corresponding transport actions, the request times out before a response is received by the caller. See the below logs for an example :

dev-dsk-jpalis-2c-27c8aa11 % ./gradlew ':integTest' --tests "org.opensearch.ad.rest.AnomalyDetectorRestApiIT.testCreateAnomalyDetector"                                                                              
=======================================
OpenSearch Build Hamster says Hello!
  Gradle Version        : 8.1.1
  OS Info               : Linux 5.4.242-162.348.amzn2int.x86_64 (amd64)
  JDK Version           : 17 (OpenJDK)
  JAVA_HOME             : /opt/jdk-17
  Random Testing Seed   : B4358DC928E0BE79
  In FIPS 140 mode      : false
=======================================

> Task :compileTestJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /local/home/jpalis/repos/integ/anomaly-detection/src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :startTestExtension
Starting a Gradle Daemon, 1 busy and 3 incompatible and 10 stopped Daemons could not be reused, use --status for details
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation

> Task :integTest

REPRODUCE WITH: ./gradlew ':integTest' --tests "org.opensearch.ad.rest.AnomalyDetectorRestApiIT.testCreateAnomalyDetector" -Dtests.seed=B4358DC928E0BE79 -Dtests.security.manager=false -Dtests.locale=pl-PL -Dtests.timezone=Singapore -Druntime.java=17

org.opensearch.ad.rest.AnomalyDetectorRestApiIT > testCreateAnomalyDetector FAILED
    org.opensearch.client.ResponseException: method [POST], host [http://[::1]:46289], URI [/_extensions/_ad-extension/detectors], status line [HTTP/1.1 408 Request Timeout]
    No response from extension to request.
        at __randomizedtesting.SeedInfo.seed([B4358DC928E0BE79:E58B5BBE98C1E8F1]:0)
        at app//org.opensearch.client.RestClient.convertResponse(RestClient.java:384)
        at app//org.opensearch.client.RestClient.performRequest(RestClient.java:354)
        at app//org.opensearch.client.RestClient.performRequest(RestClient.java:329)
        at app//org.opensearch.sdk.SDKClient$SDKRestClient.performRequest(SDKClient.java:557)
        at app//org.opensearch.ad.TestHelpers.makeRequest(TestHelpers.java:221)
        at app//org.opensearch.ad.TestHelpers.makeRequest(TestHelpers.java:194)
        at app//org.opensearch.ad.rest.AnomalyDetectorRestApiIT.testCreateAnomalyDetector(AnomalyDetectorRestApiIT.java:168)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ion test cluster set up and integration test execution

Signed-off-by: Joshua Palis <[email protected]>
…SDK equivalents, commenting out BWC tests for now

Signed-off-by: Joshua Palis <[email protected]>
…penSearchRestTestCase, refactored SDKRestClient intialization, renamed sdkClient() as sdkRestClient()

Signed-off-by: Joshua Palis <[email protected]>
… configure new SDKClient with for use in integration testing, removed test for AD Plugin enabled

Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Merging #913 (c768223) into feature/extensions (75a0e81) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@                  Coverage Diff                  @@
##             feature/extensions     #913   +/-   ##
=====================================================
  Coverage                 42.86%   42.86%           
  Complexity                 2420     2420           
=====================================================
  Files                       301      301           
  Lines                     18168    18168           
  Branches                   1873     1873           
=====================================================
+ Hits                       7787     7788    +1     
+ Misses                     9806     9805    -1     
  Partials                    575      575           
Flag Coverage Δ
plugin 42.86% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...va/org/opensearch/ad/AnomalyDetectorJobRunner.java 0.00% <ø> (ø)

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant