From 9f77b138e2badab0bb6cbb2d098bb5bad1cd88d1 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Fri, 6 Sep 2013 21:20:00 +0200 Subject: [PATCH] [api] fake issue servers using webmock Fetching fate issues seems to be a stub ;( --- src/api/app/models/issue_tracker.rb | 173 ++-- src/api/config/clock.rb | 5 +- .../config/initializers/delayed_job_config.rb | 1 + src/api/test/fixtures/backend/allitems.xml.gz | Bin 0 -> 1468 bytes .../fixtures/backend/bugzilla_get_0815.xml | 359 +++++++ .../backend/bugzilla_get_response.xml | 922 ++++++++++++++++++ .../backend/bugzilla_response_search.xml | 919 +++++++++++++++++ src/api/test/functional/attributes_test.rb | 2 + src/api/test/unit/code_quality_test.rb | 1 - src/api/test/unit/issue.rb | 21 - src/api/test/unit/issue_test.rb | 87 ++ 11 files changed, 2379 insertions(+), 111 deletions(-) create mode 100644 src/api/config/initializers/delayed_job_config.rb create mode 100644 src/api/test/fixtures/backend/allitems.xml.gz create mode 100644 src/api/test/fixtures/backend/bugzilla_get_0815.xml create mode 100644 src/api/test/fixtures/backend/bugzilla_get_response.xml create mode 100644 src/api/test/fixtures/backend/bugzilla_response_search.xml delete mode 100644 src/api/test/unit/issue.rb create mode 100644 src/api/test/unit/issue_test.rb diff --git a/src/api/app/models/issue_tracker.rb b/src/api/app/models/issue_tracker.rb index 1e1022f8df4..76dae94c9dd 100644 --- a/src/api/app/models/issue_tracker.rb +++ b/src/api/app/models/issue_tracker.rb @@ -13,9 +13,9 @@ class NotFoundError < APIException validates_inclusion_of :kind, :in => ['other', 'bugzilla', 'cve', 'fate', 'trac', 'launchpad', 'sourceforge'] # FIXME: issues_updated should not be hidden, but it should also not break our api - DEFAULT_RENDER_PARAMS = {:except => [:id, :password, :user, :issues_updated], :dasherize => true, :skip_types => true, :skip_instruct => true } + DEFAULT_RENDER_PARAMS = {:except => [:id, :password, :user, :issues_updated], :dasherize => true, :skip_types => true, :skip_instruct => true} - def self.write_to_backend() + def self.write_to_backend path = "/issue_trackers" logger.debug "Write issue tracker information to backend..." Suse::Backend.put_source(path, IssueTracker.all.to_xml(DEFAULT_RENDER_PARAMS)) @@ -29,7 +29,7 @@ def self.write_to_backend() end def update_package_metadata - Project.each do |prj| + Project.all.each do |prj| next unless Project.exists?(prj) prj.packages.each do |pkg| next unless Package.exists?(pkg) @@ -42,21 +42,21 @@ def update_package_metadata end # Checks if the given issue belongs to this issue tracker - def matches?(issue) - return Regexp.new(regex).match(issue) - end + # def matches?(issue) + # return Regexp.new(regex).match(issue) + # end # Generates a URL to display a given issue in the upstream issue tracker - def show_url_for(issue) - return show_url.gsub('@@@', issue) if issue - return nil - end + # def show_url_for(issue) + # return show_url.gsub('@@@', issue) if issue + # return nil + # end - def issue(issue_id) - return Issue.find_by_name_and_tracker(issue_id, self.name) - end + # def issue(issue_id) + # return Issue.find_by_name_and_tracker(issue_id, self.name) + # end - def update_issues() + def update_issues # before asking remote to ensure that it is older then on remote, assuming ntp works ... # to be sure, just reduce it by 5 seconds (would be nice to have a counter at bugzilla to # guarantee a complete search) @@ -68,7 +68,7 @@ def update_issues() rescue Net::ReadTimeout return false end - ids = result["bugs"].map{ |x| x["id"].to_i } + ids = result["bugs"].map { |x| x["id"].to_i } if private_fetch_issues(ids) self.issues_updated = update_time_stamp @@ -102,10 +102,10 @@ def update_issues() end # this function is usually never called. Just for debugging and disaster recovery - def enforced_update_all_issues() + def enforced_update_all_issues update_time_stamp = Time.at(Time.now.to_f - 5) - ids = issues.map{ |x| x.name.to_s } + ids = issues.map { |x| x.name.to_s } if private_fetch_issues(ids) self.issues_updated = update_time_stamp @@ -121,91 +121,94 @@ def fetch_issues(issues=nil) issues = self.issues.stateless end - ids = issues.map{ |x| x.name.to_s } + ids = issues.map { |x| x.name.to_s } return private_fetch_issues(ids) end - private - def private_fetch_issues(ids) - unless self.enable_fetch - logger.info "Bug mentioned on #{self.name}, but fetching from server is disabled" - return false + def self.update_all_issues + IssueTracker.all.each do |t| + next unless t.enable_fetch + t.delay.update_issues end + end - update_time_stamp = Time.at(Time.now.to_f) + private - if kind == "bugzilla" - # limit to 256 ids to avoid too much load and timeouts on bugzilla side - limit_per_slice=256 - while ids - begin - result = bugzilla_server.get({:ids => ids[0..limit_per_slice], :permissive => 1}) - rescue RuntimeError => e - logger.error "Unable to fetch issue #{e.inspect}" - return false - rescue XMLRPC::FaultException => e - logger.error "Error: #{e.faultCode} #{e.faultString}" - return false - end - result["bugs"].each{ |r| - issue = Issue.find_by_name_and_tracker r["id"].to_s, self.name - if issue - if r["is_open"] - # bugzilla sees it as open - issue.state = Issue.states["OPEN"] - elsif r["is_open"] == false - # bugzilla sees it as closed - issue.state = Issue.states["CLOSED"] - else - # bugzilla does not tell a state - issue.state = Issue.bugzilla_state(r["status"]) - end - u = User.find_by_email(r["assigned_to"].to_s) - logger.info "Bug user #{r["assigned_to"].to_s} is not found in OBS user database" unless u - issue.owner_id = u.id if u - issue.updated_at = update_time_stamp - if r["is_private"] - issue.summary = nil - else - issue.summary = r["summary"] - end - issue.save - end - } - - ids=ids[limit_per_slice..-1] - end - elsif kind == "fate" - # Try with 'IssueTracker.find_by_name('fate').details('123')' on script/console - url = URI.parse("#{self.url}/#{self.name}?contenttype=text%2Fxml") - begin # Need a loop to follow redirects... - http = Net::HTTP.new(url.host, url.port) - http.use_ssl = (url.scheme == 'https') - request = Net::HTTP::Get.new(url.path) - resp = http.start {|h| h.request(request) } - url = URI.parse(resp.header['location']) if resp.header['location'] - end while resp.header['location'] - # TODO: Parse returned XML and return proper JSON - return false - elsif kind == "trac" - # TODO: Most trac instances demand a login, maybe worth having one ;-) - server = XMLRPC::Client.new2("#{self.url}/rpc") + def fetch_bugzilla_issues(ids) + # limit to 256 ids to avoid too much load and timeouts on bugzilla side + limit_per_slice=256 + while !ids.blank? begin - server.proxy('system').listMethods() + result = bugzilla_server.get({:ids => ids[0..limit_per_slice], :permissive => 1}) + rescue RuntimeError => e + logger.error "Unable to fetch issue #{e.inspect}" + return false rescue XMLRPC::FaultException => e logger.error "Error: #{e.faultCode} #{e.faultString}" - if e.faultCode == 403 - # The url would be http://user:pass@trac-inst.com/login/rpc - #server = XMLRPC::Client.new2("#{self.url}/login/rpc") - end return false end + result["bugs"].each { |r| parse_single_bugzilla_issue(r) } + ids=ids[limit_per_slice..-1] + end + return true + end + + def parse_single_bugzilla_issue(r) + issue = Issue.find_by_name_and_tracker r["id"].to_s, self.name + if issue + if r["is_open"] + # bugzilla sees it as open + issue.state = Issue.states["OPEN"] + elsif r["is_open"] == false + # bugzilla sees it as closed + issue.state = Issue.states["CLOSED"] + else + # bugzilla does not tell a state + issue.state = Issue.bugzilla_state(r["status"]) + end + u = User.find_by_email(r["assigned_to"].to_s) + logger.info "Bug user #{r["assigned_to"].to_s} is not found in OBS user database" unless u + issue.owner_id = u.id if u + issue.updated_at = update_time_stamp + if r["is_private"] + issue.summary = nil + else + issue.summary = r["summary"] + end + issue.save + end + end + + def private_fetch_issues(ids) + unless self.enable_fetch + logger.info "Bug mentioned on #{self.name}, but fetching from server is disabled" + return false + end + + if kind == "bugzilla" + return fetch_bugzilla_issues(ids) + elsif kind == "fate" + # Try with 'IssueTracker.find_by_name('fate').details('123')' on script/console + return fetch_fate_issues end # everything succeeded return true end + def fetch_fate_issues + url = URI.parse("#{self.url}/#{self.name}?contenttype=text%2Fxml") + begin # Need a loop to follow redirects... + http = Net::HTTP.new(url.host, url.port) + http.use_ssl = (url.scheme == 'https') + request = Net::HTTP::Get.new(url.path) + resp = http.start { |h| h.request(request) } + url = URI.parse(resp.header['location']) if resp.header['location'] + end while resp.header['location'] + # TODO: Parse returned XML and return proper JSON + return false + end + def bugzilla_server server = XMLRPC::Client.new2("#{self.url}/xmlrpc.cgi") server.timeout = 300 # 5 minutes timeout diff --git a/src/api/config/clock.rb b/src/api/config/clock.rb index 9bc544245d8..68efab19cd0 100644 --- a/src/api/config/clock.rb +++ b/src/api/config/clock.rb @@ -15,10 +15,7 @@ end every(1.hour, 'refresh issues') do - IssueTracker.all.each do |t| - next unless t.enable_fetch - t.delay.update_issues - end + IssueTracker.update_all_issues end every(1.hour, 'accept requests') do diff --git a/src/api/config/initializers/delayed_job_config.rb b/src/api/config/initializers/delayed_job_config.rb new file mode 100644 index 00000000000..79fa7d9e8ec --- /dev/null +++ b/src/api/config/initializers/delayed_job_config.rb @@ -0,0 +1 @@ +Delayed::Worker.delay_jobs = !Rails.env.test? diff --git a/src/api/test/fixtures/backend/allitems.xml.gz b/src/api/test/fixtures/backend/allitems.xml.gz new file mode 100644 index 0000000000000000000000000000000000000000..cc06f56705018658a424273a76efdd020e85350d GIT binary patch literal 1468 zcmV;t1w;BDiwFpXH!4y917U1zX>?_6b1ryoYyh=aZExE+4F2w4LHK~71!_BS*0s%2 z4{6#C9k#C5{1&w1{6#0;RNUDPm%d&tuQ<_V0 z?svnE{~_@Pbj|=5gzhgjKlgKEs(utL7K?Dv3#FPxai`Ob9=?1Y)0~wg;6fWBDDyqA zAGh^!8!8J+ZWMDn@hQsWLKKo@dM&ScU&vchGF=hM8l|5lCB~uJt4BK_rw+g05qY@O znUCPPVI`PV#m@cF@YV-`dhzz#RnR>h%=8Q7QSK6-xKjk_m)@Q;HZ8_rlzi#UBWJ%9nof8^Zf6e;t3jyx3z`&$HAiIzH)O z!tHgvJ!)e*$DG;U(vo2XRMx^EvHav(F`5se<~<4sDXaBz>?gNUnVilw1i5igUl;3oIp{H&#UuX9AZrj=U&%9J65EfPS&&B+m?Fb!2Q)|IG%v!I5C=(TjmjTh9bQ_b5SonYek|)1z*P) zj+AMRiCe?R*49$}Iq6;D`N_j|ACsaoC98v8@AMG8M?*wwJ`+xSf%Hl-nHdtcU`P-t zkWwz7l({0X4!O=o+RpZx*{52YY?I#w`QqjhIo3IXMb0tq7~dbx#CC`dh_}wq+T`I8 z2)R|IYXTv$=NJ===;|@6$Y=|=j~&=D8aq4adNxCT;t-)y2#m0WlrpnmOzaX+WZOAI z=IyGp^(iIH$*gA90ZgZ^k+`-g$l7?*TDhzdL5h{;dMjknMyrbKm`=RyasBOT-?)x< z#&x_guCIhqtBq0ZCf-GD3j-vcYo<6`Eu(L*$Jl$Yqh>I}VT|2FN@JT4(=HLa)AtCa zwLw5#SD~Kq5PgqyT~*jhBimCV&1kK-Sw(HGInzkJ~a>5ep1*F2MzonmAg~+H^|c4AxrO9 zWVu=*Vobf|CRTv$5e+%)kt%)8q=}S;A;k}S9wfGbxHB0F9jJ}FC;H!zu8S1IzhO(d_2d6;@a|#T;@!hb93gxeJcaiqsn;U)TZD}* WVdEE=II#b8B;LOqQbf={4FCYScgW=c literal 0 HcmV?d00001 diff --git a/src/api/test/fixtures/backend/bugzilla_get_0815.xml b/src/api/test/fixtures/backend/bugzilla_get_0815.xml new file mode 100644 index 00000000000..c0c37bd0c5f --- /dev/null +++ b/src/api/test/fixtures/backend/bugzilla_get_0815.xml @@ -0,0 +1,359 @@ + + + + + + + + faults + + + + + + + faultString + + Bug #1234 does not exist. + + + + id + + 1234 + + + + faultCode + + 101 + + + + + + + + + + bugs + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T15:01:03 + + + + component + + Collector:Microsoft Active Directory Identities + + + + summary + + UPN used for email address is not expected behavior + + + + internals + + + + priority + + P5 - None + + + + cf_nts_priority + + 200 + + + + bug_id + + 815 + + + + cclist_accessible + + 1 + + + + cf_foundby + + Customer + + + + assigned_to + + 48095 + + + + short_desc + + UPN used for email address is not expected behavior + + + + qa_contact + + 56606 + + + + everconfirmed + + 1 + + + + bug_severity + + Normal + + + + reporter_id + + 2245 + + + + cf_partnerid + + + + + + resolution + + + + + + reporter_accessible + + 1 + + + + cf_biz_priority + + + + + + op_sys + + Other + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 411 + + + + rep_platform + + Other + + + + creation_ts + + 2013.09.06 14:59 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 15:01:03 + + + + version + + 2011.1r2 + + + + component_id + + 16367 + + + + component + + Collector:Microsoft Active Directory Identities + + + + product + + Sentinel Plug-ins + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + rsujith@novell.com + + + + resolution + + + + + + product + + Sentinel Plug-ins + + + + creation_time + + 20130906T14:59:00 + + + + id + + 815 + + + + alias + + + + + + severity + + Normal + + + + + + + + + + + + + diff --git a/src/api/test/fixtures/backend/bugzilla_get_response.xml b/src/api/test/fixtures/backend/bugzilla_get_response.xml new file mode 100644 index 00000000000..ab268128576 --- /dev/null +++ b/src/api/test/fixtures/backend/bugzilla_get_response.xml @@ -0,0 +1,922 @@ + + + + + + + + faults + + + + + + + + bugs + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T15:01:03 + + + + component + + Collector:Microsoft Active Directory Identities + + + + summary + + UPN used for email address is not expected behavior + + + + internals + + + + priority + + P5 - None + + + + cf_nts_priority + + 200 + + + + bug_id + + 838932 + + + + cclist_accessible + + 1 + + + + cf_foundby + + Customer + + + + assigned_to + + 48095 + + + + short_desc + + UPN used for email address is not expected behavior + + + + qa_contact + + 56606 + + + + everconfirmed + + 1 + + + + bug_severity + + Normal + + + + reporter_id + + 2245 + + + + cf_partnerid + + + + + + resolution + + + + + + reporter_accessible + + 1 + + + + cf_biz_priority + + + + + + op_sys + + Other + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 411 + + + + rep_platform + + Other + + + + creation_ts + + 2013.09.06 14:59 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 15:01:03 + + + + version + + 2011.1r2 + + + + component_id + + 16367 + + + + component + + Collector:Microsoft Active Directory Identities + + + + product + + Sentinel Plug-ins + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + rsujith@novell.com + + + + resolution + + + + + + product + + Sentinel Plug-ins + + + + creation_time + + 20130906T14:59:00 + + + + id + + 838932 + + + + alias + + + + + + severity + + Normal + + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T15:03:54 + + + + component + + Kernel + + + + summary + + kernel BUG at /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.0/linux-3.11/drivers/gpu/drm/drm_gem.c:573! + + + + internals + + + + priority + + P5 - None + + + + bug_id + + 838933 + + + + cclist_accessible + + 1 + + + + cf_foundby + + --- + + + + assigned_to + + 16339 + + + + short_desc + + kernel BUG at /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.0/linux-3.11/drivers/gpu/drm/drm_gem.c:573! + + + + qa_contact + + 7641 + + + + everconfirmed + + 1 + + + + bug_severity + + Normal + + + + reporter_id + + 21157 + + + + resolution + + + + + + reporter_accessible + + 1 + + + + op_sys + + openSUSE 12.3 + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 1257 + + + + rep_platform + + i686 + + + + creation_ts + + 2013.09.06 15:03 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 15:03:54 + + + + version + + Final + + + + component_id + + 18856 + + + + component + + Kernel + + + + product + + openSUSE 12.3 + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + kernel-maintainers@forge.provo.novell.com + + + + resolution + + + + + + product + + openSUSE 12.3 + + + + creation_time + + 20130906T15:03:00 + + + + id + + 838933 + + + + alias + + + + + + severity + + Normal + + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T17:44:27 + + + + component + + Development + + + + summary + + Should have libboost_python3 package for use of boost/python with python3 + + + + internals + + + + priority + + P5 - None + + + + bug_id + + 838970 + + + + cclist_accessible + + 1 + + + + cf_foundby + + --- + + + + assigned_to + + 13842 + + + + short_desc + + Should have libboost_python3 package for use of boost/python with python3 + + + + qa_contact + + 7641 + + + + everconfirmed + + 1 + + + + bug_severity + + Minor + + + + reporter_id + + 68080 + + + + cf_partnerid + + + + + + resolution + + + + + + reporter_accessible + + 1 + + + + op_sys + + openSUSE 12.3 + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 1257 + + + + rep_platform + + PC + + + + creation_ts + + 2013.09.06 17:44 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 17:44:27 + + + + version + + Final + + + + component_id + + 18846 + + + + component + + Development + + + + product + + openSUSE 12.3 + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + bnc-team-screening@forge.provo.novell.com + + + + resolution + + + + + + product + + openSUSE 12.3 + + + + creation_time + + 20130906T17:44:00 + + + + id + + 838970 + + + + alias + + + + + + severity + + Minor + + + + + + + + + + + + + diff --git a/src/api/test/fixtures/backend/bugzilla_response_search.xml b/src/api/test/fixtures/backend/bugzilla_response_search.xml new file mode 100644 index 00000000000..1750b50dc59 --- /dev/null +++ b/src/api/test/fixtures/backend/bugzilla_response_search.xml @@ -0,0 +1,919 @@ + + + + + + + + bugs + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T15:01:03 + + + + component + + Collector:Microsoft Active Directory Identities + + + + summary + + UPN used for email address is not expected behavior + + + + internals + + + + priority + + P5 - None + + + + cf_nts_priority + + 200 + + + + bug_id + + 838932 + + + + cclist_accessible + + 1 + + + + cf_foundby + + Customer + + + + assigned_to + + 48095 + + + + short_desc + + UPN used for email address is not expected behavior + + + + qa_contact + + 56606 + + + + everconfirmed + + 1 + + + + bug_severity + + Normal + + + + reporter_id + + 2245 + + + + cf_partnerid + + + + + + resolution + + + + + + reporter_accessible + + 1 + + + + cf_biz_priority + + + + + + op_sys + + Other + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 411 + + + + rep_platform + + Other + + + + creation_ts + + 2013.09.06 14:59 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 15:01:03 + + + + version + + 2011.1r2 + + + + component_id + + 16367 + + + + component + + Collector:Microsoft Active Directory Identities + + + + product + + Sentinel Plug-ins + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + rsujith@novell.com + + + + resolution + + + + + + product + + Sentinel Plug-ins + + + + creation_time + + 20130906T14:59:00 + + + + id + + 838932 + + + + alias + + + + + + severity + + Normal + + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T15:03:54 + + + + component + + Kernel + + + + summary + + kernel BUG at + /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.0/linux-3.11/drivers/gpu/drm/drm_gem.c:573! + + + + + internals + + + + priority + + P5 - None + + + + bug_id + + 838933 + + + + cclist_accessible + + 1 + + + + cf_foundby + + --- + + + + assigned_to + + 16339 + + + + short_desc + + kernel BUG at + /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.0/linux-3.11/drivers/gpu/drm/drm_gem.c:573! + + + + + qa_contact + + 7641 + + + + everconfirmed + + 1 + + + + bug_severity + + Normal + + + + reporter_id + + 21157 + + + + resolution + + + + + + reporter_accessible + + 1 + + + + op_sys + + openSUSE 12.3 + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 1257 + + + + rep_platform + + i686 + + + + creation_ts + + 2013.09.06 15:03 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 15:03:54 + + + + version + + Final + + + + component_id + + 18856 + + + + component + + Kernel + + + + product + + openSUSE 12.3 + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + kernel-maintainers@forge.provo.novell.com + + + + resolution + + + + + + product + + openSUSE 12.3 + + + + creation_time + + 20130906T15:03:00 + + + + id + + 838933 + + + + alias + + + + + + severity + + Normal + + + + + + + + priority + + P5 - None + + + + status + + NEW + + + + last_change_time + + 20130906T17:44:27 + + + + component + + Development + + + + summary + + Should have libboost_python3 package for use of boost/python with python3 + + + + internals + + + + priority + + P5 - None + + + + bug_id + + 838970 + + + + cclist_accessible + + 1 + + + + cf_foundby + + --- + + + + assigned_to + + 13842 + + + + short_desc + + Should have libboost_python3 package for use of boost/python with python3 + + + + + qa_contact + + 7641 + + + + everconfirmed + + 1 + + + + bug_severity + + Minor + + + + reporter_id + + 68080 + + + + cf_partnerid + + + + + + resolution + + + + + + reporter_accessible + + 1 + + + + op_sys + + openSUSE 12.3 + + + + status + + + + sortkey + + 200 + + + + value + + NEW + + + + is_open + + 1 + + + + isactive + + 1 + + + + id + + 2 + + + + + + + _multi_selects + + + + + + + + bug_file_loc + + + + + + cf_blocker + + --- + + + + product_id + + 1257 + + + + rep_platform + + PC + + + + creation_ts + + 2013.09.06 17:44 + + + + status_whiteboard + + + + + + bug_status + + NEW + + + + delta_ts + + 2013-09-06 17:44:27 + + + + version + + Final + + + + component_id + + 18846 + + + + component + + Development + + + + product + + openSUSE 12.3 + + + + target_milestone + + --- + + + + + + + is_open + + 1 + + + + assigned_to + + bnc-team-screening@forge.provo.novell.com + + + + resolution + + + + + + product + + openSUSE 12.3 + + + + creation_time + + 20130906T17:44:00 + + + + id + + 838970 + + + + alias + + + + + + severity + + Minor + + + + + + + + + + + + + diff --git a/src/api/test/functional/attributes_test.rb b/src/api/test/functional/attributes_test.rb index 1a4cb964257..80c983cad46 100644 --- a/src/api/test/functional/attributes_test.rb +++ b/src/api/test/functional/attributes_test.rb @@ -174,6 +174,8 @@ def test_with_issue get "/attribute/TEST/Dummy/_meta" assert_response :success + stub_request(:post, "http://bugzilla.novell.com/xmlrpc.cgi").to_timeout + # set issues data = " diff --git a/src/api/test/unit/code_quality_test.rb b/src/api/test/unit/code_quality_test.rb index 38974ebdff0..9474e11b57a 100644 --- a/src/api/test/unit/code_quality_test.rb +++ b/src/api/test/unit/code_quality_test.rb @@ -79,7 +79,6 @@ def setup 'ProjectStatusHelper::calc_status' => 159.25, 'MaintenanceIncident#getUpdateinfoId' => 151.95, 'PersonController#userinfo' => 149.28, - 'IssueTracker#private_fetch_issues' => 147.27, 'Maintainership#extract_maintainer' => 144.49, 'BsRequest#events' => 143.76, 'SourceController#project_command_copy' => 140.04, diff --git a/src/api/test/unit/issue.rb b/src/api/test/unit/issue.rb deleted file mode 100644 index 33cbbc1b499..00000000000 --- a/src/api/test/unit/issue.rb +++ /dev/null @@ -1,21 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/..') + '/test_helper' - -class IssueTest < ActiveSupport::TestCase - fixtures :users - fixtures :db_packages - fixtures :issue_trackers - - def test_create_and_destroy - #pkg = Package.find( 10095 ) - iggy = User.find_by_email("Iggy@pop.org") - bnc = IssueTracker.find_by_name("bnc") - issue = Issue.create :name => '0815', :issue_tracker => bnc - issue.save - issue.summary = 'This unit test is not working' - issue.state = 'INVALID' - issue.owner = iggy - issue.save - issue.destroy - end - -end diff --git a/src/api/test/unit/issue_test.rb b/src/api/test/unit/issue_test.rb new file mode 100644 index 00000000000..bb767d5451c --- /dev/null +++ b/src/api/test/unit/issue_test.rb @@ -0,0 +1,87 @@ +require File.expand_path(File.dirname(__FILE__) + '/..') + '/test_helper' + +class IssueTest < ActiveSupport::TestCase + fixtures :all + + def teardown + WebMock.reset! + end + + BugGet0815 = "Bug.getids12340815permissive1\n" + + def test_create_and_destroy + + stub_request(:post, "http://bugzilla.novell.com/xmlrpc.cgi"). + with(body: BugGet0815). + to_return(:status => 200, + body: load_backend_file("bugzilla_get_0815.xml"), + headers: {}) + + #pkg = Package.find( 10095 ) + iggy = User.find_by_email("Iggy@pop.org") + bnc = IssueTracker.find_by_name("bnc") + issue = Issue.create :name => '0815', :issue_tracker => bnc + issue.save + issue.summary = 'This unit test is not working' + issue.state = Issue.bugzilla_state('NEEDINFO') + issue.owner = iggy + issue.save + issue.destroy + end + + BugSearch = "Bug.searchlast_change_time20110729T14:00:21\n" + BugGet = "Bug.getids838932838933838970permissive1\n" + + test "fetch issues" do + + stub_request(:post, "http://bugzilla.novell.com/xmlrpc.cgi"). + with(body: BugSearch). + to_return(:status => 200, + body: load_backend_file("bugzilla_response_search.xml"), + headers: {}) + + stub_request(:post, "http://bugzilla.novell.com/xmlrpc.cgi"). + with(body: BugGet). + to_return(status: 200, + body: load_backend_file("bugzilla_get_response.xml"), + headers: {}) + + IssueTracker.update_all_issues + end + + test "fetch cve" do + # erase all the bugzilla fixtures + Issue.destroy_all + IssueTracker.find_by_kind("bugzilla").destroy + + cve = IssueTracker.find_by_name("cve") + cve.enable_fetch = 1 + cve.save + cve.issues.create name: "CVE-1999-0001" + + stub_request(:head, "http://cve.mitre.org/data/downloads/allitems.xml.gz"). + to_return(:status => 200, headers: {'Last-Modified' => 2.days.ago}) + + stub_request(:get, "http://cve.mitre.org/data/downloads/allitems.xml.gz"). + to_return(:status => 200, :body => load_backend_file("allitems.xml.gz"), + headers: {'Last-Modified' => 2.days.ago}) + + IssueTracker.update_all_issues + end + + test "fetch fate" do + # erase all the bugzilla fixtures + Issue.destroy_all + IssueTracker.find_by_kind("bugzilla").destroy + + stub_request(:get, "https://features.opensuse.org//fate"). + to_return(:status => 200, :body => "", :headers => {}) + + fate = IssueTracker.find_by_name("fate") + fate.enable_fetch = 1 + fate.save + fate.issues.create name: "fate#2282" + + IssueTracker.update_all_issues + end +end