-
Notifications
You must be signed in to change notification settings - Fork 41
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
Build if-diff
core feature
#637
Comments
Thoughts on this tool so far
Generally we can't really refine this properly until we start collecting the manifests we want to use for testing in #615, understanding the different manifest test files will drive the requirements of the |
Some suggested acceptance criteria (with questions for @jawache or for discussion in spike call):
|
noting that after #615 is complete, @MariamKhalatova can turn attention to this and help design how this feature can be tested |
@jmcook1186 agreed, if-diff is a separate script in the if package.json (all of our tools should be separate scripts, if-diff, if-check, if-blitz, ie (if-run)) As discussed today. On matching
On cli
BUT if source is omitted it takes in source from stdin, that way it can be used in a linux pipeline like so.
if-check might then just be as simple as a bash file which runs this on every file in a folder.
On display if-diff should print out something like so on the difference it finds, perhaps something like the below but @jmcook1186 you should take a look at how other tools like diff display these kinds of differences: On a difference
On a deleted node (in target but not in source)
On an added node (in source but not in target)
|
There is a bit of a conflict between the idea to provide a matching status (content-match, tree-match etc) and the idea to exit on the first difference if-diff encounters. This is because this implies you need to know the matching tolerance in advance, maybe passing it as a piece of config, rather than having it being something returned by the tool. I think scrap the idea of having matching status as an outcome and instead make it config. On the CLI you could pass Then the return types are either SUCCESS or it reports the first identified error within your stated tolerance. Here's a breakdown of how I see it working: CLI details:
Tolerance rules:
Global matching rules
Output display format
|
@jmcook1186 I think at least for the MVP we need to support automated testing, there isn't a need to differentiate between tree, context anymore like we originally discussed. I think we're talking right now about just I'm not sure I fully understand the issue of why having both causes problems, but if we only have |
yes, I think that removing |
Updated ticket with acceptance criteria. Happy for this to go to @narekhovhannisyan to think about implementation details and give feedback on the spec. |
@jawache @jmcook1186 if we want to pipe the ie response to if-diff, then ie should return clean manifest without any logging. To do that we may have to add a logging flag. F.ex. |
@jmcook1186 as discussed let's add an AC that mirrors a negative testing manifest from the folder we created. |
@jmcook1186 please check over the acceptance criteria and updated SoW, I tried to add headings to separate out the scenarios, but got quite confused at the very and as I couldn't get where the last scenario starts, hope you can unpick that one, perhaps I have deleted too much? 🙏 |
yes some of the criteria have gotten scrambled between the issues. I'm cleaning it up now. |
if-diff
core featureif-diff
if-diff
if-diff
core feature
@MariamKhalatova can you please link all the bugs raised around this feature so we are aware of what's left to fix until it can be merged (or what can be deprioritised so it doesn't hold up the release). I've seen #726, are there more and how severe are they. I believe we agreed to do this last bug triage, let me know if you have any questions. |
@jmcook1186 please review @MariamKhalatova PR #721 |
Sub of: #629 -> #650
What
A command line utility that compares two manifest files and returns both a code and useful console logs for showing where two manifest files differ.
Why
As a user who needs to compare manifests files I would find it very useful to have a command line tool that can rapidly report whether two manifests are identical and if not how they differ.
Context
We can create a convenience tool for users to quickly see how manifests differ. This tool needs to be designed and specified before we start building. This ticket covers designing and documenting the tool prior to building.
The tool should be able to categorize differences, something along the lines of 'identical', tree match, context-match no-overlap or similar. The user should be able to get granular detail about where and how the manifests differ, similar to git diff.
CLI details:
if-diff
is a script separate fromie
- it is self contained and can be included inif/package.json
.if-diff
should take two arguments:--source
and--target
source
is the "test case" file that represents the source of truthtarget
is the file that is being compared againstsource
if-diff
should only be able to return eitherFILES MATCH
or the details of the first difference it encounters.if-diff
should be able to receive asource
from stdin as well as from a file path passed on the command line, e.g.ie --manifest source.yml | if-diff --target target.yml
if-diff
should emit an exit value:0
: files match1
: files did not match2
: some other error occurred during executionMatching rules
if-diff
should support wildcard characters (*
) that allow any value to count as a matchsource
includescpu-util: *
then bothcpu-util: 45
andcpu-util: 55
in the same position intarget
should be accepted as a match. Pass on any value - no need to check types etc here at the moment.Output display format
if-diff
finds no in-scope differences between thesource
andtarget
then it should return a success flag:FILES MATCH
and exit code0
.if-diff
detects an in-scope difference between the files, it should halt execution, return exit code1
and report the error to the command line. The report should include the yaml path to the differing element in the tree, the value in thesource
and the value in thetarget
, using the following schema:If the difference relates to a missing node in the tree for
source
ortarget
then<value in x file
> should be eitherexists
ormissing
and the yaml path should point to the highest level element that is missing (e.g. if an entire child component is missing, provide the path to the child component).e.g. difference values detected:
Prerequisites
Related Issues:
if-diff
#706if-diff
#707SoW
if-diff
outputs conform to the schema defined in therationale
section aboveif
reposirotyAcceptance Criteria
Scenario 1: Executing
if-diff
if-diff
exists as a standalone tool that comes bundled withif
if/package.json
if-diff
command--source
and--target
FILES MATCH
AND exit code0
OR a difference report describing the first error it encounters while comparing the two files AND exit code1
.Scenario 2: No change detected
if
WHEN they execute
if-diff --source manifest1.yml --target manifest2.yml
AND both
manifest1.yml
andmanifest2.yml
contain:THEN:
if-diff
should returnFILES MATCH
and exit code0
.Scenario 3: Change detected
GIVEN the user has downloaded and installed
if
WHEN they execute
if-diff --source manifest1.yml --target manifest2.yml
AND
manifest-1.yml
containsbut manifest-2.yml contains (different value for
energy/network
):THEN
if-diff
should emit exit code1
and returnScenario 4: Reading output
if-diff
can receive--source
data from stdin as well as a given filepathie --manifest example1.yml | if-diff --target example-target.yml
GIVEN a user has downloaded and installed
if
WHEN they run
if-diff --source manifest-1.yml --target manifest-2.yml
WITH
manifest-1.yml
containing:AND
manifest-2.yml
containsTHEN
if-diff
should emit exit code0
and returnFILES MATCH
.if-diff
conforms to the matching rules described above inrationale
sectione.g. for two manifests whose value in the posiiton
tree.children.vm1.inputs[3]['cpu/energy']
:for two manifests that have different nodes in their trees:
if-diff
can accept data fromstdin
instead of a file on diskif
WHEN they pipe the output from
ie
toif-diff
, for example using the following command:ie --manifest example1.yml --stdout| if-diff --target example-target.yml
THEN: they receive an
if-diff
output.The text was updated successfully, but these errors were encountered: