Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-30517 Add lfn external unit tests #17901

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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