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

#590 bugzilla rest connector #592

Merged
merged 5 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ public static boolean runHeartbeatTestsOnly() {
return !Boolean.getBoolean("org.eclipse.mylyn.tests.all");
}

/**
* Returns whether to run a limited suite of tests. Returns true, unless a system property has been set to force running of all network
* tests (using CI Server).
*/
public static boolean runOnCIServerTestsOnly() {
return Boolean.getBoolean("org.eclipse.mylyn.ci.server.tests");
}

/**
* Unzips the given zip file to the given destination directory extracting only those entries the pass through the given filter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ IgnoreCondition create() {
private IgnoreCondition createCondition() throws Exception {
IgnoreCondition result;
if (isConditionTypeStandalone()) {
result = conditionType.newInstance();
result = conditionType.getDeclaredConstructor().newInstance();
} else {
result = conditionType.getDeclaredConstructor(testClass).newInstance(testClass);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2024 Frank Becker and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Frank Becker - initial API and implementation
*******************************************************************************/

package org.eclipse.mylyn.commons.sdk.util;

public class MustRunOnCIServerRule implements ConditionalIgnoreRule.IgnoreCondition {

@Override
public boolean isSatisfied(AbstractTestFixture fixture) {
return !CommonTestUtil.runOnCIServerTestsOnly();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public <T> List<T> discover(Class<T> clazz, String fixtureType, boolean defaultO
defaultOnly, exception);
}

if (fixtures.isEmpty()) {
if (fixtures.isEmpty() && CommonTestUtil.runOnCIServerTestsOnly()) {
throw new RuntimeException(
NLS.bind("Failed to discover any fixtures for kind {0} with defaultOnly={1} ({2} and {3})",
new Object[] { fixtureType, Boolean.toString(defaultOnly), URL_SERVICES_LOCALHOST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests"/>
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.mylyn.bugzilla.rest.core.tests"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/OpenJDK 17.0.4 [17.0.4]"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/OpenJDK 21.0.3 [21.0.3]"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Jenkins builds are with 17. I think we should use the same version both locally and remote.

Given that 24-09 compiler level defaults to 21 (or was it 22) do we stay with 17? What are the expectations for staying with 17?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also is specific to the one environment. Something like JavaSE-21 would be better

<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.mylyn.bugzilla.rest.core.tests.AllBugzillaRestCoreTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -consolelog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylyn.bugzilla.rest.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m&#10;-Dorg.eclipse.mylyn.tests.all=true"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m&#10;-Dorg.eclipse.mylyn.ci.server.tests=true&#10;-Dorg.eclipse.mylyn.tests.all=true"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.eclipse.mylyn.commons.sdk.util.IFixtureJUnitClass;
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner;
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition;
import org.eclipse.mylyn.commons.sdk.util.MustRunOnCIServerRule;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestAttachmentMapper;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestClient;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration;
Expand Down Expand Up @@ -83,7 +84,6 @@
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand All @@ -98,7 +98,7 @@
// the value in the fixture.
// Note: When there is no fixture with this property no tests get executed
//@RunOnlyWhenProperty(property = "default", value = "1")
@Ignore("No CI Server")

public class BugzillaRestClientTest implements IFixtureJUnitClass {
private final BugzillaRestTestFixture actualFixture;

Expand Down Expand Up @@ -128,12 +128,14 @@ public AbstractTestFixture getActualFixture() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer going straight to JUnit5 end @EnabledIf instead, like I did with #589

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can do that. BugzillaRest Connector is special because we use here a Junit4TestFixtureRunner with a BlockJUnit4ClassRunner to group the unit test per fixture.

Have you the migration of the BugzillaRest Connector on your list or should I do this because I implement the Connector?

public void testConnectorClientCache() throws Exception {
BugzillaRestClient client1 = connector.getClient(actualFixture.repository());
assertNotNull(client1);
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testGetVersion() throws Exception {
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector);
assertNotNull(client.getClient());
Expand All @@ -143,13 +145,15 @@ public void testGetVersion() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testValidate() throws Exception {
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector);
assertNotNull(client.getClient());
assertTrue(client.validate(new NullOperationMonitor()));
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testInvalidUserValidate() throws BugzillaRestException {
RepositoryLocation location = new RepositoryLocation();
location.setUrl(actualFixture.getRepositoryUrl());
Expand All @@ -165,6 +169,7 @@ public void testInvalidUserValidate() throws BugzillaRestException {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testNoUserValidate() throws BugzillaRestException {
RepositoryLocation location = new RepositoryLocation();
location.setUrl(actualFixture.getRepositoryUrl());
Expand All @@ -179,6 +184,7 @@ public void testNoUserValidate() throws BugzillaRestException {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testInvalidPasswordValidate() throws BugzillaRestException {
RepositoryLocation location = new RepositoryLocation();
location.setUrl(actualFixture.getRepositoryUrl());
Expand Down Expand Up @@ -228,6 +234,7 @@ public void testInvalidApikeyValidate() throws BugzillaRestException {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testGetConfiguration() throws Exception {
TaskRepository repository = actualFixture.repository();
BugzillaRestClient client = connector.getClient(repository);
Expand All @@ -251,17 +258,17 @@ public void testGetConfiguration() throws Exception {
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/parameters.json"),
Charset.defaultCharset()),
new Gson().toJson(parameter)
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
"http://dummy.url/"));
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json"),
Charset.defaultCharset()),
new Gson().toJson(configuration)
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
"http://dummy.url/"));
}

private void assertConfigurationFieldNames(Collection<Field> fields) throws IOException {
Expand All @@ -278,6 +285,7 @@ private void assertConfigurationFieldNames(Collection<Field> fields) throws IOEx
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testinitializeTaskData() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -323,6 +331,7 @@ public String getProduct() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testPostTaskDataWithoutProduct() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand All @@ -347,12 +356,16 @@ public String getDescription() {
fail("never reach this!");
} catch (BugzillaRestException e) {
String url = actualFixture.getRepositoryUrl();
if (url.endsWith("/")) {
url= url.substring(0, url.length()-1);
}
assertEquals("You must select/enter a product. (status: Bad Request from "
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage());
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage());
}
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testPostTaskDataWithoutMilestone() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -391,12 +404,16 @@ public String getVersion() {
fail("never reach this!");
} catch (BugzillaRestException e) {
String url = actualFixture.getRepositoryUrl();
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
assertEquals("You must select/enter a milestone. (status: Bad Request from "
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage());
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage());
}
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testPostTaskData() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -439,6 +456,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testPostTaskDataFromTaskdata() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -488,6 +506,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testGetTaskData() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -589,6 +608,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testUpdateTaskData() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Expand Down Expand Up @@ -647,6 +667,7 @@ public void testUpdateTaskData() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testAddComment() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Expand Down Expand Up @@ -681,6 +702,7 @@ public void testAddComment() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testGifAttachment() throws Exception {
TaskAttribute attachmentAttribute = null;
TaskRepository repository = actualFixture.repository();
Expand Down Expand Up @@ -750,6 +772,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testTextAttachment() throws Exception {
TaskAttribute attachmentAttribute = null;
TaskRepository repository = actualFixture.repository();
Expand Down Expand Up @@ -838,6 +861,7 @@ public void accept(TaskData taskData) {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testCreateCCAttribute() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -891,6 +915,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testCreateBlocksAttribute() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -945,6 +970,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testCreateDependsOnAttribute() throws Exception {
final TaskMapping taskMappingInit = new TaskMapping() {
@Override
Expand Down Expand Up @@ -999,6 +1025,7 @@ public String getVersion() {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testCCAttribute() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
TaskData taskDataGet = harness.getTaskFromServer(taskId);
Expand Down Expand Up @@ -1046,6 +1073,7 @@ public void testCCAttribute() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testBlocksAttributeV1() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
String[] taskIdRel = harness.getRelationTasks();
Expand Down Expand Up @@ -1093,6 +1121,7 @@ public void testBlocksAttributeV1() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testBlocksAttributeV2() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
String[] taskIdRel = harness.getRelationTasks();
Expand Down Expand Up @@ -1143,6 +1172,7 @@ public void testBlocksAttributeV2() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testDependsOnAttributeV1() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
String[] taskIdRel = harness.getRelationTasks();
Expand Down Expand Up @@ -1191,6 +1221,7 @@ public void testDependsOnAttributeV1() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testDependsOnAttributeV2() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();
String[] taskIdRel = harness.getRelationTasks();
Expand Down Expand Up @@ -1242,6 +1273,7 @@ public void testDependsOnAttributeV2() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testFlagsSet() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();

Expand Down Expand Up @@ -1358,6 +1390,7 @@ public void testFlagsSet() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testFlagsReset() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();

Expand Down Expand Up @@ -1546,6 +1579,7 @@ public void testFlagsReset() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testFlagsChange() throws Exception {
String taskId = harness.getNewTaksId4TestProduct();

Expand Down Expand Up @@ -1745,6 +1779,7 @@ public void testFlagsChange() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
public void testTextAttachmentWithFlags() throws Exception {
TaskAttribute attachmentAttribute = null;
TaskRepository repository = actualFixture.repository();
Expand Down
Loading