Skip to content

Commit

Permalink
Merge pull request #17901 from jakesmith/HPCC-30517-lfn-external-unit…
Browse files Browse the repository at this point in the history
…tests

HPCC-30517 Add lfn external unit tests

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Oct 19, 2023
2 parents 9cab6fd + d27e138 commit 7d8b69a
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions testing/unittests/dalitests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2782,6 +2782,14 @@ class CDaliUtils : public CppUnit::TestFixture
{ "~remote::dfs1::ascope::afile", "remote::dfs1::ascope"},
{ nullptr, nullptr } // terminator
};

const char *externalUrlChecks[][2] = {
{ "~file::127.0.0.1::var::lib::^H^P^C^C^Systems::mydropzone::ascope::afile", "/var/lib/HPCCSystems/mydropzone/ascope/afile"},
{ "~file::10.3.2.1::var::lib::^H^P^C^C^Systems::mydropzone::ascope::afile", "//10.3.2.1/var/lib/HPCCSystems/mydropzone/ascope/afile"},
{ "~plane::mydropzone::ascope::afile", "/var/lib/HPCCSystems/mydropzone/ascope/afile"},
{ "~plane::dropzone2::ascope::afile", "//10.4.3.2/var/lib/HPCCSystems/mydropzone/ascope/afile"},
{ nullptr, nullptr } // terminator
};
PROGLOG("Checking valid logical filenames");
unsigned nlfn=0;
for (;;)
Expand Down Expand Up @@ -2866,6 +2874,59 @@ class CDaliUtils : public CppUnit::TestFixture
CPPUNIT_FAIL(err.str());
}
}

constexpr const char * globalConfigYaml = R"!!(
storage:
planes:
- name: data
category: data
prefix: /var/lib/HPCCSystems/hpcc-data
- name: mydropzone
category: lz
prefix: /var/lib/HPCCSystems/mydropzone
- name: dropzone2
category: lz
prefix: /var/lib/HPCCSystems/mydropzone
hosts:
- 10.4.3.2
)!!";
Owned<IPropertyTree> globalConfig = createPTreeFromYAMLString(globalConfigYaml);
replaceComponentConfig(getComponentConfigSP(), globalConfig);

PROGLOG("Checking physical file paths");
nlfn = 0;
for (;;)
{
const char **entry = externalUrlChecks[nlfn++];
if (nullptr == entry[0])
break;
const char *lfn = entry[0];
const char *expected = entry[1];
PROGLOG("lfn = %s, expect = %s", lfn, expected);
CDfsLogicalFileName dlfn;
StringBuffer err;
try
{
dlfn.set(lfn);
RemoteFilename rfn;
dlfn.getExternalFilename(rfn);
StringBuffer filePath;
rfn.getPath(filePath);
if (!streq(filePath, expected))
err.appendf("Logical filename '%s' external url should be '%s', but result was '%s'.", lfn, expected, filePath.str());
}
catch (IException *e)
{
err.appendf("Logical filename '%s' failed: ", lfn);
e->errorMessage(err);
e->Release();
}
if (err.length())
{
ERRLOG("%s", err.str());
CPPUNIT_FAIL(err.str());
}
}
}
};

Expand Down

0 comments on commit 7d8b69a

Please sign in to comment.