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

refactor: create otaclient_common._io module for holding io related helper funcs #397

Merged
merged 30 commits into from
Oct 19, 2024

Conversation

Bodong-Yang
Copy link
Member

@Bodong-Yang Bodong-Yang commented Oct 10, 2024

Introduction

This PR introduces a new module otaclient_common._io for holding io related helper functions with refinement.

Especially, this modules provides the following new features/changes:

  1. implement new cal_file_digest helper function, based on python stdlib file_digest.
  2. a new write_str_to_file_atomic method, replacing the old write_str_to_file, which uses the rename syscall to atomically update target file. This function is intended for writing critical config files like boot cfg files, and it is much robust to unexpected interruption, ensured by kernel rename syscall.
  3. refined symlink_atomic func.
  4. new copyfile_atomic func.

Tests

  • test file(s) that covers the change(s) is implemented.
  • local test is passed.
  • OTA test with VM passed.

@Bodong-Yang Bodong-Yang added the refactor Rewrite/remove related code instead of patching them label Oct 10, 2024
@Bodong-Yang Bodong-Yang changed the title feat: create otaclient_common._io module for holding io related helper funcs refactor: create otaclient_common._io module for holding io related helper funcs Oct 10, 2024
Copy link
Contributor

github-actions bot commented Oct 19, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/ota_metadata/legacy
   __init__.py110100% 
   parser.py3353888%100, 156, 161, 197–198, 208–209, 212, 224, 282, 292–295, 334–337, 417, 420, 428–430, 443, 452–453, 456–457, 669–670, 673, 700–702, 752, 755–757
   types.py841384%37, 40–42, 112–116, 122–125
src/ota_proxy
   __init__.py361072%59, 61, 63, 72, 81–82, 102, 104–106
   __main__.py770%16–18, 20, 22–23, 25
   _consts.py150100% 
   cache_control_header.py68494%71, 91, 113, 121
   cache_streaming.py1422284%154–156, 184–186, 211, 225, 229–230, 265–266, 268, 280, 348, 354–355, 358, 366–369
   config.py170100% 
   db.py731875%109, 115, 153, 159–160, 163, 169, 171, 192–199, 201–202
   errors.py50100% 
   lru_cache_helper.py47295%84–85
   ota_cache.py2155972%70–71, 140, 151–152, 184–185, 202, 239–243, 247–249, 251, 253–260, 262–264, 267–268, 272–273, 277, 324, 332–334, 413–416, 430, 433–434, 448–449, 451–453, 457–458, 464–465, 496, 502, 529, 581–583
   server_app.py1393971%76, 79, 85, 101, 103, 162, 171, 213–214, 216–218, 221, 226–228, 231–232, 235, 238, 241, 244, 257–258, 261–262, 264, 267, 293–296, 299, 313–315, 321–323
   utils.py140100% 
src/otaclient
   __init__.py5260%17, 19
   __main__.py110%16
   log_setting.py52590%53, 55, 64–66
src/otaclient/app
   __main__.py110%16
   configs.py760100% 
   errors.py1200100% 
   interface.py30100% 
   main.py46589%52–53, 75–77
   ota_client.py37310871%79, 87, 108, 135, 137–138, 140, 144, 148–149, 154–155, 161, 163, 201–204, 210, 214, 220, 339, 351–352, 354, 363, 366, 371–372, 375, 381, 383–387, 406–409, 412–419, 447–450, 496–497, 501, 503–504, 534–535, 544–551, 558, 561–567, 612–615, 623, 659–661, 666–668, 671–672, 674–675, 677, 735–736, 739, 747–748, 751, 762–763, 766, 774–775, 778, 789, 808, 835, 854, 872
   ota_client_stub.py39310972%75–77, 79–80, 88–91, 94–96, 100, 105–106, 108–109, 112, 114–115, 118–120, 123–124, 127–129, 134–139, 143, 146–150, 152–153, 161–163, 166, 203–205, 210, 246, 271, 274, 277, 381, 405, 407, 431, 477, 534, 604–605, 644, 663–665, 671–674, 678–680, 687–689, 692, 696–699, 752, 841–843, 850, 880–881, 884–888, 897–906, 913, 919, 922–923, 927, 930
   update_stats.py104991%57, 103, 105, 114, 116, 125, 127, 148, 179
