Skip to content

Commit

Permalink
fix devide by zero bug + do not bypass small intervals (#900)
Browse files Browse the repository at this point in the history
* adding tests

* NO GROUPING

* grouping fix

* lint

* do not bypass small intervals
  • Loading branch information
haim-kermany authored Oct 30, 2024
1 parent c5cdea5 commit 19feb8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pkg/drawio/layoutOverlap.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func (lyO *layoutOverlap) potentialBypassPoints(srcPoint, dstPoint, middlePoint
deltaX, deltaY := (srcPoint.X - dstPoint.X), (srcPoint.Y - dstPoint.Y)
disXY := int(math.Sqrt(float64(deltaX)*float64(deltaX) + float64(deltaY)*float64(deltaY)))
BPs := []point{}
if disXY <= 2*minSize {
// the points are too close, there is no point to bypass.
return BPs
}
for i := 0; i < nPotentialBP; i++ {
verticalVectorSize := pow(-1, i) * (1 + i/2) * iconSize
verticalVectorX := verticalVectorSize * deltaY / disXY
Expand Down
16 changes: 9 additions & 7 deletions pkg/ibmvpc/analysis_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,15 @@ var tests = []*testfunc.VpcAnalysisTest{
},
GroupingType: vpcmodel.GroupingNoConsistencyEdges,
},
// commented until https://github.com/np-guard/vpc-network-config-analyzer/issues/847 is fixed
// {
// InputConfig: "iks_workers_large",
// UseCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints},
// Grouping: true,
// Format: vpcmodel.DRAWIO,
// },
{
VpcTestCommon: testfunc.VpcTestCommon{
InputConfig: "iks_workers_large",
UseCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints},
Format: vpcmodel.DRAWIO,
},
GroupingType: vpcmodel.GroupingNoConsistencyEdges,
},

// Grouping test of identical names different resources and thus different UIDs that should not be merged
{
VpcTestCommon: testfunc.VpcTestCommon{
Expand Down

0 comments on commit 19feb8b

Please sign in to comment.