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

Use environment variables in config files #60 #80

Merged
merged 7 commits into from
Dec 28, 2021

Conversation

navinrathore
Copy link
Contributor

Feature to allow user to pass environment variables for the Zingg configuration values #60

@sonalgoyal
Copy link
Member

Junis are meant to be atomic. So you build tests like testBooleanVar teststringVar testIntegerVar testDataPipeFormat testOutputPipexxxx testDataPipeArrayFormat etc etc...go as many cases as you can think of, and combinations testBooleanStringxxxxx

the tests also need to address the specific issue - values of pipe properties

tests should also be there for malformed system var like $var or var$ - in case of boolean and int you should get exceptions, in other cases you should get exceptions again

and tests when something is referenced in json but not configured in env variable also need to be there.

@sonalgoyal
Copy link
Member

Also checkin comments need to be better - right now there are three commits with Use environment variables in config files. You can reference the issue in all commits, but the commit has to specify what is being changed too.

@navinrathore
Copy link
Contributor Author

The newly added testcases cover the above suggestions and other units/fragments of the the code changes. I tried to avoid redundant and out of scope scenarios.

@@ -54,7 +92,8 @@ public void testCreateArgsMissingMatchFile() {
}

@Test
public void testCreateArgsMissingDelimiterFile() {
Copy link
Member

Choose a reason for hiding this comment

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

remove these tests which are getting ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

matcher.appendReplacement(buffer, replacement != null ? Matcher.quoteReplacement(replacement) : "null");
}
else {
LOG.warn("The environment variable for {" + matcher.group(1) + "} is not set");
Copy link
Member

Choose a reason for hiding this comment

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

should we throw an exception 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.

Added Exception.

@navinrathore
Copy link
Contributor Author

Made changes as per comments and the discussion

Copy link
Member

@sonalgoyal sonalgoyal left a comment

Choose a reason for hiding this comment

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

Overall it is much better. few things

  • print at warn level which variables are getting substituted - only name, not value.
  • test that $var without an end $ throws an exception
  • is there a way to ensure or test non .env file has no substitutions.


fail("Exception was expected for blank value for an environment variable");
} catch (IOException | ZinggClientException e) {
System.out.println("Expected exception received due to blank value for an environment variable");
Copy link
Member

Choose a reason for hiding this comment

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

use logger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@navinrathore
Copy link
Contributor Author

Made changes to add Logger in Tests; Added message for substituted environment variables as well.

@sonalgoyal sonalgoyal merged commit 48c3532 into zinggAI:main Dec 28, 2021
@navinrathore navinrathore deleted the zEnvVarInConfig branch January 3, 2022 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants