Commit a98858d
authored
[GCU] Different apply-patch runs should produce same sorted steps (sonic-net#1988)
#### What I did
Fixes sonic-net#1976
Different runs of `apply-patch` would produce different sorted steps. It is better to be consistent while producing the sorted steps to make it easier to debug issues in the future.
The issue is with using `set(list)` to remove duplicates from the list. Looping over the set elements does not guarantee same order every time we iterate. To reproduce this do the following:
1. Create a file named `test.py` with the content
```python
x = ["XYZ", "ABC", "DEF"]
y = set(x)
print(y)
```
2. Run `python3 test.py`
3. Again `python3 test.py`
4. Again `python3 test.py`
The output of these runs will be different each time.
#### How I did it
Instead of returning a `set`, return a list of `ref_paths` which does not have duplicated elements inserted to begin with.
#### How to verify it
unit-tests
#### Previous command output (if the output of a command-line utility has changed)
#### New command output (if the output of a command-line utility has changed)1 parent 8c81ae3 commit a98858d
4 files changed
Lines changed: 69 additions & 32 deletions
File tree
- generic_config_updater
- tests/generic_config_updater
- files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| 417 | + | |
417 | 418 | | |
418 | 419 | | |
419 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
420 | 423 | | |
421 | | - | |
| 424 | + | |
422 | 425 | | |
423 | 426 | | |
424 | 427 | | |
| |||
Lines changed: 42 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
701 | | - | |
| 701 | + | |
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
| |||
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
755 | | - | |
| 755 | + | |
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
| |||
1331 | 1331 | | |
1332 | 1332 | | |
1333 | 1333 | | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
1334 | 1340 | | |
1335 | 1341 | | |
1336 | 1342 | | |
1337 | 1343 | | |
1338 | 1344 | | |
1339 | 1345 | | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1340 | 1355 | | |
1341 | 1356 | | |
1342 | 1357 | | |
1343 | | - | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
1344 | 1370 | | |
1345 | 1371 | | |
1346 | 1372 | | |
| |||
1349 | 1375 | | |
1350 | 1376 | | |
1351 | 1377 | | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1352 | 1385 | | |
1353 | 1386 | | |
1354 | 1387 | | |
| |||
2465 | 2498 | | |
2466 | 2499 | | |
2467 | 2500 | | |
2468 | | - | |
| 2501 | + | |
2469 | 2502 | | |
2470 | 2503 | | |
2471 | 2504 | | |
2472 | 2505 | | |
2473 | 2506 | | |
2474 | | - | |
| 2507 | + | |
2475 | 2508 | | |
2476 | 2509 | | |
2477 | 2510 | | |
2478 | 2511 | | |
2479 | 2512 | | |
2480 | | - | |
| 2513 | + | |
2481 | 2514 | | |
2482 | 2515 | | |
2483 | 2516 | | |
| |||
2490 | 2523 | | |
2491 | 2524 | | |
2492 | 2525 | | |
2493 | | - | |
| 2526 | + | |
2494 | 2527 | | |
2495 | 2528 | | |
2496 | 2529 | | |
2497 | 2530 | | |
2498 | 2531 | | |
2499 | 2532 | | |
2500 | | - | |
| 2533 | + | |
2501 | 2534 | | |
2502 | 2535 | | |
2503 | 2536 | | |
2504 | 2537 | | |
2505 | 2538 | | |
2506 | | - | |
| 2539 | + | |
2507 | 2540 | | |
2508 | 2541 | | |
2509 | 2542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
| 622 | + | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
| 635 | + | |
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | 641 | | |
646 | 642 | | |
| 643 | + | |
| 644 | + | |
647 | 645 | | |
648 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
| 655 | + | |
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | 661 | | |
667 | 662 | | |
668 | 663 | | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
675 | | - | |
| 675 | + | |
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1747 | 1747 | | |
1748 | 1748 | | |
1749 | 1749 | | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1750 | 1753 | | |
1751 | 1754 | | |
1752 | 1755 | | |
| |||
1762 | 1765 | | |
1763 | 1766 | | |
1764 | 1767 | | |
1765 | | - | |
1766 | | - | |
1767 | | - | |
| 1768 | + | |
1768 | 1769 | | |
1769 | 1770 | | |
1770 | 1771 | | |
| |||
1787 | 1788 | | |
1788 | 1789 | | |
1789 | 1790 | | |
1790 | | - | |
| 1791 | + | |
1791 | 1792 | | |
1792 | 1793 | | |
1793 | 1794 | | |
| |||
1831 | 1832 | | |
1832 | 1833 | | |
1833 | 1834 | | |
1834 | | - | |
| 1835 | + | |
1835 | 1836 | | |
1836 | 1837 | | |
1837 | 1838 | | |
| |||
0 commit comments