def test_private_attachments_do_not_show(self): self.settings.param.allow_private_bugs = False database.make_test_instance(self.settings.bugzilla) #MARK SOME STUFF PRIVATE with DB(self.settings.bugzilla) as db: private_attachments = db.query(""" SELECT bug_id, attach_id FROM attachments ORDER BY mod(attach_id, 7), attach_id LIMIT 5 """) for a in private_attachments: database.mark_attachment_private(db, a.attach_id, isprivate=1) es = elasticsearch.make_test_instance("candidate", self.settings.real.bugs) es_c = elasticsearch.make_test_instance("candidate_comments", self.settings.real.comments) bz_etl.main(self.settings, es, es_c) Thread.sleep(2) # MUST SLEEP WHILE ES DOES ITS INDEXING verify_no_private_attachments(es, private_attachments)
def test_recent_private_stuff_does_not_show(self): self.settings.param.allow_private_bugs = False File(self.settings.param.first_run_time).delete() File(self.settings.param.last_run_time).delete() database.make_test_instance(self.settings.bugzilla) es = elasticsearch.make_test_instance("candidate", self.settings.real.bugs) es_c = elasticsearch.make_test_instance("candidate_comments", self.settings.real.comments) bz_etl.main(self.settings, es, es_c) #MARK SOME STUFF PRIVATE with DB(self.settings.bugzilla) as db: #BUGS private_bugs = set(Random.sample(self.settings.param.bugs, 3)) Log.note("The private bugs are {{bugs}}", {"bugs": private_bugs}) for b in private_bugs: database.add_bug_group(db, b, BUG_GROUP_FOR_TESTING) #COMMENTS comments = db.query("SELECT comment_id FROM longdescs").comment_id marked_private_comments = Random.sample(comments, 5) for c in marked_private_comments: database.mark_comment_private(db, c, isprivate=1) #INCLUDE COMMENTS OF THE PRIVATE BUGS implied_private_comments = db.query(""" SELECT comment_id FROM longdescs WHERE {{where}} """, { "where": esfilter2sqlwhere(db, {"terms":{"bug_id":private_bugs}}) }).comment_id private_comments = marked_private_comments + implied_private_comments Log.note("The private comments are {{comments}}", {"comments": private_comments}) #ATTACHMENTS attachments = db.query("SELECT bug_id, attach_id FROM attachments") private_attachments = Random.sample(attachments, 5) Log.note("The private attachments are {{attachments}}", {"attachments": private_attachments}) for a in private_attachments: database.mark_attachment_private(db, a.attach_id, isprivate=1) if not File(self.settings.param.last_run_time).exists: Log.error("last_run_time should exist") bz_etl.main(self.settings, es, es_c) Thread.sleep(2) # MUST SLEEP WHILE ES DOES ITS INDEXING verify_no_private_bugs(es, private_bugs) verify_no_private_attachments(es, private_attachments) verify_no_private_comments(es_c, private_comments) #MARK SOME STUFF PUBLIC with DB(self.settings.bugzilla) as db: for b in private_bugs: database.remove_bug_group(db, b, BUG_GROUP_FOR_TESTING) bz_etl.main(self.settings, es, es_c) #VERIFY BUG IS PUBLIC, BUT PRIVATE ATTACHMENTS AND COMMENTS STILL NOT Thread.sleep(2) # MUST SLEEP WHILE ES DOES ITS INDEXING verify_public_bugs(es, private_bugs) verify_no_private_attachments(es, private_attachments) verify_no_private_comments(es_c, marked_private_comments)
def test_recent_private_stuff_does_not_show(self): self.settings.param.allow_private_bugs = False File(self.settings.param.first_run_time).delete() File(self.settings.param.last_run_time).delete() database.make_test_instance(self.settings.bugzilla) es = elasticsearch.make_test_instance("candidate", self.settings.real.bugs) es_c = elasticsearch.make_test_instance("candidate_comments", self.settings.real.comments) bz_etl.main(self.settings, es, es_c) #MARK SOME STUFF PRIVATE with DB(self.settings.bugzilla) as db: #BUGS private_bugs = set(Random.sample(self.settings.param.bugs, 3)) Log.note("The private bugs are {{bugs}}", {"bugs": private_bugs}) for b in private_bugs: database.add_bug_group(db, b, BUG_GROUP_FOR_TESTING) #COMMENTS comments = db.query("SELECT comment_id FROM longdescs").comment_id marked_private_comments = Random.sample(comments, 5) for c in marked_private_comments: database.mark_comment_private(db, c, isprivate=1) #INCLUDE COMMENTS OF THE PRIVATE BUGS implied_private_comments = db.query( """ SELECT comment_id FROM longdescs WHERE {{where}} """, { "where": esfilter2sqlwhere(db, {"terms": { "bug_id": private_bugs }}) }).comment_id private_comments = marked_private_comments + implied_private_comments Log.note("The private comments are {{comments}}", {"comments": private_comments}) #ATTACHMENTS attachments = db.query("SELECT bug_id, attach_id FROM attachments") private_attachments = Random.sample(attachments, 5) Log.note("The private attachments are {{attachments}}", {"attachments": private_attachments}) for a in private_attachments: database.mark_attachment_private(db, a.attach_id, isprivate=1) if not File(self.settings.param.last_run_time).exists: Log.error("last_run_time should exist") bz_etl.main(self.settings, es, es_c) Thread.sleep(2) # MUST SLEEP WHILE ES DOES ITS INDEXING verify_no_private_bugs(es, private_bugs) verify_no_private_attachments(es, private_attachments) verify_no_private_comments(es_c, private_comments) #MARK SOME STUFF PUBLIC with DB(self.settings.bugzilla) as db: for b in private_bugs: database.remove_bug_group(db, b, BUG_GROUP_FOR_TESTING) bz_etl.main(self.settings, es, es_c) #VERIFY BUG IS PUBLIC, BUT PRIVATE ATTACHMENTS AND COMMENTS STILL NOT Thread.sleep(2) # MUST SLEEP WHILE ES DOES ITS INDEXING verify_public_bugs(es, private_bugs) verify_no_private_attachments(es, private_attachments) verify_no_private_comments(es_c, marked_private_comments)