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

211 vsis #227

Merged
merged 38 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
78401ee
structs and main functionality of https://github.com/np-guard/vpc-net…
ShiriMoran Oct 12, 2023
9a4f947
Highlevel code and structs
ShiriMoran Oct 15, 2023
15970f4
subnetConnectivitySubtract code; still needs to fill inside functiona…
ShiriMoran Oct 16, 2023
9400063
Redefined made the connection set diff and added todos
ShiriMoran Oct 17, 2023
bf18d01
Minor reorgs
ShiriMoran Oct 17, 2023
625fa41
Export SubnetConnectivityMap and enable external creation for unit test
ShiriMoran Oct 17, 2023
d2fbe4e
Added grouping subnet unittesting as preliminery stage to writing uni…
ShiriMoran Oct 18, 2023
823503e
exporting functionality for unit test; SubnetConnectivitySubtract sho…
ShiriMoran Oct 18, 2023
769eb7a
semantic diff simple unit test
ShiriMoran Oct 18, 2023
5a652cc
improved semantic diff computation
ShiriMoran Oct 18, 2023
f735908
fixed a bug/typo, added ad-hoc printing functionality
ShiriMoran Oct 18, 2023
20b4e98
unit test written for current functionality
ShiriMoran Oct 18, 2023
ce31dda
lint comments
ShiriMoran Oct 19, 2023
6b0897b
Merge remote-tracking branch 'origin/main'
ShiriMoran Oct 23, 2023
cdeff24
Merge remote-tracking branch 'origin/main'
ShiriMoran Oct 31, 2023
b9220e6
Merge remote-tracking branch 'origin/main'
ShiriMoran Nov 6, 2023
027d643
Merge remote-tracking branch 'origin/main'
ShiriMoran Nov 7, 2023
f315fb0
Merge remote-tracking branch 'origin/main'
ShiriMoran Nov 8, 2023
2d45e42
Merge remote-tracking branch 'origin/main'
ShiriMoran Nov 8, 2023
c4b7c2d
Merge remote-tracking branch 'origin/main'
ShiriMoran Nov 12, 2023
6b5be67
the diff is no longer limited to subnet - relevant renaming
ShiriMoran Nov 12, 2023
78fd54f
Option to call Vsis diff added
ShiriMoran Nov 12, 2023
435b9bc
extended support in code to include VSIs; some more renaming
ShiriMoran Nov 13, 2023
07a21d3
more renaming
ShiriMoran Nov 13, 2023
db9a030
unit test added
ShiriMoran Nov 13, 2023
c56492f
lint comments
ShiriMoran Nov 13, 2023
75b0182
added end-to-end support and test for vsis diff (endpoints diff)
ShiriMoran Nov 14, 2023
5378e3b
lint
ShiriMoran Nov 14, 2023
070ccd3
CR comments 1
ShiriMoran Nov 16, 2023
65ed510
CR comments 2
ShiriMoran Nov 16, 2023
81af2c2
Update pkg/vpcmodel/output.go
ShiriMoran Nov 16, 2023
db16e99
CR comments 3
ShiriMoran Nov 16, 2023
e826276
CR comments 4
ShiriMoran Nov 16, 2023
ba225dd
CR comments 5
ShiriMoran Nov 16, 2023
bce67ed
CR comments 6
ShiriMoran Nov 16, 2023
0c0e5d1
lint comment
ShiriMoran Nov 16, 2023
9fd1e96
should be commented - the uncommented code was committed by mistake
ShiriMoran Nov 16, 2023
d06f80d
CR comment
ShiriMoran Nov 16, 2023
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
4 changes: 3 additions & 1 deletion cmd/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func analysisTypeToUseCase(inArgs *InArgs) vpcmodel.OutputUseCase {
case allSubnets:
return vpcmodel.AllSubnets
case allSubnetsDiff:
return vpcmodel.AllSubnetsDiff
return vpcmodel.SubnetsDiff
case allEndpointsDiff:
return vpcmodel.EndpointsDiff
}
return vpcmodel.AllEndpoints
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/analyzer/parse_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var supportedAnalysisTypes = map[string]bool{
allSubnets: true,
singleSubnet: true,
allSubnetsDiff: true,
allEndpointsDiff: false,
allEndpointsDiff: true,
}

func getSupportedValuesString(supportedValues map[string]bool) string {
Expand Down
84 changes: 49 additions & 35 deletions pkg/ibmvpc/analysis_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
suffixOutFileSubnetsLevel = "subnetsBased_withPGW"
suffixOutFileSubnetsLevelNoPGW = "subnetsBased_withoutPGW"
suffixOutFileDiffSubnets = "subnetsDiff"
suffixOutFileDiffEndpoints = "endpointsDiff"
txtOutSuffix = ".txt"
debugOutSuffix = "_debug.txt"
mdOutSuffix = ".md"
Expand Down Expand Up @@ -95,29 +96,38 @@ func getTestFileName(testName string,
res = baseName + suffixOutFileSubnetsLevel
case vpcmodel.AllSubnetsNoPGW:
res = baseName + suffixOutFileSubnetsLevelNoPGW
case vpcmodel.AllSubnetsDiff:
case vpcmodel.SubnetsDiff:
res = baseName + suffixOutFileDiffSubnets
case vpcmodel.EndpointsDiff:
res = baseName + suffixOutFileDiffEndpoints
}
suffix, suffixErr := getTestFileSuffix(format)
if suffixErr != nil {
return "", "", suffixErr
}
res += suffix
expectedFileName = res
actualFileName = actualOutFilePrefix + res
return expectedFileName, actualFileName, nil
}

