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

Update the lib to 6.5.0 and add gradle-check-flaky-test-issue-creation.jenkinsfile. #4777

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

prudhvigodithi
Copy link
Member

@prudhvigodithi prudhvigodithi commented Jun 13, 2024

Description

Issues Resolved

Part of opensearch-project/OpenSearch#13950 and opensearch-project/opensearch-build-libraries#441

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.

@prudhvigodithi
Copy link
Member Author

@prudhvigodithi prudhvigodithi marked this pull request as ready for review June 13, 2024 20:34
stage('Detect Gradle Check Flaky Tests') {
steps {
script {
gradleCheckFlakyTestChecker()
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to add tests for this jenkinsFile specifically?

Copy link
Member Author

Choose a reason for hiding this comment

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

With this limitation currently its not possible opensearch-project/opensearch-build-libraries#436 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

So even the regression txt file wont be generated?

Copy link
Member Author

Choose a reason for hiding this comment

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

It wont Sayali initially I have tried it, but the line it reaches gradleCheckFlakyTestChecker it starts failing for this line here https://github.com/opensearch-project/opensearch-build-libraries/blob/main/src/gradlecheck/FetchPostMergeFailedTestClass.groovy#L77 as it's not able to find the class OpenSearchMetricsQuery.

Copy link
Member Author

@prudhvigodithi prudhvigodithi Jun 13, 2024

Choose a reason for hiding this comment

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

Tried the following way but fails at OpenSearchMetricsQuery, its not able to mock external classes part of the used library.

/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
import org.yaml.snakeyaml.Yaml
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertThrows

class TestGradleCheckFlakyTestIssueCreation extends BuildPipelineTest { 
    def mockedResponseHere = '''
    {
        "aggregations": {
            "test_class_keyword_agg": {
                "buckets": [
                    {
                        "key": "TestClass1",
                        "doc_count": 10
                    },
                    {
                        "key": "TestClass2",
                        "doc_count": 5
                    }
                ]
            }
        }
    }
    '''

    @Override
    @Before
    void setUp() {
        helper.registerSharedLibrary(
            library().name('jenkins')
                .defaultVersion('main')
                .allowOverride(true)
                .implicit(true)
                .targetPath('vars')
                .retriever(gitSource('https://github.com/prudhvigodithi/opensearch-build-libraries.git'))
                .build()
        )

        super.setUp()
        addParam('METRICS_HOST_ACCOUNT', '1.0.0')
        helper.registerAllowedMethod('withAWS', [Map, Closure], null)

        def openSearchMetricsQueryMock = new OpenSearchMetricsQuery('', '', '', '', null)
        openSearchMetricsQueryMock.metaClass.fetchMetrics = { String query ->
            return new groovy.json.JsonSlurper().parseText(mockedResponseHere)
        }
    }

    @Test
    void jenkinsFileExecution() {
        super.testPipeline('jenkins/gradle/gradle-check-flaky-test-issue-creation.jenkinsfile',
                'tests/jenkins/jenkinsjob-regression-files/promotion/gradle-check-flaky-test-issue-creation.jenkinsfile')
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

Weird! @dblock Maybe you have some idea here?

@gaiksaya
Copy link
Member

Looks like groovy tests are still failing. Can you please fix them before merging?

@prudhvigodithi
Copy link
Member Author

Looks like groovy tests are still failing. Can you please fix them before merging?

Sure Sayali will take care of it.

@prudhvigodithi prudhvigodithi merged commit 32af732 into opensearch-project:main Jun 13, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants