use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerOnPipelineJobWithGlobalEnvVarInTopic.
public void _testSimpleCIEventTriggerOnPipelineJobWithGlobalEnvVarInTopic() throws Exception {
j.jenkins.getGlobalNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("MY_TOPIC_ID", "MY_UUID")));
WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
jobA.setDefinition(new CpsFlowDefinition("node('master') {\n sleep 10\n}", true));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("$MY_TOPIC_ID", null, "CI_TYPE = 'code-quality-checks-done' and CI_STATUS = 'failed'"))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC_ID", MessageUtils.MESSAGE_TYPE.CodeQualityChecksDone, "CI_STATUS = failed", "Hello World")));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventTriggerWithCheckOnPipelineJobWithGlobalEnvVarInTopic.
public void _testSimpleCIEventTriggerWithCheckOnPipelineJobWithGlobalEnvVarInTopic() throws Exception {
j.jenkins.getGlobalNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("MY_TOPIC_ID", "MY_UUID")));
WorkflowJob jobA = j.jenkins.createProject(WorkflowJob.class, "jobA");
jobA.setDefinition(new CpsFlowDefinition("node('master') {\n sleep 10\n}", true));
attachTrigger(new CIBuildTrigger(false, Collections.singletonList(getSubscriberProviderData("$MY_TOPIC_ID", null, null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE)))), jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("$MY_TOPIC_ID", null, null, MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class SharedMessagingPluginIntegrationTest method _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic.
public void _testSimpleCIEventSubscribeWithCheckWithTopicOverrideAndVariableTopic() throws Exception {
FreeStyleProject jobA = j.createFreeStyleProject();
jobA.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("MY_TOPIC", "my-topic", "")));
jobA.getBuildersList().add(new CIMessageSubscriberBuilder(getSubscriberProviderData("$MY_TOPIC", "HELLO", null, new MsgCheck(MESSAGE_CHECK_FIELD, MESSAGE_CHECK_VALUE))));
jobA.getBuildersList().add(new Shell("echo $HELLO"));
scheduleAwaitStep(jobA);
FreeStyleProject jobB = j.createFreeStyleProject();
jobB.getPublishersList().add(new CIMessageNotifier(getPublisherProviderData("my-topic", null, null, MESSAGE_CHECK_CONTENT)));
j.buildAndAssertSuccess(jobB);
waitUntilScheduledBuildCompletes();
j.assertBuildStatusSuccess(jobA.getLastBuild());
j.assertLogContains("catch me", jobA.getLastBuild());
}
use of com.redhat.jenkins.plugins.ci.CIMessageNotifier 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.CIMessageNotifier in project jms-messaging-plugin by jenkinsci.
the class RabbitMQMessagingPluginIntegrationTest method testFedoraMessagingHeaders.
@Test
public void testFedoraMessagingHeaders() throws Exception {
FreeStyleProject job = j.createFreeStyleProject();
job.getPublishersList().add(new CIMessageNotifier(new RabbitMQPublisherProviderData("test", null, "", true, true, 20, "schema")));
FreeStyleBuild lastBuild = j.buildAndAssertSuccess(job);
j.assertLogContains("fedora_messaging_severity=20, fedora_messaging_schema=schema}", lastBuild);
j.assertLogContains("{sent_at=", lastBuild);
}
Aggregations