func getTestFileSuffix(format vpcmodel.OutFormat) (suffix string, err error) {
switch format {
case vpcmodel.Text:
res += txtOutSuffix
return txtOutSuffix, nil
case vpcmodel.Debug:
res += debugOutSuffix
return debugOutSuffix, nil
case vpcmodel.MD:
res += mdOutSuffix
return mdOutSuffix, nil
case vpcmodel.JSON:
res += jsonOutSuffix
return jsonOutSuffix, nil
case vpcmodel.DRAWIO:
res += drawioOutSuffix
return drawioOutSuffix, nil
case vpcmodel.ARCHDRAWIO:
res += archDrawioOutSuffix
return archDrawioOutSuffix, nil
default:
return "", "", errors.New("unexpected out format")
return "", errors.New("unexpected out format")
}

expectedFileName = res
actualFileName = actualOutFilePrefix + res
return expectedFileName, actualFileName, nil
}

// initTest: based on the test name, set the input config file name, and the output
Expand Down Expand Up @@ -336,35 +346,39 @@ var tests = []*vpcGeneralTest{
format: vpcmodel.Text,
},
{
name: "acl_testing5",
// TODO: currently for this test, there are 2 connections that only differ in statefulness attribute, and
// are not yet displayed in the diff report (sub1-1-ky => sub1-2-ky , sub1-1-ky => sub1-3-ky)
useCases: []vpcmodel.OutputUseCase{vpcmodel.AllSubnetsDiff},
name: "acl_testing5",
useCases: []vpcmodel.OutputUseCase{vpcmodel.SubnetsDiff},
format: vpcmodel.Text,
},
{
name: "acl_testing3",
useCases: []vpcmodel.OutputUseCase{vpcmodel.EndpointsDiff},
format: vpcmodel.Text,
},
}

var formatsAvoidComparison = map[vpcmodel.OutFormat]bool{vpcmodel.ARCHDRAWIO: true, vpcmodel.DRAWIO: true}

// uncomment the function below to run for updating the expected output
/*var formatsAvoidOutputGeneration = map[vpcmodel.OutFormat]bool{vpcmodel.ARCHDRAWIO: true, vpcmodel.DRAWIO: true}
func TestAllWithGeneration(t *testing.T) {
// tests is the list of tests to run
for testIdx := range tests {
tt := tests[testIdx]
// todo - remove the following if when drawio is stable
if formatsAvoidOutputGeneration[tt.format] {
tt.mode = outputIgnore
} else {
tt.mode = outputGeneration
}
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tt.runTest(t)
})
}
fmt.Println("done")
}*/
// var formatsAvoidOutputGeneration = map[vpcmodel.OutFormat]bool{vpcmodel.ARCHDRAWIO: true, vpcmodel.DRAWIO: true}
//
// func TestAllWithGeneration(t *testing.T) {
// // tests is the list of tests to run
// for testIdx := range tests {
// tt := tests[testIdx]
// // todo - remove the following if when drawio is stable
// if formatsAvoidOutputGeneration[tt.format] {
// tt.mode = outputIgnore
// } else {
// tt.mode = outputGeneration
// }
// t.Run(tt.name, func(t *testing.T) {
// t.Parallel()
// tt.runTest(t)
// })
// }
// fmt.Println("done")
//}

func TestAllWithComparison(t *testing.T) {
// tests is the list of tests to run
Expand Down Expand Up @@ -407,7 +421,7 @@ func (tt *vpcGeneralTest) runTest(t *testing.T) {
var vpcConfigs2nd map[string]*vpcmodel.VPCConfig
diffUseCase := false
for _, useCase := range tt.useCases {
if useCase == vpcmodel.AllSubnetsDiff {
if useCase == vpcmodel.SubnetsDiff || useCase == vpcmodel.EndpointsDiff {
diffUseCase = true
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/ibmvpc/examples/acl_testing3endpointsDiff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Analysis for diff between VPC test-vpc1-ky and VPC test-vpc2-ky
diff-type: removed, source: vsi1-ky[10.240.10.4], destination: Public Internet [161.26.0.0/16], config1: protocol: UDP *, config2: No connection, vsis-diff-info:
diff-type: removed, source: vsi1-ky[10.240.10.4], destination: vsi2-ky[10.240.20.4], config1: protocol: TCP,UDP, config2: No connection, vsis-diff-info:
Loading
Loading