src/otaclient/boot_control
   __init__.py40100% 
   _common.py24911255%70–71, 92–94, 110–111, 131–132, 151–152, 171–172, 191–192, 214–216, 231–232, 256–262, 283, 291, 309, 317, 336–337, 340–341, 364, 366–375, 377–386, 388–390, 409, 412, 420, 428, 444–446, 448–453, 546, 551, 556, 669, 673–674, 677, 684, 686–687, 713–714, 716–719, 724, 730–731, 734–735, 737, 744–745, 756–762, 772–774, 778–779, 782–783, 786, 792
   _firmware_package.py942276%83, 87, 137, 181, 187, 210–211, 214–219, 221–222, 225–230, 232
   _grub.py41812869%216, 264–267, 273–277, 314–315, 322–327, 330–336, 339, 342–343, 348, 350–352, 361–367, 369–370, 372–374, 383–385, 387–389, 468–469, 473–474, 526, 532, 558, 580, 584–585, 600–602, 626–629, 641, 645–647, 649–651, 710–713, 738–741, 764–767, 779–780, 783–784, 819, 825, 845–846, 848, 860, 863, 866, 869, 873–875, 893–896, 924–927, 932–940, 945–953
   _jetson_cboot.py2632630%20, 22–25, 27–29, 35–39, 41–42, 58–59, 61, 63–64, 70, 74, 133, 136, 138–139, 142, 149–150, 158–159, 162, 168–169, 177, 186–190, 192, 198, 201–202, 208, 211–212, 217–218, 220, 226–227, 230–231, 234–236, 238, 244, 249–251, 253–255, 260, 262–265, 267–268, 277–278, 281–282, 287–288, 291–295, 298–299, 304–305, 308, 311–315, 320–323, 326, 329–330, 333, 336–337, 340, 344–349, 353–354, 358, 361–362, 365, 368–371, 373, 376–377, 381, 384, 387–390, 392, 399, 403–404, 407–408, 414–415, 421, 423–424, 428, 430, 432–434, 437, 441, 444, 447–448, 450, 453, 461–462, 469, 479, 482, 490–491, 496–499, 501, 508, 510–512, 518–519, 523–524, 527, 531, 534, 536, 543–547, 549, 561–564, 567, 570, 572, 579, 583–584, 586–587, 589–591, 593, 595, 598, 601, 604, 606–607, 610–614, 618–620, 622, 630–634, 636, 639, 643, 646, 657–658, 663, 673, 676–684, 688–697, 701–710, 714, 716–718, 720–721, 723–724
   _jetson_common.py1734573%133, 141, 289–292, 295, 312, 320, 355, 360–365, 383, 409–410, 412–414, 418–421, 423–424, 426–430, 432, 439–440, 443–444, 454, 457–458, 461, 463, 507–508
   _jetson_uefi.py39827131%123–125, 130–131, 150–152, 157–160, 327, 445, 447–450, 454, 458–459, 461–469, 471, 483–484, 487–488, 491–492, 495–497, 501–502, 507–509, 513, 517–518, 521–522, 525–526, 530, 533–534, 536, 541–542, 546, 549–550, 555, 559–560, 563, 567–569, 571, 575–578, 580–581, 603–604, 608–609, 611, 615, 619–620, 623–624, 631, 634–636, 639, 641–642, 647–648, 651–654, 656–657, 662, 664–665, 673, 676–679, 681–682, 684, 688–689, 693, 701–705, 708–709, 711, 714–718, 721, 724–728, 732–733, 736–741, 744–745, 748–751, 753–754, 761–762, 772–775, 778, 781–784, 787–791, 794–795, 798, 801–804, 807, 809, 814–815, 818, 821–824, 826, 832, 837–838, 857–858, 861, 869–870, 877, 887, 890, 897–898, 903–906, 914–917, 925–926, 938–941, 943, 946, 949, 957, 968–970, 972–974, 976–980, 985–986, 988, 1001, 1005, 1008, 1018, 1023, 1031–1032, 1035, 1039, 1041–1043, 1049–1050, 1055, 1063–1070, 1075–1083, 1088–1096, 1102–1104
   _rpi_boot.py28713453%54, 57, 121–122, 126, 134–137, 151–154, 161–162, 164–165, 170–171, 174–175, 184–185, 223, 229–233, 236, 254–256, 260–262, 267–269, 273–275, 285–286, 289, 292, 294–295, 297–298, 300–302, 308, 311–312, 322–325, 333–337, 339, 341–342, 347–348, 355–361, 392, 394–397, 407–410, 414–415, 417–421, 449–452, 471–474, 479, 482, 500–503, 508–516, 521–529, 546–549, 555–557, 560, 563
   configs.py550100% 
   protocol.py40100% 
   selecter.py412929%45–47, 50–51, 55–56, 59–61, 64, 66, 70, 78–80, 82–83, 85–86, 90, 92, 94–95, 97, 99–100, 102, 104
src/otaclient/configs
   _common.py80100% 
   ecu_info.py58198%108
   proxy_info.py52296%88, 90
src/otaclient/create_standby
   __init__.py12558%29–31, 33, 35
   common.py2244480%62, 65–66, 70–72, 74, 78–79, 81, 127, 175–177, 179–181, 183, 186–189, 193, 204, 278–279, 281–286, 298, 335, 363, 366–368, 384–385, 399, 403, 425–426
   interface.py50100% 
   rebuild_mode.py97990%93–95, 107–112
src/otaclient_api/v2
   api_caller.py39684%45–47, 83–85
   api_stub.py170100% 
   types.py2562391%86, 89–92, 131, 209–210, 212, 259, 262–263, 506–508, 512–513, 515, 518–519, 522–523, 586
src/otaclient_common
   __init__.py34876%42–44, 61, 63, 69, 76–77
   _io.py64198%41
   common.py1061189%44, 148, 151–153, 168, 175–177, 271, 275
   downloader.py1991094%107–108, 126, 153, 369, 424, 428, 516–517, 526
   linux.py611575%51–53, 59, 69, 74, 76, 108–109, 133–134, 190, 195–196, 198
   logging.py29196%55
   persist_file_handling.py1181884%113, 118, 150–152, 163, 192–193, 228–232, 242–244, 246–247
   proto_streamer.py42880%33, 48, 66–67, 72, 81–82, 100
   proto_wrapper.py3984887%87, 165, 172, 184–186, 205, 210, 221, 257, 263, 268, 299, 303, 307, 402, 462, 469, 472, 492, 499, 501, 526, 532, 535, 537, 562, 568, 571, 573, 605, 609, 611, 625, 642, 669, 672, 676, 707, 713, 760–763, 765, 803–805
   retry_task_map.py105595%158–159, 161, 181–182
   typing.py25388%69–70, 72
TOTAL6317167473% 

Tests Skipped Failures Errors Time
221 0 💤 0 ❌ 0 🔥 13m 31s ⏱️

Copy link

@Bodong-Yang Bodong-Yang merged commit 2a930e7 into main Oct 19, 2024
7 checks passed
@Bodong-Yang Bodong-Yang deleted the feat/otaclient_common_io branch October 19, 2024 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Rewrite/remove related code instead of patching them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant