def test_PLPERL91010_super_untrust(self): """ Language PL/PERL upgrade to 9.1:File system operations are allowed for untrusted PL/PERL """ if self.checkAPPHOMEandLIB("plperl"): print 'installation' gp_procedural_languages().installPL('plperlu') tmpfilename = local_path('plperl91/plsuperuser.tmp') tmpfile = '' for i in tmpfilename: if i == '/': tmpfile = tmpfile + '\/' else: tmpfile = tmpfile + i tmpfilename = tmpfile localpath = local_path('') if sys.platform == 'sunos5': cmd = 'sed \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql > %s/plperl91/test010_super_untrust.sql.tmp && mv %s/plperl91/test010_super_untrust.sql.tmp %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath, localpath, localpath, localpath) elif sys.platform == 'darwin': cmd = 'sed -i \'\' \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath) else: cmd = 'sed -i \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath) os.system(cmd) self.doPLPERLUbyuser("plperl91/test010_super_untrust", 'plsuperuser') checkcmd = 'cat ' + tmpfilename res = {'rc': 0, 'stdout': '', 'stderr': ''} run_shell_command(checkcmd, 'run command %s' % checkcmd, res) if res['rc']: raise Exception("Unable to open created file")
def doPLJAVA(self, num, filename, default="-a"): """ run PL/JAVA test case """ # If JAVA_HOME is set, then run PL/Java # Also check whether pljava.so is install in $GPHOME/lib/postgresql init_file_list = [] init_file = local_path('pljava/init_file') init_file_list.append(init_file) if self.checkAPPHOMEandLIB("pljava", "JAVA_HOME"): # If JDK is not 1.6 and up, then raise error res = {'rc': 0, 'stdout': '', 'stderr': ''} run_shell_command("java -version 2>&1", 'check java version', res) out = res['stdout'].split('\n') if out[0].find("1.6.") > 0: gp_procedural_languages().installPL('pljava') self.doTest(num, filename, default=default, match_sub=init_file_list) else: raise Exception( "Requires JDK 1.6 and up, your current version is :%s" % (out[0])) else: # If JAVA_HOME is not set, then raise error if not os.environ.get("JAVA_HOME"): raise Exception("JAVA_HOME is not set")
def test_PLPERL91010_super_untrust(self): """ Language PL/PERL upgrade to 9.1:File system operations are allowed for untrusted PL/PERL """ if self.checkAPPHOMEandLIB("plperl"): print 'installation' gp_procedural_languages().installPL('plperlu') tmpfilename = local_path('plperl91/plsuperuser.tmp') tmpfile = '' for i in tmpfilename: if i == '/': tmpfile = tmpfile + '\/' else: tmpfile = tmpfile + i tmpfilename = tmpfile localpath = local_path('') if sys.platform == 'sunos5': cmd = 'sed \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql > %s/plperl91/test010_super_untrust.sql.tmp && mv %s/plperl91/test010_super_untrust.sql.tmp %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath, localpath, localpath, localpath) elif sys.platform == 'darwin': cmd = 'sed -i \'\' \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath ) else: cmd = 'sed -i \'s/TMPFILENAME/%s/g\' %s/plperl91/test010_super_untrust.sql' % ( tmpfilename, localpath ) os.system( cmd ) self.doPLPERLUbyuser("plperl91/test010_super_untrust", 'plsuperuser') checkcmd = 'cat ' + tmpfilename res = {'rc': 0, 'stdout' : '', 'stderr': ''} run_shell_command(checkcmd, 'run command %s'%checkcmd, res) if res['rc']: raise Exception("Unable to open created file")
def doPLPYTHONU(self, num, filename, default='-a'): """ run PL/PYTHONU test case """ # Check if plpython.so is installed in $GPHOME/lib/postgresql if self.checkAPPHOMEandLIB("plpython"): gp_procedural_languages().installPL('plpythonu') self.doTest(num, filename, default=default) else: self.skipTest('skipping test: plpython.so is not installed in $GPHOME/lib/postgresql')
def doPLPGSQL(self, num, filename, default="-a"): """ run PL/PGSQL test case """ # Check if plpgsql.so is installed in $GPHOME/lib/postgresql if self.checkAPPHOMEandLIB("plpgsql"): gp_procedural_languages().installPL('plpgsql') self.doTest(num, filename, default=default) else: self.skipTest('skipping test: not found plpgsql.so installed in $GPHOME/lib/postgresql')
def doPLR(self, num, filename, default="-a"): """ run PL/R test case """ # If R_HOME is set, then run PL/R # Also check whether plr.so is install in $GPHOME/lib/postgresql if self.checkAPPHOMEandLIB("plr","R_HOME"): gp_procedural_languages().installPL('plr') self.doTest(num, filename, default=default) else: self.skipTest('skipping test: not plr.so found in $GPHOME/lib/postgresql')
def doPLPERLUbyuser(self, filename, user): """ run PL/PERLU test case """ # Check if plperl.so is installed in $GPHOME/lib/postgresql if self.checkAPPHOMEandLIB("plperl"): gp_procedural_languages().installPL('plperlu') sql_file = local_path('%s.sql' % (filename)) out_file = local_path('%s.out' % (filename)) ans_file = local_path('%s.ans' % (filename)) PSQL.run_sql_file(sql_file = sql_file, out_file = out_file, flags='-e', username=user) self.assertTrue(Gpdiff.are_files_equal(out_file, ans_file)) else: self.skipTest('skipping test: plperl.so is not installed in $GPHOME/lib/postgresql')
def doPLJAVAU(self, num, filename, default="-a"): """ run PL/JAVAU test case """ # If JAVA_HOME is set, then run PL/Java # Also check whether pljava.so is install in $GPHOME/lib/postgresql if self.checkAPPHOMEandLIB("pljava", "JAVA_HOME"): # If JDK is not 1.6 and up, then raise error res = {'rc': 0, 'stdout' : '', 'stderr': ''} run_shell_command("java -version 2>&1", 'check java version', res) if res['stdout'][0].find("1.6.")>0: gp_procedural_languages().installPL('pljavau') self.doTest(num, filename, default=default) else: raise Exception("Requires JDK 1.6 and up, your current version is :%s" % (out[0])) else: # If JAVA_HOME is not set, then raise error if not os.environ.get("JAVA_HOME"): raise Exception("JAVA_HOME is not set")
def doSQL(self, num, filename, default='-a'): """ run SQL test case """ # Run test cases for procedure language SQL gp_procedural_languages().installPL('sql') self.doTest(num, filename, default=default)