use of com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData in project jms-messaging-plugin by jenkinsci.
the class MigrationTest method testConfig.
@LocalData
@Test
public void testConfig() {
assertEquals("config is not 1", 1, GlobalCIConfiguration.get().getConfigs().size());
JMSMessagingProvider config = GlobalCIConfiguration.get().getConfigs().get(0);
ActiveMqMessagingProvider aconfig = (ActiveMqMessagingProvider) config;
String topic = aconfig.getTopic();
assertEquals("topic is not TOM", "TOM", topic);
AbstractProject<?, ?> triggerJob = (AbstractProject<?, ?>) j.getInstance().getItem("ci-trigger");
CIBuildTrigger trigger = triggerJob.getTrigger(CIBuildTrigger.class);
assertNotNull(trigger);
CIBuildTrigger cibt = triggerJob.getTrigger(CIBuildTrigger.class);
assertTrue(cibt.getProviders().get(0) instanceof ActiveMQSubscriberProviderData);
assertNotNull(cibt.getProviders().get(0).getName());
assertNotNull(cibt.getSelector());
FreeStyleProject notifierJob = (FreeStyleProject) j.getInstance().getItem("ci-notifier");
CIMessageBuilder builder = notifierJob.getBuildersList().get(CIMessageBuilder.class);
assertNotNull(builder);
assertNotNull(builder.getProviderName());
assertNotNull(notifierJob.getPublishersList());
CIMessageNotifier notifierPublisher = notifierJob.getPublishersList().get(CIMessageNotifier.class);
assertNotNull(notifierPublisher.getProviderName());
FreeStyleProject subscriberJob = (FreeStyleProject) j.getInstance().getItem("ci-message-subscriber");
CIMessageSubscriberBuilder subscriberBuilder = subscriberJob.getBuildersList().get(CIMessageSubscriberBuilder.class);
assertNotNull(subscriberBuilder);
assertNotNull(subscriberBuilder.getProviderName());
GlobalCIConfiguration newGlobalConfig = new GlobalCIConfiguration();
JMSMessagingProvider config2 = newGlobalConfig.getConfigs().get(0);
ActiveMqMessagingProvider aconfig2 = (ActiveMqMessagingProvider) config2;
assertNotNull(aconfig2.getAuthenticationMethod());
}
use of com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData in project jms-messaging-plugin by jenkinsci.
the class AmqMessagingPluginWithFailoverIntegrationTest method testSimpleCIEventTrigger.
@Test
public void testSimpleCIEventTrigger() throws Exception {
ArrayList<FreeStyleProject> jobs = new ArrayList<>();
for (int i = 0; i < 10; i++) {
FreeStyleProject jobA = j.createFreeStyleProject("receiver" + i);
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
jobA.addTrigger(new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))));
}
waitForNoAMQTaskThreads();
long currentThreadCount = getCurrentAMQThreadCount();
System.out.println("Current AMQ Thread Count: " + currentThreadCount);
String previousThreads = printAMQThreads();
System.out.println(previousThreads);
FreeStyleProject jobB = j.createFreeStyleProject("sender");
jobB.getPublishersList().add(new CIMessageNotifier(new ActiveMQPublisherProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", null, true)));
j.buildAndAssertSuccess(jobB);
for (FreeStyleProject job : jobs) {
FreeStyleBuild lastBuild = job.getLastBuild();
j.assertBuildStatusSuccess(lastBuild);
j.assertLogContains("echo CI_TYPE = code-quality-checks-done", lastBuild);
lastBuild.delete();
}
// Now stop AMQ
System.out.println("Stopping AMQ");
stopAMQ();
System.out.println("Waiting 60 secs");
Thread.sleep(60000);
// Check for unconnection AMQ threads
System.out.println(printAMQThreads());
ensureNoUnconnectedThreads();
// Now startup
System.out.println("Starting AMQ");
startAMQ();
System.out.println("Waiting 10 secs");
Thread.sleep(10000);
waitForNoAMQTaskThreads();
System.out.println(printAMQThreads());
ensureNoLeakingThreads(currentThreadCount, previousThreads);
j.buildAndAssertSuccess(jobB);
Thread.sleep(1000);
for (FreeStyleProject job : jobs) {
FreeStyleBuild lastBuild = job.getLastBuild();
j.assertBuildStatusSuccess(lastBuild);
j.assertLogContains("echo CI_TYPE = code-quality-checks-done", lastBuild);
lastBuild.delete();
}
System.out.println(printAMQThreads());
System.out.println("Waiting 10 secs");
Thread.sleep(10000);
waitForNoAMQTaskThreads();
}
use of com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData in project jms-messaging-plugin by jenkinsci.
the class AmqMessagingPluginWithFailoverIntegrationTest method testInvalidJMSSelector.
// Test setting a valid JMS selector, then fixing it, and make sure threads are handled correctly.
@Test
public void testInvalidJMSSelector() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject("receiver");
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
jobA.addTrigger(new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, // Missing '='; invalid syntax.
"CI_TYPE 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))));
jobA.getTrigger(CIBuildTrigger.class).start(jobA, true);
// Wait for connection to fail
Thread.sleep(5000);
List<Long> ids1 = getCurrentTriggerThreadIds("receiver");
assertEquals("Trigger threads invalid size", 0, ids1.size());
JenkinsRule.WebClient wc = j.createWebClient();
String source = wc.getPage(jobA).getWebResponse().getContentAsString();
assertThat(source, containsString("CI Build Trigger Issue"));
assertThat(source, containsString("javax.jms.InvalidSelectorException"));
// Now fix the selector.
jobA.addTrigger(new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))));
new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, // Missing '='; invalid syntax.
"CI_TYPE 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))).start(jobA, true);
List<Long> ids2 = getCurrentTriggerThreadIds("receiver");
assertEquals("Trigger threads valid selector size", 1, ids2.size());
}
use of com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData in project jms-messaging-plugin by jenkinsci.
the class MessageProviderMigrator method updateCIMessageSubscriberBuilder.
private static boolean updateCIMessageSubscriberBuilder(AbstractProject<?, ?> p, CIMessageSubscriberBuilder builder) {
if (builder.getProviderData() == null) {
if (builder.getProviderName() == null) {
builder.setProviderName(GlobalCIConfiguration.get().getConfigs().get(0).getName());
}
JMSMessagingProvider prov = GlobalCIConfiguration.get().getProvider(builder.getProviderName());
if (prov instanceof ActiveMqMessagingProvider) {
ActiveMQSubscriberProviderData apd = new ActiveMQSubscriberProviderData(builder.getProviderName());
apd.setOverrides(builder.getOverrides());
apd.setSelector(builder.getSelector());
apd.setChecks(builder.getChecks());
apd.setVariable(builder.getVariable());
apd.setTimeout(builder.getTimeout());
builder.setProviderData(apd);
} else if (prov instanceof FedMsgMessagingProvider) {
FedMsgSubscriberProviderData fpd = new FedMsgSubscriberProviderData(builder.getProviderName());
fpd.setOverrides(builder.getOverrides());
fpd.setVariable(builder.getVariable());
fpd.setTimeout(builder.getTimeout());
builder.setProviderData(fpd);
} else {
RabbitMQSubscriberProviderData rpd = new RabbitMQSubscriberProviderData(builder.getProviderName());
rpd.setOverrides(builder.getOverrides());
rpd.setVariable(builder.getVariable());
rpd.setTimeout(builder.getTimeout());
builder.setProviderData(rpd);
}
try {
p.save();
return true;
} catch (IOException e) {
log.log(Level.WARNING, "Failed to save project", e);
}
}
return false;
}
use of com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData in project jms-messaging-plugin by jenkinsci.
the class AmqMessagingPluginWithFailoverIntegrationTest method testChangingJMSSelector.
@Test
public void testChangingJMSSelector() throws Exception {
// Test changing a selector and make sure threads are handled correctly.
FreeStyleProject jobA = j.createFreeStyleProject("receiver");
jobA.getBuildersList().add(new Shell("echo CI_TYPE = $CI_TYPE"));
jobA.addTrigger(new CIBuildTrigger(true, Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'", Collections.emptyList(), "CI_MESSAGE", 60))));
jobA.getTrigger(CIBuildTrigger.class).start(jobA, true);
List<Long> ids1 = getCurrentTriggerThreadIds("receiver");
assertEquals("Trigger threads value selector size", 1, ids1.size());
// Now change the selector.
jobA.getTrigger(CIBuildTrigger.class).setProviderList(Collections.singletonList(new ActiveMQSubscriberProviderData(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'success'", Collections.emptyList(), "CI_MESSAGE", 60)));
jobA.getTrigger(CIBuildTrigger.class).start(jobA, true);
List<Long> ids2 = getCurrentTriggerThreadIds("receiver");
assertEquals("Trigger threads changed selector size", 1, ids2.size());
assertNotSame("Trigger threads new thread created", ids1.get(0), ids2.get(0));
}
Aggregations