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-20458 Allow File Access keys to be defined in the environment #12027

Merged
merged 1 commit into from Jan 16, 2019

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Jan 7, 2019

Add new CLI envmod for processing modification templates to modify
environment files.
Update modification template support.
Add unit tests for new features.

Signed-off-by: Ken Rowland kenneth.rowland@lexisnexisrisk.com

Refactoring and updates

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Testing:

@hpcc-jirabot
Copy link

@kenrowland
Copy link
Contributor Author

@jpmcmu Please review

Please let me know if you have any questions.

@AttilaVamos
Copy link
Contributor

@kenrowland Maybe I'm wrong, but this line looks like very suspicious to me:

#3  EnvironmentNode::getRoot (this=this@entry=0x0) at /mnt/disk1/home/vamosax/smoketest/PR-12027/HPCC-Platform/configuration/configmgr/configmgrlib/EnvironmentNode.cpp:506

especially this part: "this=this@entry=0x0"
As well as this:

#0  _M_get_use_count (this=0x30) at /usr/include/c++/4.8.2/bits/shared_ptr_base.h:672

where "this=0x30"

@kenrowland
Copy link
Contributor Author

kenrowland commented Jan 9, 2019

@AttilaVamos one important thing to note is that this all works on Ubuntu. It's also possible that my latest test has a problem

@AttilaVamos
Copy link
Contributor

@kenrowland I know.

@AttilaVamos
Copy link
Contributor

@kenrowland I should check something. Give me ~ half an hour.

@kenrowland
Copy link
Contributor Author

@AttilaVamos the failure on my last commit is a logic error. I did not test on Ubuntu, so consider it an invalid workaround.

@AttilaVamos
Copy link
Contributor

Well Done! (That's why we really need Smoketest and OBT.)

@kenrowland
Copy link
Contributor Author

kenrowland commented Jan 10, 2019

@AttilaVamos I agree! That's why once I figured out how to implement unit tests, I started adding them for all my code. I still have more I will be adding as time goes by so that when I make a change to core code, it's easy to test it.

One more commit coming to clean up.

@kenrowland kenrowland force-pushed the HPCC-20458 branch 2 times, most recently from 50b6cf8 to 18247a1 Compare January 14, 2019 16:28
Copy link
Contributor

@jpmcmu jpmcmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenrowland Looks good, a couple of comments

std::string inputName(input.FindMember("name")->value.GetString());
std::string type(input.FindMember("type")->value.GetString());
pInput = inputValueFactory(type, inputName);
std::string varName(varValue.FindMember("name")->value.GetString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the "name" and "type" members always exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are required by the schema.

// Get the count (optional, default is 1)
it = dataObj.FindMember("count");
if (it != dataObj.MemberEnd())
pOp->m_count = trim(it->value.GetString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like m_count is a string at this point. Would it be better to convert it to an int here to catch invalid number strings early?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because they could be substitution variables in the form {{varname}}. For that reason, they are kept in their raw for until used whereby a substitution and conversion to a number is done. At that time an exception, during execution of the template, can be thrown if there is a problem.

// Get the starting index (optional, for windowing into a range of values)
it = dataObj.FindMember("start_index");
if (it != dataObj.MemberEnd())
pOp->m_startIndex = trim(it->value.GetString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above for m_startIndex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment for m_count above.

rapidjson::Value::ConstMemberIterator saveInfoIt = dataObj.FindMember("save_nodeid");
if (saveInfoIt != dataObj.MemberEnd())
{
pOp->m_saveNodeIdName = saveInfoIt->value.GetObject().FindMember("save_name")->value.GetString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "save_name" guaranteed to exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is required by the schema if the save object exists.

saveInfoIt = attr.FindMember("save_value");
if (saveInfoIt != attr.MemberEnd())
{
newAttribute.saveValue = saveInfoIt->value.GetObject().FindMember("save_name")->value.GetString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question from above is "save_name" always present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same sub schema definition is use here as well.

if (!attr.saveValue.empty())
{
bool found=false, set=false;
std::shared_ptr<Variable> pInput = pInputs->getVariable(attr.saveValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can pInput be a nullptr here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Previously the attr.saveValue member would have been used to add an entry by that name to the Variables object. However, the getVariable method will throw an exception if the requested variable does not exist.

}
else
{
// if (!m_values.empty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep the commented out code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, no. I thought I had removed all the commented code, guess I missed this one. I will remove.

Add new CLI envmod for processing modification templates to modify
environment files.
Update modification template support.
Add unit tests for new features.

Signed-off-by: Ken Rowland <kenneth.rowland@lexisnexisrisk.com>
@HPCCSmoketest
Copy link
Contributor

Automated Smoketest: ✅
OS: centos 7.4.1708 (Linux 3.10.0-327.28.3.el7.x86_64)
Sha: 87af079
Build: success
Build: success
HPCC Start: OK

Unit tests result:

Test total passed failed errors timeout
unittest 101 101 0 0 0
wutoolTest(Dali) 19 19 0 0 0
wutoolTest(Cassandra) 19 19 0 0 0

Regression test result:

phase total pass fail
setup (hthor) 11 11 0
setup (thor) 11 11 0
setup (roxie) 11 11 0
test (hthor) 812 812 0
test (thor) 738 738 0
test (roxie) 886 886 0

HPCC Stop: OK
Time stats:

Prep time Build time Package time Install time Start time Test time Stop time Summary
31 sec (00:00:31) 189 sec (00:03:09) 0 sec (00:00:00) 2 sec (00:00:02) 18 sec (00:00:18) 1468 sec (00:24:28) 18 sec (00:00:18) 1726 sec (00:28:46)

@jpmcmu
Copy link
Contributor

jpmcmu commented Jan 15, 2019

@kenrowland looks good

@kenrowland
Copy link
Contributor Author

@richardkchapman Please merge

@richardkchapman richardkchapman merged commit 4b8d5ac into hpcc-systems:candidate-7.2.0 Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants