From 4dd71657a096a2e436225cf33a0f406950c31302 Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Thu, 17 Aug 2023 10:52:52 -0400 Subject: [PATCH] JAPI-524 Address wsfileio/wsfs junit failures - Ignores invalid fileio tests until HPCC_30117 is addressed - WsFS conditionally provides DZ path and name if available Signed-off-by: Rodrigo Pastrana --- .../ws/client/HPCCFileSprayClient.java | 13 ++++++++++- .../ws/client/WSFileIOClientTest.java | 23 +++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java index 212bb281c..87d0c5d61 100644 --- a/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java +++ b/wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java @@ -1481,7 +1481,18 @@ public boolean uploadLargeFile(File uploadFile, DropZoneWrapper dropZone) URLConnection fileUploadConnection = null; URL fileUploadURL = null; String uploadurlbuilder = UPLOADURI; - uploadurlbuilder += "&NetAddress=" + dropZone.getNetAddress(); + + if (dropZone.getPath().isEmpty()) + { + log.error("HPCCFileSprayClient::uploadLargeFile: empty dropZone path detected!"); + return false; + } + + uploadurlbuilder += "&NetAddress=" + dropZone.getNetAddress() + "&Path=" + dropZone.getPath(); + + if (!dropZone.getName().isEmpty()) + uploadurlbuilder += "&DropZoneName=" + dropZone.getName(); + String path = dropZone.getPath().trim(); if (!path.endsWith("/")) path += "/"; diff --git a/wsclient/src/test/java/org/hpccsystems/ws/client/WSFileIOClientTest.java b/wsclient/src/test/java/org/hpccsystems/ws/client/WSFileIOClientTest.java index ac8c9e7b9..236ddeb70 100644 --- a/wsclient/src/test/java/org/hpccsystems/ws/client/WSFileIOClientTest.java +++ b/wsclient/src/test/java/org/hpccsystems/ws/client/WSFileIOClientTest.java @@ -19,6 +19,7 @@ HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®. import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; import java.util.HashSet; import java.util.Set; @@ -44,6 +45,8 @@ public class WSFileIOClientTest extends BaseRemoteTest private final static String testfilename = System.getProperty("lztestfile", "myfilename.txt"); private final static String targetLZ = System.getProperty("lzname", "localhost"); + private final static String targetLZPath = System.getProperty("lzpath", "/var/lib/HPCCSystems/mydropzone"); + private final static String HPCC_30117 = System.getProperty("HPCC30117", "fixed"); static { @@ -52,13 +55,21 @@ public class WSFileIOClientTest extends BaseRemoteTest if (System.getProperty("lzname") == null) System.out.println("lzname not provided - defaulting to localhost"); + + if (System.getProperty("lzpath") == null) + System.out.println("lzpath not provided - defaulting to /var/lib/HPCCSystems/mydropzone"); + + if (System.getProperty("HPCC30117") == null) + System.out.println("HPCC30117 status not provided - defaulting to fixed"); + else + System.out.println("HPCC30117 status: '" + HPCC_30117 + "'"); } @Test public void copyFile() throws Exception { Assume.assumeFalse("Test not valid on containerized HPCC environment", client.isTargetHPCCContainerized()); - + assumeTrue("Ignoring test 'copyFile' because HPCC-30117 is not fixed", HPCC_30117.equalsIgnoreCase("fixed")); String lzfile=System.currentTimeMillis() + "_csvtest.csv"; String hpccfilename="temp::" + lzfile; client.createHPCCFile(lzfile, targetLZ, true); @@ -135,23 +146,27 @@ public void copyFile() throws Exception public void AcreateHPCCFile() throws Exception, ArrayOfEspExceptionWrapper { Assume.assumeFalse("Test not valid on containerized HPCC environment", client.isTargetHPCCContainerized()); - + assumeTrue("Ignoring test 'copyFile' because HPCC-30117 is not fixed", HPCC_30117.equalsIgnoreCase("fixed")); System.out.println("Creating file: '" + testfilename + "' on LandingZone: '" + targetLZ + "' on HPCC: '" + super.connString +"'"); - Assert.assertTrue(client.createHPCCFile(testfilename, targetLZ, true)); + //At some point, wsfileio writedata made it necessary to fully qualify the filename + Assert.assertTrue(client.createHPCCFile(targetLZPath + "/" + testfilename, targetLZ, true)); } @Test public void BwriteHPCCFile() throws Exception, ArrayOfEspExceptionWrapper { + assumeTrue("Ignoring test 'copyFile' because HPCC-30117 is not fixed", HPCC_30117.equalsIgnoreCase("fixed")); System.out.println("Writing data to file: '" + testfilename + "' on LandingZone: '" + targetLZ + "' on HPCC: '" + super.connString +"'"); byte[] data = "HELLO MY DARLING, HELLO MY DEAR!1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ".getBytes(); - Assert.assertTrue(client.writeHPCCFileData(data, testfilename, targetLZ, true, 0, 20)); + //At some point, wsfileio writedata made it necessary to fully qualify the filename + Assert.assertTrue(client.writeHPCCFileData(data, targetLZPath + "/" + testfilename, targetLZ, true, 0, 20)); } @Test public void CreadHPCCFile() throws Exception, ArrayOfEspExceptionWrapper { Assume.assumeFalse("Test not valid on containerized HPCC environment", client.isTargetHPCCContainerized()); + assumeTrue("Ignoring test 'copyFile' because HPCC-30117 is not fixed", HPCC_30117.equalsIgnoreCase("fixed")); System.out.println("reading data from file: '" + testfilename + "' on LandingZone: '" + targetLZ + "' on HPCC: '" + super.connString +"'"); byte[] data = "HELLO MY DARLING, HELLO MY DEAR!1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ".getBytes();