Skip to content

Commit

Permalink
[CI] Fix BuildParameterExtensionSpec (#119239)
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby authored Dec 27, 2024
1 parent 3a07b77 commit 3439f1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package org.elasticsearch.gradle.internal.info

import spock.lang.Ignore

import spock.lang.Specification

import org.gradle.api.JavaVersion
Expand All @@ -19,9 +19,7 @@ import org.gradle.api.provider.ProviderFactory
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Assert

import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
import java.util.concurrent.Future
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger

Expand All @@ -31,35 +29,18 @@ class BuildParameterExtensionSpec extends Specification {

ProjectBuilder projectBuilder = new ProjectBuilder()

@Ignore
def "#getterName is cached anc concurrently accessible"() {
given:
def project = projectBuilder.build()
def providers = project.getProviders();
def buildParams = extension(project, providers)
int numberOfThreads = 10;
when:
var service = Executors.newFixedThreadPool(numberOfThreads)
var latch = new CountDownLatch(numberOfThreads)
def testedProvider = buildParams."$getterName"()
def futures = (1..numberOfThreads).collect {
service.submit(
() -> {
try {
testedProvider.get()
} catch (AssertionError e) {
latch.countDown()
Assert.fail("Accessing cached provider more than once")
}
latch.countDown()
}
)
}
latch.await(10, TimeUnit.SECONDS)

then:
testedProvider.get()
testedProvider.get()

futures.any { it.isCancelled() || it.isDone() == false } == false
where:
getterName << [
"getRuntimeJavaHome",
Expand Down Expand Up @@ -99,10 +80,10 @@ class BuildParameterExtensionSpec extends Specification {

private Provider providerMock() {
Provider provider = Mock(Provider)
AtomicInteger counter = new AtomicInteger(0)
AtomicInteger counter = new AtomicInteger(1)
provider.getOrNull() >> {
println "accessing provider"
return counter.get() == 1 ? fail("Accessing cached provider more than once") : counter.incrementAndGet()
println "accessing provider #${counter.get()}"
return counter.get() == 2 ? fail("Accessing cached provider more than once") : counter.incrementAndGet()
}
provider.get() >> {
fail("Accessing cached provider directly")
Expand Down
9 changes: 0 additions & 9 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,9 @@ tests:
issue: https://github.com/elastic/elasticsearch/issues/117937
- class: org.elasticsearch.xpack.security.authc.kerberos.KerberosAuthenticationIT
issue: https://github.com/elastic/elasticsearch/issues/118414
- class: org.elasticsearch.gradle.internal.info.BuildParameterExtensionSpec
method: getJavaToolChainSpec is cached anc concurrently accessible
issue: https://github.com/elastic/elasticsearch/issues/119173
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
method: test {p0=synonyms/90_synonyms_reloading_for_synset/Reload analyzers for specific synonym set}
issue: https://github.com/elastic/elasticsearch/issues/116777
- class: org.elasticsearch.gradle.internal.info.BuildParameterExtensionSpec
method: getRuntimeJavaDetails is cached anc concurrently accessible
issue: https://github.com/elastic/elasticsearch/issues/119234
- class: org.elasticsearch.gradle.internal.info.BuildParameterExtensionSpec
method: getBwcVersionsProvider is cached anc concurrently accessible
issue: https://github.com/elastic/elasticsearch/issues/119172
- class: org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest
method: "builds distribution from branches via archives extractedAssemble [bwcDistVersion: 8.1.3, bwcProject: bugfix2, expectedAssembleTaskName:
extractedAssemble, #3]"
Expand Down

0 comments on commit 3439f1d

Please sign in to comment.