Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Last active December 28, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wheresalice/96e49b2e0bfd405ebbb81db92cbc6122 to your computer and use it in GitHub Desktop.
Save wheresalice/96e49b2e0bfd405ebbb81db92cbc6122 to your computer and use it in GitHub Desktop.
Test the health of a yum repository, ensuring that the repomd.xml file and linked data files can all be downloaded. Usage: `ruby yum_repo_test.rb http://pkg.jenkins.io/redhat-stable/repodata`
require 'open-uri'
require 'nokogiri'
BASE_PATH = ARGV[0].freeze
@repomd = Nokogiri::XML(open(File.join(BASE_PATH, 'repomd.xml')).read)
def test_path(type)
href = @repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"filelists\"]/xmlns:location").first['href']
full_path = File.join(File.dirname(BASE_PATH), href)
puts full_path
begin
open(full_path)
rescue => e
puts "failed to request #{full_path} #{e}".red
else
puts "ok".green
end
end
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
colorize(32)
end
end
test_path("filelists")
test_path("primary")
test_path("primary_db")
test_path("other_db")
test_path("other")
test_path("filelists_db")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment