/** Beautify and convert an HTTP error to a Test exception */ private HoneycombTestException makeTestException(String tag, String url, HTTPResponse response) { int status = 0; String msg = null; List st = new LinkedList(); List output = new LinkedList(); try { output.add(new String(response.getData())); status = response.getStatusCode(); String reason = URLEncoder.decode(response.getReasonLine()); st.add(reason); msg = tag + " error " + status + ": " + reason; Log.INFO(msg); } catch (Exception e) { e.printStackTrace(); msg = e.getMessage(); } HoneycombTestException e = new HoneycombTestException(msg); e.exitStatus = new ExitStatus(url, status, output, st); return e; }
/** Run the metadata test to see if it discovers any errors. */ public boolean testMetadata() throws Throwable { addTag(Tag.POSITIVE); addTag(HoneycombTag.QUERY); addTag(HoneycombTag.JAVA_API); // addTag(Tag.QUICK); // addTag(Tag.REGRESSION); // addTag(Tag.SMOKE); if (excludeCase()) return false; TestMetadata Metadata = new TestMetadata(); String args[] = {"-s", testBed.getDataVIP(), "-p", "" + testBed.getDataPort(), "-T"}; try { Metadata.main(args); } catch (HoneycombTestException hte) { // Look at the exception message to see if it passed or failed String rc = hte.getMessage(); Log.DEBUG("Result is " + rc); if (!rc.equals(TestRun.PASS)) { Log.ERROR("Test failed...see stdout"); return (false); } } return (true); }
/** Check for the existence of a webdav URL. */ public boolean exists(String url) throws HoneycombTestException { try { CmdResult rc = getFile(url, false); return true; } catch (HoneycombTestException e) { if (e.getMessage().startsWith("getFile error 404")) return false; throw e; } }
/** Retrieve a file. */ public boolean testBRetrieveAfterStore() { if (!setupOK) addTag(Tag.MISSINGDEP, "failed some dependency"); addTag(Tag.SMOKE); addTag(Tag.REGRESSION); addTag(Tag.QUICK); addTag(Tag.SMOKE); addTag(HoneycombTag.RETRIEVEDATA); addTag(HoneycombTag.JAVA_API); addTag(HoneycombTag.EMULATOR); if (excludeCase()) return false; CmdResult cr; try { cr = retrieve(storeResult.mdoid); Log.INFO( "Retrieved oid " + storeResult.mdoid + " @ " + (cr.filesize * 1000 / cr.time) + " bytes/sec"); } catch (HoneycombTestException hte) { Log.ERROR("Retrieve failed [oid " + storeResult.mdoid + "]: " + hte.getMessage()); Log.DEBUG(Log.stackTrace(hte)); return (false); } if (TestBed.doHash) { try { verifyFilesMatch(storeResult, cr); Log.INFO("Retrieved file matched stored file"); } catch (HoneycombTestException hte) { Log.ERROR("verifyFilesMatch failed: " + hte.getMessage()); return (false); } } else Log.INFO("skipping hash check"); return (true); }