import time

print "--SELFTEST-- loading test"

us = [
	'127.0.0.1#P1',
	'127.0.0.1#P2',
	'127.0.0.1#P3',
	'127.0.0.1#P4',
	'127.0.0.1#P5'
]

def payload1(wait, n):
	time.sleep(wait)

	print "--STEPTEST-- payload1 start"

	b = job.barrier('127.0.0.1#P%d' % (n), 'here', 60)
	b.rendezvous(*us)

	print "--STEPTEST-- payload1 complete"

def payload2(wait, n):
	time.sleep(wait)
	print "--STEPTEST-- payload2 start"

	b = job.barrier('127.0.0.1#P%d' % (n), 'here', 60)
	b.rendezvous(*us)

	time.sleep(1)
	print "--STEPTEST-- payload2 complete"

job.parallel(
	[payload2, 5,  1],
	[payload2, 10, 2],
	[payload1, 15, 3],
	[payload2, 20, 4],
	[payload2, 25, 5]
)