Ejemplo n.º 1
0
	def test_02_build_client (self) :
		log = logging.getLogger( "testCase" )
		log.debug(" ")
		if not "dry_run" in self.options :
			msg = "I: asserting dry_run for test cases"
			log.debug (msg)
			self.options["dry_run"] = True
		base_client = PackageHandler(self.options)
		self.assertTrue (base_client)
		self.assertTrue (base_client.is_dry_run())
		deb_client = DebianBuildClient(self.options)
		self.assertTrue (deb_client)
		self.assertTrue (deb_client.is_dry_run())
		svn_client = SubversionClient(self.options)
		self.assertTrue (svn_client)
		self.assertTrue (svn_client.is_dry_run())
		apt_client = AptClient(self.options)
		self.assertTrue (apt_client)
		self.assertTrue (apt_client.is_dry_run())
		git_client = GitClient(self.options)
		self.assertTrue (git_client)
		self.assertTrue (git_client.is_dry_run())
Ejemplo n.º 2
0
def main():
	FORMAT = '%(asctime)s %(filename)s:%(lineno)d %(msg)s'
	logging.basicConfig( stream=sys.stderr, level=logging.DEBUG)
	logging.basicConfig( format=FORMAT )
	conffile = "%s/configs/client/client.conf" % (os.getcwd());
	testconf = "%s/buildd-test.conf" % (os.getcwd());
	if os.path.isfile (conffile):
		(settings, opened_path) = pybit.load_settings(conffile)
	else :
		(settings, opened_path) = pybit.load_settings("/etc/pybit/client/client.conf")
	build_client = PyBITClient(settings["host_arch"], settings["distribution"], settings["pkg_format"], settings["suites"], None, settings)

	if not os.path.isfile (testconf):
		print "E: Unable to find %s - no test data for this buildd" % (testconf)
		print "I: Copy /usr/share/pybitclient/buildd-test.conf and modify it for your available packages."
		return 1
	else :
		(test_options, opened_path) = pybit.load_settings(testconf)

	count = 0
	max_count = test_options["count"]
	tags = [ "vcs_id", "method_type", "suite", "package", "version",
		"architecture", "source", "uri", "pkg_format", "distribution", "role", "commands" ]
	svn_vcs = SubversionClient (settings)
	git_vcs = GitClient(settings)
	apt_src = AptClient(settings)
	client = DebianBuildClient (settings)

	while count < test_options["count"] and count < 10: # catch typos in the conf file
		count = count + 1
		for tag in tags :
			tag_run = "%s%s" % (tag, count)
			if tag_run not in test_options :
				print "E: missing config item in %s \"%s\"" % (testconf, tag_run)
				return -2
			if test_options[tag_run] == '' :
				test_options[tag_run] = None
			if tag == "vcs_id" :
				vcs_id = test_options[tag_run]
			elif tag == "method_type" :
				method_type = test_options[tag_run]
			elif tag == "suite" :
				suite = test_options[tag_run]
			elif tag == "package" :
				package = test_options[tag_run]
			elif tag == "version" :
				version = test_options[tag_run]
			elif tag == "architecture" :
				architecture = test_options[tag_run]
			elif tag == "source" :
				source = test_options[tag_run]
			elif tag == "uri" :
				uri = test_options[tag_run]
			elif tag == "pkg_format" :
				pkg_format = test_options[tag_run]
			elif tag == "distribution" :
				distribution = test_options[tag_run]
			elif tag == "commands" :
				commands = test_options[tag_run]
			elif tag == "role" :
				role = test_options[tag_run]
			else :
				print "E: unrecognised option: %s" % tag_run
				return -1
		logging.debug("I: starting test #%s (%s)" % (count, role))
		if commands is not None :
			logging.debug("I: test #%s requires a custom build command: '%s'" % (count, commands))
		test_arch = Arch(0, architecture)
		test_suite = Suite (0, suite)
		test_transport = Transport (0, method_type, uri, vcs_id)
		test_package = Package(0, version, package)
		test_packageinstance = PackageInstance(1, test_package, test_arch, test_suite, pkg_format, distribution, True)
		test_job =  Job(2, test_packageinstance,None)
		test_req = BuildRequest(test_job,test_transport,None,commands)
		test_req.stamp_request()
		# clean up in case the last test failed.
		if (method_type == "svn") :
			svn_vcs.clean_source(test_req, None)
			svn_vcs.fetch_source (test_req, None)
		if (method_type == "git") :
			git_vcs.clean_source(test_req, None)
			git_vcs.fetch_source (test_req, None)
		if (method_type == "apt") :
			apt_src.clean_source(test_req, None)
			apt_src.fetch_source(test_req, None)
		if (role == "slave"):
			# runs the build with --apt-update
			client.build_slave (test_req, None)
		else :
			# runs update_environment first
			client.build_master (test_req, None)
		client.upload (test_req, None)
		if (method_type == "svn") :
			svn_vcs.clean_source(test_req, None)
		if (method_type == "git") :
			git_vcs.clean_source(test_req, None)
		if (method_type == "apt") :
			apt_src.clean_source(test_req, None)
	return 0