fsteff
fsteff

Reputation: 553

Jenkins - Running a single job addressing two nodes simultaneous - or intercommunicate between two jobs

Jenkins newbie, but have other build-server experience.

I'm in progress of setting up a test job, where software on two nodes need to ping-pong with each other. I have a pool of labeled nodes (lets call them A, running windows 7) to run the testing software and another pool of labeled nodes (lets call these B, running lubuntu 14.10).

The testing is performed through TCP/IP and needs various command line stimuli on both A and B nodes throughout the test. In the end I need to gather artifacts from both the A and B nodes.

I imagine the requirement and need to control multiple nodes simultaneous isn't so rare, but I'm really having a hard time locating info on this on the web.
Might there be a plugin for this that I've missed?


Below are my thoughts of what needs to be performer, should a single plugin not exist to help me out.

My preferred solution would be a single job, but then I need to find out how to perform following:

  1. Check out from SVN to Node A.
  2. Check out from SVN to Node B.
  3. Execute Windows script on Node A.
  4. Execute Linux script on Node B.
  5. Collect artifact from Node A.
  6. Collect artifact from Node B.

Alternative to all the even bullets above, might be to perform those actions using SSH from either the master or the A node to control the B Node, but that leaves the following questions:

  1. How to select one B node out of the B node pool - and mark it in use?
  2. How to use the Jenkins SSH/slave credentials?



A totally different alternative could be to set up two jobs, one for Node A's and one for Node B's. But then I need to find out how to perform the following:

  1. Associate one Node A job with a Node B job, so they are both aware of the association.
  2. Perform two-ways inter-communication, allowing the Node A job to wait for a signal from a Node B job and visa verse.

Eagerly looking forward to your answers!

Upvotes: 1

Views: 1728

Answers (2)

luka5z
luka5z

Reputation: 7815

In my case I've used Multi-configuration project with Slave axis. Then you can synchronize execution between nodes using your own code, or mix it with (system) Groovy script to communicate between different configurations.

ie.

def siblings = [] 

build.getParentBuild().getExactRuns().each { run ->
    if (!build.is(run)) {

        if (run.hasntStartedYet()) {
            println "Build " + name + " hasn't started yet!"
        } else {
            if (!run.isBuilding()) {
                println "Build " + name + " has already completed!"
                break
            }

            executor = run.getExecutor()
            if (executor) {
                hostname = executor.getOwner().getHostName()

                // In case hostname could not be found explicitly,
                // then set it based on node's name.
                if (!hostname) hostname = executor.getOwner().getName()

                if (hostname) {
                    siblings.add(hostname)
                }
            }
        }
    }
}

Upvotes: 0

Eldad Assis
Eldad Assis

Reputation: 11045

In a similar scenario we use, we have two jobs (I'm not aware of a way to run a single job on two nodes).
Job A runs on node A and sets up a server and then triggers job B, which is set to run on node B (as a build step).
Job B will start its client app, which is configured to work with the server installed by A (an IP configuration in my case).
The job A (server) goes into a wait loop (using bash while) that checks if client running on B has connected (I use a flag file in a shared location).

Once connected, both jobs do a few more steps and complete. Each job will end with its own reporting.

I hope this helps.

Upvotes: 0

Related Questions