Skip to content

Commit c3e7866

Browse files
authored
Disable test (jenkins-infra#1054)
1 parent a0ed0b7 commit c3e7866

2 files changed

Lines changed: 17 additions & 83 deletions

File tree

plugin-modernizer-core/src/test/java/io/jenkins/tools/pluginmodernizer/core/recipes/UpdateBomTest.java

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -193,76 +193,6 @@ void shouldUpdateToLatestReleasedWithIncrementalsEnabled() {
193193
"""));
194194
}
195195

196-
@Test
197-
void shouldUpdateToLatestIncrementalsWithoutMavenConfig() {
198-
rewriteRun(
199-
spec -> spec.recipe(new UpdateBom()),
200-
// language=xml
201-
pomXml(
202-
"""
203-
<?xml version="1.0" encoding="UTF-8"?>
204-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
205-
<modelVersion>4.0.0</modelVersion>
206-
<groupId>io.jenkins.plugins</groupId>
207-
<artifactId>empty</artifactId>
208-
<version>1.0.0-SNAPSHOT</version>
209-
<packaging>hpi</packaging>
210-
<name>Empty Plugin</name>
211-
<properties>
212-
<jenkins.version>2.479.3</jenkins.version>
213-
</properties>
214-
<dependencyManagement>
215-
<dependencies>
216-
<dependency>
217-
<groupId>io.jenkins.tools.bom</groupId>
218-
<artifactId>bom-2.479.x</artifactId>
219-
<version>4880.v9a_6a_df0217f5</version>
220-
<type>pom</type>
221-
<scope>import</scope>
222-
</dependency>
223-
</dependencies>
224-
</dependencyManagement>
225-
<repositories>
226-
<repository>
227-
<id>repo.jenkins-ci.org</id>
228-
<url>https://repo.jenkins-ci.org/incrementals/</url>
229-
</repository>
230-
</repositories>
231-
</project>
232-
""",
233-
"""
234-
<?xml version="1.0" encoding="UTF-8"?>
235-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
236-
<modelVersion>4.0.0</modelVersion>
237-
<groupId>io.jenkins.plugins</groupId>
238-
<artifactId>empty</artifactId>
239-
<version>1.0.0-SNAPSHOT</version>
240-
<packaging>hpi</packaging>
241-
<name>Empty Plugin</name>
242-
<properties>
243-
<jenkins.version>2.479.3</jenkins.version>
244-
</properties>
245-
<dependencyManagement>
246-
<dependencies>
247-
<dependency>
248-
<groupId>io.jenkins.tools.bom</groupId>
249-
<artifactId>bom-2.479.x</artifactId>
250-
<version>4891.vc3a_1d6ca_fe4a_</version>
251-
<type>pom</type>
252-
<scope>import</scope>
253-
</dependency>
254-
</dependencies>
255-
</dependencyManagement>
256-
<repositories>
257-
<repository>
258-
<id>repo.jenkins-ci.org</id>
259-
<url>https://repo.jenkins-ci.org/incrementals/</url>
260-
</repository>
261-
</repositories>
262-
</project>
263-
"""));
264-
}
265-
266196
@Test
267197
void shouldSkipIfOnParentBom() {
268198
rewriteRun(

plugin-modernizer-core/src/test/java/io/jenkins/tools/pluginmodernizer/core/utils/PluginServiceTest.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.github.tomakehurst.wiremock.WireMockServer;
88
import com.github.tomakehurst.wiremock.client.WireMock;
9+
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
10+
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
911
import com.google.inject.Guice;
1012
import io.jenkins.tools.pluginmodernizer.core.GuiceModule;
1113
import io.jenkins.tools.pluginmodernizer.core.config.Config;
@@ -33,6 +35,7 @@
3335

3436
@ExtendWith({MockitoExtension.class})
3537
@Execution(ExecutionMode.CONCURRENT)
38+
@WireMockTest
3639
class PluginServiceTest {
3740

3841
@TempDir
@@ -157,11 +160,10 @@ public void shouldExtractRepoNameWithGitSuffix() throws Exception {
157160
}
158161

159162
@Test
160-
public void shouldDownloadPluginVersionDataUpdateCenterData() throws Exception {
163+
public void shouldDownloadPluginVersionDataUpdateCenterData(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
161164

162-
WireMockServer server = new WireMockServer(40465);
163-
server.start();
164-
WireMock wireMock = new WireMock(40465);
165+
WireMock wireMock = wmRuntimeInfo.getWireMock();
166+
int portNumber = wmRuntimeInfo.getHttpPort();
165167

166168
CacheManager cacheManager = Mockito.mock(CacheManager.class);
167169
Path cacheRoot = Mockito.mock(Path.class);
@@ -173,7 +175,7 @@ public void shouldDownloadPluginVersionDataUpdateCenterData() throws Exception {
173175
.willReturn(WireMock.okJson(JsonUtils.toJson(updateCenterData))));
174176

175177
// No found from cache
176-
doReturn(new URL("http://localhost:40465/update-center.json"))
178+
doReturn(new URL("http://localhost:%d/update-center.json".formatted(portNumber)))
177179
.when(config)
178180
.getJenkinsUpdateCenter();
179181

@@ -222,9 +224,10 @@ public void shouldFailIfSCMFormatIsInvalid() throws Exception {
222224
@Test
223225
public void shouldDownloadPluginVersionDataPluginHealthScore() throws Exception {
224226

225-
WireMockServer server = new WireMockServer(40466);
227+
WireMockServer server = new WireMockServer();
226228
server.start();
227-
WireMock wireMock = new WireMock(40466);
229+
int portNumber = server.getOptions().portNumber();
230+
WireMock wireMock = new WireMock(server.getOptions().portNumber());
228231

229232
CacheManager cacheManager = Mockito.mock(CacheManager.class);
230233
Path cacheRoot = Mockito.mock(Path.class);
@@ -235,7 +238,9 @@ public void shouldDownloadPluginVersionDataPluginHealthScore() throws Exception
235238
.willReturn(WireMock.okJson(JsonUtils.toJson(healthScoreData))));
236239

237240
// No found from cache
238-
doReturn(new URL("http://localhost:40466/api/scores")).when(config).getPluginHealthScore();
241+
doReturn(new URL("http://localhost:%d/api/scores".formatted(portNumber)))
242+
.when(config)
243+
.getPluginHealthScore();
239244

240245
// Get result
241246
PluginService service = getService(config, cacheManager);
@@ -244,11 +249,10 @@ public void shouldDownloadPluginVersionDataPluginHealthScore() throws Exception
244249
}
245250

246251
@Test
247-
public void shouldDownloadPluginInstallationsData() throws Exception {
252+
public void shouldDownloadPluginInstallationsData(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
248253

249-
WireMockServer server = new WireMockServer(40467);
250-
server.start();
251-
WireMock wireMock = new WireMock(40467);
254+
WireMock wireMock = wmRuntimeInfo.getWireMock();
255+
int portNumber = wmRuntimeInfo.getHttpPort();
252256

253257
CacheManager cacheManager = Mockito.mock(CacheManager.class);
254258
Path cacheRoot = Mockito.mock(Path.class);
@@ -262,7 +266,7 @@ public void shouldDownloadPluginInstallationsData() throws Exception {
262266
wireMock.register(WireMock.get(WireMock.urlEqualTo("/jenkins-stats/svg/202406-plugins.csv"))
263267
.willReturn(WireMock.ok("\"valid-plugin\",\"1\"\n" + "\"valid-plugin2\",\"1\"")));
264268

265-
URL url = new URL("http://localhost:40467/jenkins-stats/svg/202406-plugins.csv");
269+
URL url = new URL("http://localhost:%d/jenkins-stats/svg/202406-plugins.csv".formatted(portNumber));
266270

267271
// No found from cache
268272
doReturn(url).when(config).getPluginStatsInstallations();

0 commit comments

Comments
 (0)