This seems to be a fairly commonly recurring error in the 4.9.0dev tests:
ERROR:Pegasus.db.dashboard_loader.DashboardLoader(194): Integrity error on batch flush: (IntegrityError) foreign key constraint failed u'INSERT INTO master_workflowstate (wf_id, state, timestamp, restart_count, status, reason) VALUES (?, ?, ?, ?, ?, ?)' (39, 'WORKFLOW_TERMINATED', 1534503332.0, 0, 0, None) - batch will need to be committed per-event which will take longer