summaryrefslogtreecommitdiff
path: root/python-testarchiver.spec
blob: f00ed1e34ae2588d7fa11abb64aa97d0122dbd9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
%global _empty_manifest_terminate_build 0
Name:		python-testarchiver
Version:	2.6.1
Release:	1
Summary:	Tools for serialising test results to SQL database
License:	Apache License 2.0
URL:		https://github.com/salabs/TestArchiver
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/cc/13/202ded5ce6c1f7b3f66e34ef284a12795abca8f6fb7e103cfbb8316330ee/testarchiver-2.6.1.tar.gz
BuildArch:	noarch

Requires:	python3-psycopg2-binary

%description
# TestArchiver

TestArchiver is a tool for archiving your test results to a SQL database.

And [Epimetheus](https://github.com/salabs/Epimetheus) is the tool for browsing the results you archived.

## Testing framework support

| Framework       | Status                      | Fixture test status | Parser option |
| --------------- | --------------------------- | ------------------- | ------------- |
| Robot Framework | [Supported](robot_tests/)   | Done                | robot         |
| Mocha           | [Supported](mocha_tests/)   | Done                | mocha-junit   |
| pytest          | [Supported](pytest/)        | Done                | pytest-junit  |
| PHPUnit         | [Supported](phpunit_tests/) | Done                | php-junit     |
| JUnit           | Experimental                | Missing             | junit         |
| xUnit           | Experimental                | Missing             | xunit         |
| MSTest          | Experimental                | Missing             | mstest        |


Experimental status here means that there is a parser that can take in e.g. generic JUnit formatted output but there is no specific test set or any extensive testing or active development for the parser.

Contributions for output parsers or listeners for different testing frameworks are appreciated. Contributing simply a fixture test set (that can be used to generate output files for developing a specific parser) is extremely helpful for any new framework.

## Installation
`sudo -H python3 -m pip install testarchiver`

## Supported databases

### SQLite

[SQLite](https://www.sqlite.org) default database for the archiver and is mainly useful for testing and demo purposes. Sqlite3 driver is part of the python standard library so there are no additional dependencies for trying out the archiver.

### PostgreSQL

[PostgreSQL](https://www.postgresql.org) is the currently supported database for real projects. For example [Epimetheus](https://github.com/salabs/Epimetheus) service uses a PosrgreSQL database. For accessing PostgreSQL databases the script uses psycopg2 module: `pip install psycopg2-binary` (comes with pip install)

## Basic usage

The output files from different testing frameworks can be parsed into a database using `test_archiver/output_parser.py` script.

```
testarchiver --database test_archive.db output.xml
```

Assuming that `output.xml` is a output file generated by Robot Framework (the default parser option), this will create a SQLite database file named `test_archive.db` that contains the results.

For list of other options: `testarchiver --help`
```
positional arguments:
  output_files          list of test output files to parse in to the test
                        archive

optional arguments:
  -h, --help            show this help message and exit
  --version, -v         show program's version number and exit
  --config CONFIG_FILE  Path to JSON config file containing database
                        credentials and other configurations. Options given on
                        command line will override options set in a config
                        file.
  --format {robot,robotframework,xunit,junit,mocha-junit,pytest-junit,mstest,php-junit}
                        output format (default: robotframework)
  --repository REPOSITORY
                        The repository of the test cases. Used to
                        differentiate between test with same name in different
                        projects.
  --team TEAM           Team name for the test series
  --series SERIES       Name of the test series (and optionally build number
                        'SERIES_NAME#BUILD_NUM' or build id
                        'SERIES_NAME#BUILD_ID')
  --metadata NAME:VALUE
                        Adds given metadata to the test run. Expected format:
                        'NAME:VALUE'

Database connection:
  --dbengine DB_ENGINE  Database engine, postgresql or sqlite (default)
  --database DATABASE   database name
  --host HOST           database host name
  --user USER           database user
  --pw PASSWORD, --password PASSWORD
                        database password
  --port PORT           database port (default: 5432)
  --dont-require-ssl    Disable the default behavior to require ssl from the
                        target database.

Schema updates:
  --allow-minor-schema-updates
                        Allow TestArchiver to perform MINOR (backwards
                        compatible) schema updates the test archive
  --allow-major-schema-updates
                        Allow TestArchiver to perform MAJOR (backwards
                        incompatible) schema updates the test archive

Limit archived data:
  --no-keywords         Do not archive keyword data
  --no-keyword-stats    Do not archive keyword statistics
  --ignore-logs-below {TRACE,DEBUG,INFO,WARN}
                        Sets a cut off level for archived log messages. By
                        default archives all available log messages.
  --ignore-logs         Do not archive any log messages
  --max_log_message_length MAX_LOG_MESSAGE_LENGTH
                        Specify how many characters of the log message that is
                        archived. full: archives the complete log. positive
                        integers: archives number of characters from the
                        beginning. negative integers: archives number of
                        characters from the end.

Adjust timestamps:
  --time-adjust-secs TIME_ADJUST_SECS
                        Adjust time in timestamps by given seconds. This can
                        be used to change time to utc before writing the
                        results to database, especially if the test system
                        uses local time, such as robot framework. For example
                        if test were run in Finland (GMT+3) in summer (+1hr),
                        calculate total hours by minutes and seconds and
                        invert to adjust in correct direction, i.e.
                        -(3+1)*60*60, so --time-adjust-secs -14400. This
                        option is useful if you are archiving in a different
                        location to where tests are run.If you are running
                        tests and archiving in same timezone, time-adjust-
                        with-system-timezone may be a better option. This
                        option may be used in conjunction with --time-adjust-
                        with-system-timezone if desired.
  --time-adjust-with-system-timezone
                        Adjust the time in timestamps by the system timezone
                        (including daylight savings adjust). If you are
                        archiving tests in the same timezone as you are
                        running tests, setting this option will ensure time
                        written to the database is in UTC/GMT time. This
                        assumes that if multiple computers are used that their
                        timezone and daylight savings settings are identical.
                        Take care also that you do not run tests just before a
                        daylight savings time adjust and archive just after,
                        as times will be out by one hour. This could easily
                        happen if long running tests cross a timezone adjust
                        boundary. This option may be used in conjunction with
                        --time-adjust-secs.

ChangeEngine:
  --change-engine-url CHANGE_ENGINE_URL
                        Starts a listener that feeds results to ChangeEngine
  --execution-context EXECUTION_CONTEXT
                        To separate data from different build pipelines for
                        ChangeEngine prioritization. Example if same changes
                        or tests may be used to verify app in Android and iOS
                        platforms, then it would be good to separate the
                        result from different builds pipelines/platforms. The
                        ChangeEngine prioritization might not give correct
                        result if different results from different platforms
                        are mixed together.
  --changes CHANGES     Json file which contains information from the changed
                        files for each repo. The file should be formatted like
                        this: { "context": "The execution context, same as
                        --execution-context and command line will override
                        this setting.", "changes": [ { "name": "string
                        representing the changed item, for example file path",
                        "repository": "Repository (optional), for separating
                        between changed items with identical names.",
                        "item_type": "Separating items (optional) and for
                        filtering subsets when prioritising", "subtype":
                        "(optional, for separating items for filtering subsets
                        when prioritising" } ] }
  --execution-id EXECUTION_ID
                        Identifier or version of the tested application for
                        given execution-context. Stored in ChangeEngine and
                        returned by "last_update" query.
```

## Data model

[Schema and data model](https://github.com/salabs/TestArchiver/tree/master/test_archiver/schemas) (NOTICE: this points to latest version)

## Useful metadata

There are meta data that are useful to add with the results. Some testing frameworks allow adding metadata to your test results and for those frameworks (e.g. Robot Framework) it is recommended to add that metadata already to the tests so the same information is also available in the results. Additional metadata can be added when parsing the results using the `--metadata` option. Metadata given during the parsing is linked to the top level test suite.

`--metadata NAME:VALUE`

## Test series and teams

In the data model, each test result file is represented as single test run. These test runs are linked and organized into builds in in different result series. Depending on the situation the series can be e.g. CI build jobs or different branches. By default if no series is specified the results are linked to a default series with autoincrementing build numbers. Different test runs (from different testing frameworks or parallel executions) that belong together can be organized into the same build. Different test series are additionally organized by team. Series name and build number/id are separated by `#`.

Some examples using the `--series` and `--team` options of `testarchiver`

-   `--series ${JENKINS_JOB_NAME}#${BUILD_NUMBER}`
-   `--series "UI tests"#<commit hash>`
-   `--series ${CURRENT_BRANCH}#${BUILD_ID} --team Team-A`
-   `--series manually_run`

Each build will have a build number in the series. If the build number is specified then that number is used. If the build number/id is omitted then the build number will be checked from the previous build in that series and incremented. If the build number/id is not a number it is considered a build identifier string. If that id is new to the series the build number is incremented just as if it no build number was specified. If the same build id is found in the same test series then the results are added under that same previously archived build.

If the tests are executed in a CI environment the build number/id is an excellent way to link the archived results to the actual builds.

The series can also be indicated using metadata. Any metadata with name prefixed with `series` are interpreted as series information. This is especially useful when using listeners. For example when using Robot Framework metadata `--metadata team:A-Team --metadata series:JENKINS_JOB_NAME#BUILD_NUMBER`

## Timestamp adjustment

Some test frameworks use local time in their timestamps. For archiving into databases this can be problematic if tests
are viewed and or run in different timezones. To address this two ways to adjust the time back to GMT/UTC are provided.

The first allows the user to apply an adjustment of a fixed time in seconds of their choosing. This is useful for cases
where tests were already run and the place/timezone where they were run are known. This option is useful if you are
archiving in a different location to where tests are  run. The time value provided as an option is added to the
timestamp. Care must be taken with places where summer time is different (usually +1hr).

For example if test were run in Finland (GMT+2), plus 1 hour in summer, calculate total hours by minutes and seconds
and invert to adjust in correct direction, i.e. -(2+1)*60*60, so --time-adjust-secs -10800 in summer time,
and -7200 otherwise.

The second provides for automated adjustment based on the system timezone and/or daylight savings if it applies. This
is useful if the tests and archiving are performed in the same place and time.
This assumes that if multiple computers are used that their timezone and daylight savings settings are identical.
Care must also be taken that tests are not run just before a daylight savings time adjust and archived just after
as times will be out by one hour. This could easily happen if long running tests cross a timezone adjust boundary.
This can be set using --time-adjust-with-system-timezone.

The ArchiverRobotListener allows for the second option if its adjust_with_system_timezone argument is set to True.

To ensure any of the optional adjustments are traceable, two meta data values are added to the suites' test run.
If time-adjust-secs is set to a value, time_adjust_secs with that value is written to the suite_metadata table.
If `--time-adjust-with-system-timezone` option is included, then the addition of the time-adjust-secs and the
system timezone is written to the suite_metadata tables as time_adjust_secs_total.

e.g with command line

`output_parser.py --time-adjust-secs -3600 --time-adjust-with-system-timezone ...`

the following values would be added to suite_metadata table for (GMT+2)

 - time_adjust_secs with value -3600
 - time_adjust_secs_total with -10800.

This example is mimicking adding daylight savings (1hr = 3600 secs) onto
a system offset secs of 7200 (GMT+2). i.e. if the computer being used had the 'daylight savings' setting
of and you want to manually add it during archiving.


# Release notes
- 2.6.1 (2022-10-19)
  * Fixes a bug/regression that caused data of log messages not to be archived.

- 2.6.0 (2022-09-15)
  * `--max_log_message_length` option to control the length of log messages archived.
    Defaults to 2000 chars. Negative values will archive log messages from the end.
  * Ignores return statements without warnigns from Robot Framework 5.x inputs

- 2.5.1 (2022-09-06)
  * JUnit parsers updated to accept results where time value is missing from a testcase
  * XUnit parsers updated to accept results where time value is missing from a testcase

- 2.5.0 (2022-06-23)
  * Time adjustments effect also test_run's generated field and start_time of all items
  * Fixes pytest parser by always using keyword on failure
  * The port option is now used when connecting to databases

- 2.4.0 (2021-04-28)
  * Updates to support archiving Robot Framework 4.0
  * Fixes bug in execution path calculation for log messages

- 2.3.0 (2021-03-16)
  * Better support for feeding changes and execution context for ChangeEngine
    - `--changes` for feeding changes information
    - `--execution-id` Identifier or version of the tested application for given execution-context. Stored in ChangeEngine and returned by `last_update` query.

- 2.2.0 (2020-12-21)
  * Ability to adjust times as reported by timestamps in test results.
    - `--time-adjust-secs` allows for manual adjustment of the timestamps with given value
    - `--time-adjust-with-system-timezone` allows for automatic adjustment of timestamps by timezone and/or daylight savings.
  * Support for parsing PHPUnit output
  * ChangeEngine:
    - Listener ignores skipped tests
    - Adds test type to all parsers
    - `--execution-context` option for setting the execution context for the results
  * diff2change_context_list.py now uses the term change context instead of simply context for clarity
  * Adds Dockerfiles for an empty database and database with sample data
    generated from project's tests

- 2.1.0 (2020-09-16)
  * New options for controlling archiving of keywords and log messages
    - `--no-keywords` for ignoring all keyword data
    - `--no-keyword-stats` for not collecting keyword statistics data
    - `--ignore-logs` for not collecting any log message data
    - `--ignore-logs-below` for ignoring all log messages below the given log level

- 2.0.0 (2020-09-04)
  * Distribution as pip package `pip3 install testarchiver` and it installs:
    - `testarchiver` script (aka: output_parser.py)
    - `testarchive_schematool` script (aka: database.py)
    - `diff2change_context_list.py` script
    - `test_archiver` module
  * Functionality for managing schema updates
    - TestArchiver version has to match with the schema version
    - TestArchiver can apply schema updates when explicitly allowed
    - Updates are divided to major and minor updates
    - Minor updates are backwards compatible for applications reading the database
    - Major updates are backwards incompatible for applications reading the database
  * Major schema update #1:
    - Adds `schema_updates` table for recording schema updates
    - Adds `schema_version` column to `test_run` table to make schema incompatible with
      old versions TestArchiver
    - Adds index for log messages for query performance
  * Renamed `output_parser.py` cli option `--change_engine_url` to `--change-engine-url`
  * Record an execution path for test cases, suites and log messages.
    - The path explains the position of the item in its test run.
    - E.g. `s1-s2-t3` means the third test in the second subsuite of the top suite.
  * Minor schema update #2:
    - Adds `execution_path` column to `test_result`, `suite_result` and `log_message` tables
  * Renamed Robot Framework listener `ArchiverListener.py` as `ArchiverRobotListener.py` for clarity


- 1.2.0 (2020-08-18)
  * Important database integrity fix when using sqlite database
  * Record test criticality (Robot Framework specific)
  * Redesign of configurations management
    - Allows using both config file and command line arguments uniformly
    - CLI arguments override options set in config file

- 1.1.3 (2020-06-09)
  * Performance fix for the schema existence check
  * Improved error messages:
    - Error when trying to archive results that have already been archived
    - Error when psycopg2 module is not found




%package -n python3-testarchiver
Summary:	Tools for serialising test results to SQL database
Provides:	python-testarchiver
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-testarchiver
# TestArchiver

TestArchiver is a tool for archiving your test results to a SQL database.

And [Epimetheus](https://github.com/salabs/Epimetheus) is the tool for browsing the results you archived.

## Testing framework support

| Framework       | Status                      | Fixture test status | Parser option |
| --------------- | --------------------------- | ------------------- | ------------- |
| Robot Framework | [Supported](robot_tests/)   | Done                | robot         |
| Mocha           | [Supported](mocha_tests/)   | Done                | mocha-junit   |
| pytest          | [Supported](pytest/)        | Done                | pytest-junit  |
| PHPUnit         | [Supported](phpunit_tests/) | Done                | php-junit     |
| JUnit           | Experimental                | Missing             | junit         |
| xUnit           | Experimental                | Missing             | xunit         |
| MSTest          | Experimental                | Missing             | mstest        |


Experimental status here means that there is a parser that can take in e.g. generic JUnit formatted output but there is no specific test set or any extensive testing or active development for the parser.

Contributions for output parsers or listeners for different testing frameworks are appreciated. Contributing simply a fixture test set (that can be used to generate output files for developing a specific parser) is extremely helpful for any new framework.

## Installation
`sudo -H python3 -m pip install testarchiver`

## Supported databases

### SQLite

[SQLite](https://www.sqlite.org) default database for the archiver and is mainly useful for testing and demo purposes. Sqlite3 driver is part of the python standard library so there are no additional dependencies for trying out the archiver.

### PostgreSQL

[PostgreSQL](https://www.postgresql.org) is the currently supported database for real projects. For example [Epimetheus](https://github.com/salabs/Epimetheus) service uses a PosrgreSQL database. For accessing PostgreSQL databases the script uses psycopg2 module: `pip install psycopg2-binary` (comes with pip install)

## Basic usage

The output files from different testing frameworks can be parsed into a database using `test_archiver/output_parser.py` script.

```
testarchiver --database test_archive.db output.xml
```

Assuming that `output.xml` is a output file generated by Robot Framework (the default parser option), this will create a SQLite database file named `test_archive.db` that contains the results.

For list of other options: `testarchiver --help`
```
positional arguments:
  output_files          list of test output files to parse in to the test
                        archive

optional arguments:
  -h, --help            show this help message and exit
  --version, -v         show program's version number and exit
  --config CONFIG_FILE  Path to JSON config file containing database
                        credentials and other configurations. Options given on
                        command line will override options set in a config
                        file.
  --format {robot,robotframework,xunit,junit,mocha-junit,pytest-junit,mstest,php-junit}
                        output format (default: robotframework)
  --repository REPOSITORY
                        The repository of the test cases. Used to
                        differentiate between test with same name in different
                        projects.
  --team TEAM           Team name for the test series
  --series SERIES       Name of the test series (and optionally build number
                        'SERIES_NAME#BUILD_NUM' or build id
                        'SERIES_NAME#BUILD_ID')
  --metadata NAME:VALUE
                        Adds given metadata to the test run. Expected format:
                        'NAME:VALUE'

Database connection:
  --dbengine DB_ENGINE  Database engine, postgresql or sqlite (default)
  --database DATABASE   database name
  --host HOST           database host name
  --user USER           database user
  --pw PASSWORD, --password PASSWORD
                        database password
  --port PORT           database port (default: 5432)
  --dont-require-ssl    Disable the default behavior to require ssl from the
                        target database.

Schema updates:
  --allow-minor-schema-updates
                        Allow TestArchiver to perform MINOR (backwards
                        compatible) schema updates the test archive
  --allow-major-schema-updates
                        Allow TestArchiver to perform MAJOR (backwards
                        incompatible) schema updates the test archive

Limit archived data:
  --no-keywords         Do not archive keyword data
  --no-keyword-stats    Do not archive keyword statistics
  --ignore-logs-below {TRACE,DEBUG,INFO,WARN}
                        Sets a cut off level for archived log messages. By
                        default archives all available log messages.
  --ignore-logs         Do not archive any log messages
  --max_log_message_length MAX_LOG_MESSAGE_LENGTH
                        Specify how many characters of the log message that is
                        archived. full: archives the complete log. positive
                        integers: archives number of characters from the
                        beginning. negative integers: archives number of
                        characters from the end.

Adjust timestamps:
  --time-adjust-secs TIME_ADJUST_SECS
                        Adjust time in timestamps by given seconds. This can
                        be used to change time to utc before writing the
                        results to database, especially if the test system
                        uses local time, such as robot framework. For example
                        if test were run in Finland (GMT+3) in summer (+1hr),
                        calculate total hours by minutes and seconds and
                        invert to adjust in correct direction, i.e.
                        -(3+1)*60*60, so --time-adjust-secs -14400. This
                        option is useful if you are archiving in a different
                        location to where tests are run.If you are running
                        tests and archiving in same timezone, time-adjust-
                        with-system-timezone may be a better option. This
                        option may be used in conjunction with --time-adjust-
                        with-system-timezone if desired.
  --time-adjust-with-system-timezone
                        Adjust the time in timestamps by the system timezone
                        (including daylight savings adjust). If you are
                        archiving tests in the same timezone as you are
                        running tests, setting this option will ensure time
                        written to the database is in UTC/GMT time. This
                        assumes that if multiple computers are used that their
                        timezone and daylight savings settings are identical.
                        Take care also that you do not run tests just before a
                        daylight savings time adjust and archive just after,
                        as times will be out by one hour. This could easily
                        happen if long running tests cross a timezone adjust
                        boundary. This option may be used in conjunction with
                        --time-adjust-secs.

ChangeEngine:
  --change-engine-url CHANGE_ENGINE_URL
                        Starts a listener that feeds results to ChangeEngine
  --execution-context EXECUTION_CONTEXT
                        To separate data from different build pipelines for
                        ChangeEngine prioritization. Example if same changes
                        or tests may be used to verify app in Android and iOS
                        platforms, then it would be good to separate the
                        result from different builds pipelines/platforms. The
                        ChangeEngine prioritization might not give correct
                        result if different results from different platforms
                        are mixed together.
  --changes CHANGES     Json file which contains information from the changed
                        files for each repo. The file should be formatted like
                        this: { "context": "The execution context, same as
                        --execution-context and command line will override
                        this setting.", "changes": [ { "name": "string
                        representing the changed item, for example file path",
                        "repository": "Repository (optional), for separating
                        between changed items with identical names.",
                        "item_type": "Separating items (optional) and for
                        filtering subsets when prioritising", "subtype":
                        "(optional, for separating items for filtering subsets
                        when prioritising" } ] }
  --execution-id EXECUTION_ID
                        Identifier or version of the tested application for
                        given execution-context. Stored in ChangeEngine and
                        returned by "last_update" query.
```

## Data model

[Schema and data model](https://github.com/salabs/TestArchiver/tree/master/test_archiver/schemas) (NOTICE: this points to latest version)

## Useful metadata

There are meta data that are useful to add with the results. Some testing frameworks allow adding metadata to your test results and for those frameworks (e.g. Robot Framework) it is recommended to add that metadata already to the tests so the same information is also available in the results. Additional metadata can be added when parsing the results using the `--metadata` option. Metadata given during the parsing is linked to the top level test suite.

`--metadata NAME:VALUE`

## Test series and teams

In the data model, each test result file is represented as single test run. These test runs are linked and organized into builds in in different result series. Depending on the situation the series can be e.g. CI build jobs or different branches. By default if no series is specified the results are linked to a default series with autoincrementing build numbers. Different test runs (from different testing frameworks or parallel executions) that belong together can be organized into the same build. Different test series are additionally organized by team. Series name and build number/id are separated by `#`.

Some examples using the `--series` and `--team` options of `testarchiver`

-   `--series ${JENKINS_JOB_NAME}#${BUILD_NUMBER}`
-   `--series "UI tests"#<commit hash>`
-   `--series ${CURRENT_BRANCH}#${BUILD_ID} --team Team-A`
-   `--series manually_run`

Each build will have a build number in the series. If the build number is specified then that number is used. If the build number/id is omitted then the build number will be checked from the previous build in that series and incremented. If the build number/id is not a number it is considered a build identifier string. If that id is new to the series the build number is incremented just as if it no build number was specified. If the same build id is found in the same test series then the results are added under that same previously archived build.

If the tests are executed in a CI environment the build number/id is an excellent way to link the archived results to the actual builds.

The series can also be indicated using metadata. Any metadata with name prefixed with `series` are interpreted as series information. This is especially useful when using listeners. For example when using Robot Framework metadata `--metadata team:A-Team --metadata series:JENKINS_JOB_NAME#BUILD_NUMBER`

## Timestamp adjustment

Some test frameworks use local time in their timestamps. For archiving into databases this can be problematic if tests
are viewed and or run in different timezones. To address this two ways to adjust the time back to GMT/UTC are provided.

The first allows the user to apply an adjustment of a fixed time in seconds of their choosing. This is useful for cases
where tests were already run and the place/timezone where they were run are known. This option is useful if you are
archiving in a different location to where tests are  run. The time value provided as an option is added to the
timestamp. Care must be taken with places where summer time is different (usually +1hr).

For example if test were run in Finland (GMT+2), plus 1 hour in summer, calculate total hours by minutes and seconds
and invert to adjust in correct direction, i.e. -(2+1)*60*60, so --time-adjust-secs -10800 in summer time,
and -7200 otherwise.

The second provides for automated adjustment based on the system timezone and/or daylight savings if it applies. This
is useful if the tests and archiving are performed in the same place and time.
This assumes that if multiple computers are used that their timezone and daylight savings settings are identical.
Care must also be taken that tests are not run just before a daylight savings time adjust and archived just after
as times will be out by one hour. This could easily happen if long running tests cross a timezone adjust boundary.
This can be set using --time-adjust-with-system-timezone.

The ArchiverRobotListener allows for the second option if its adjust_with_system_timezone argument is set to True.

To ensure any of the optional adjustments are traceable, two meta data values are added to the suites' test run.
If time-adjust-secs is set to a value, time_adjust_secs with that value is written to the suite_metadata table.
If `--time-adjust-with-system-timezone` option is included, then the addition of the time-adjust-secs and the
system timezone is written to the suite_metadata tables as time_adjust_secs_total.

e.g with command line

`output_parser.py --time-adjust-secs -3600 --time-adjust-with-system-timezone ...`

the following values would be added to suite_metadata table for (GMT+2)

 - time_adjust_secs with value -3600
 - time_adjust_secs_total with -10800.

This example is mimicking adding daylight savings (1hr = 3600 secs) onto
a system offset secs of 7200 (GMT+2). i.e. if the computer being used had the 'daylight savings' setting
of and you want to manually add it during archiving.


# Release notes
- 2.6.1 (2022-10-19)
  * Fixes a bug/regression that caused data of log messages not to be archived.

- 2.6.0 (2022-09-15)
  * `--max_log_message_length` option to control the length of log messages archived.
    Defaults to 2000 chars. Negative values will archive log messages from the end.
  * Ignores return statements without warnigns from Robot Framework 5.x inputs

- 2.5.1 (2022-09-06)
  * JUnit parsers updated to accept results where time value is missing from a testcase
  * XUnit parsers updated to accept results where time value is missing from a testcase

- 2.5.0 (2022-06-23)
  * Time adjustments effect also test_run's generated field and start_time of all items
  * Fixes pytest parser by always using keyword on failure
  * The port option is now used when connecting to databases

- 2.4.0 (2021-04-28)
  * Updates to support archiving Robot Framework 4.0
  * Fixes bug in execution path calculation for log messages

- 2.3.0 (2021-03-16)
  * Better support for feeding changes and execution context for ChangeEngine
    - `--changes` for feeding changes information
    - `--execution-id` Identifier or version of the tested application for given execution-context. Stored in ChangeEngine and returned by `last_update` query.

- 2.2.0 (2020-12-21)
  * Ability to adjust times as reported by timestamps in test results.
    - `--time-adjust-secs` allows for manual adjustment of the timestamps with given value
    - `--time-adjust-with-system-timezone` allows for automatic adjustment of timestamps by timezone and/or daylight savings.
  * Support for parsing PHPUnit output
  * ChangeEngine:
    - Listener ignores skipped tests
    - Adds test type to all parsers
    - `--execution-context` option for setting the execution context for the results
  * diff2change_context_list.py now uses the term change context instead of simply context for clarity
  * Adds Dockerfiles for an empty database and database with sample data
    generated from project's tests

- 2.1.0 (2020-09-16)
  * New options for controlling archiving of keywords and log messages
    - `--no-keywords` for ignoring all keyword data
    - `--no-keyword-stats` for not collecting keyword statistics data
    - `--ignore-logs` for not collecting any log message data
    - `--ignore-logs-below` for ignoring all log messages below the given log level

- 2.0.0 (2020-09-04)
  * Distribution as pip package `pip3 install testarchiver` and it installs:
    - `testarchiver` script (aka: output_parser.py)
    - `testarchive_schematool` script (aka: database.py)
    - `diff2change_context_list.py` script
    - `test_archiver` module
  * Functionality for managing schema updates
    - TestArchiver version has to match with the schema version
    - TestArchiver can apply schema updates when explicitly allowed
    - Updates are divided to major and minor updates
    - Minor updates are backwards compatible for applications reading the database
    - Major updates are backwards incompatible for applications reading the database
  * Major schema update #1:
    - Adds `schema_updates` table for recording schema updates
    - Adds `schema_version` column to `test_run` table to make schema incompatible with
      old versions TestArchiver
    - Adds index for log messages for query performance
  * Renamed `output_parser.py` cli option `--change_engine_url` to `--change-engine-url`
  * Record an execution path for test cases, suites and log messages.
    - The path explains the position of the item in its test run.
    - E.g. `s1-s2-t3` means the third test in the second subsuite of the top suite.
  * Minor schema update #2:
    - Adds `execution_path` column to `test_result`, `suite_result` and `log_message` tables
  * Renamed Robot Framework listener `ArchiverListener.py` as `ArchiverRobotListener.py` for clarity


- 1.2.0 (2020-08-18)
  * Important database integrity fix when using sqlite database
  * Record test criticality (Robot Framework specific)
  * Redesign of configurations management
    - Allows using both config file and command line arguments uniformly
    - CLI arguments override options set in config file

- 1.1.3 (2020-06-09)
  * Performance fix for the schema existence check
  * Improved error messages:
    - Error when trying to archive results that have already been archived
    - Error when psycopg2 module is not found




%package help
Summary:	Development documents and examples for testarchiver
Provides:	python3-testarchiver-doc
%description help
# TestArchiver

TestArchiver is a tool for archiving your test results to a SQL database.

And [Epimetheus](https://github.com/salabs/Epimetheus) is the tool for browsing the results you archived.

## Testing framework support

| Framework       | Status                      | Fixture test status | Parser option |
| --------------- | --------------------------- | ------------------- | ------------- |
| Robot Framework | [Supported](robot_tests/)   | Done                | robot         |
| Mocha           | [Supported](mocha_tests/)   | Done                | mocha-junit   |
| pytest          | [Supported](pytest/)        | Done                | pytest-junit  |
| PHPUnit         | [Supported](phpunit_tests/) | Done                | php-junit     |
| JUnit           | Experimental                | Missing             | junit         |
| xUnit           | Experimental                | Missing             | xunit         |
| MSTest          | Experimental                | Missing             | mstest        |


Experimental status here means that there is a parser that can take in e.g. generic JUnit formatted output but there is no specific test set or any extensive testing or active development for the parser.

Contributions for output parsers or listeners for different testing frameworks are appreciated. Contributing simply a fixture test set (that can be used to generate output files for developing a specific parser) is extremely helpful for any new framework.

## Installation
`sudo -H python3 -m pip install testarchiver`

## Supported databases

### SQLite

[SQLite](https://www.sqlite.org) default database for the archiver and is mainly useful for testing and demo purposes. Sqlite3 driver is part of the python standard library so there are no additional dependencies for trying out the archiver.

### PostgreSQL

[PostgreSQL](https://www.postgresql.org) is the currently supported database for real projects. For example [Epimetheus](https://github.com/salabs/Epimetheus) service uses a PosrgreSQL database. For accessing PostgreSQL databases the script uses psycopg2 module: `pip install psycopg2-binary` (comes with pip install)

## Basic usage

The output files from different testing frameworks can be parsed into a database using `test_archiver/output_parser.py` script.

```
testarchiver --database test_archive.db output.xml
```

Assuming that `output.xml` is a output file generated by Robot Framework (the default parser option), this will create a SQLite database file named `test_archive.db` that contains the results.

For list of other options: `testarchiver --help`
```
positional arguments:
  output_files          list of test output files to parse in to the test
                        archive

optional arguments:
  -h, --help            show this help message and exit
  --version, -v         show program's version number and exit
  --config CONFIG_FILE  Path to JSON config file containing database
                        credentials and other configurations. Options given on
                        command line will override options set in a config
                        file.
  --format {robot,robotframework,xunit,junit,mocha-junit,pytest-junit,mstest,php-junit}
                        output format (default: robotframework)
  --repository REPOSITORY
                        The repository of the test cases. Used to
                        differentiate between test with same name in different
                        projects.
  --team TEAM           Team name for the test series
  --series SERIES       Name of the test series (and optionally build number
                        'SERIES_NAME#BUILD_NUM' or build id
                        'SERIES_NAME#BUILD_ID')
  --metadata NAME:VALUE
                        Adds given metadata to the test run. Expected format:
                        'NAME:VALUE'

Database connection:
  --dbengine DB_ENGINE  Database engine, postgresql or sqlite (default)
  --database DATABASE   database name
  --host HOST           database host name
  --user USER           database user
  --pw PASSWORD, --password PASSWORD
                        database password
  --port PORT           database port (default: 5432)
  --dont-require-ssl    Disable the default behavior to require ssl from the
                        target database.

Schema updates:
  --allow-minor-schema-updates
                        Allow TestArchiver to perform MINOR (backwards
                        compatible) schema updates the test archive
  --allow-major-schema-updates
                        Allow TestArchiver to perform MAJOR (backwards
                        incompatible) schema updates the test archive

Limit archived data:
  --no-keywords         Do not archive keyword data
  --no-keyword-stats    Do not archive keyword statistics
  --ignore-logs-below {TRACE,DEBUG,INFO,WARN}
                        Sets a cut off level for archived log messages. By
                        default archives all available log messages.
  --ignore-logs         Do not archive any log messages
  --max_log_message_length MAX_LOG_MESSAGE_LENGTH
                        Specify how many characters of the log message that is
                        archived. full: archives the complete log. positive
                        integers: archives number of characters from the
                        beginning. negative integers: archives number of
                        characters from the end.

Adjust timestamps:
  --time-adjust-secs TIME_ADJUST_SECS
                        Adjust time in timestamps by given seconds. This can
                        be used to change time to utc before writing the
                        results to database, especially if the test system
                        uses local time, such as robot framework. For example
                        if test were run in Finland (GMT+3) in summer (+1hr),
                        calculate total hours by minutes and seconds and
                        invert to adjust in correct direction, i.e.
                        -(3+1)*60*60, so --time-adjust-secs -14400. This
                        option is useful if you are archiving in a different
                        location to where tests are run.If you are running
                        tests and archiving in same timezone, time-adjust-
                        with-system-timezone may be a better option. This
                        option may be used in conjunction with --time-adjust-
                        with-system-timezone if desired.
  --time-adjust-with-system-timezone
                        Adjust the time in timestamps by the system timezone
                        (including daylight savings adjust). If you are
                        archiving tests in the same timezone as you are
                        running tests, setting this option will ensure time
                        written to the database is in UTC/GMT time. This
                        assumes that if multiple computers are used that their
                        timezone and daylight savings settings are identical.
                        Take care also that you do not run tests just before a
                        daylight savings time adjust and archive just after,
                        as times will be out by one hour. This could easily
                        happen if long running tests cross a timezone adjust
                        boundary. This option may be used in conjunction with
                        --time-adjust-secs.

ChangeEngine:
  --change-engine-url CHANGE_ENGINE_URL
                        Starts a listener that feeds results to ChangeEngine
  --execution-context EXECUTION_CONTEXT
                        To separate data from different build pipelines for
                        ChangeEngine prioritization. Example if same changes
                        or tests may be used to verify app in Android and iOS
                        platforms, then it would be good to separate the
                        result from different builds pipelines/platforms. The
                        ChangeEngine prioritization might not give correct
                        result if different results from different platforms
                        are mixed together.
  --changes CHANGES     Json file which contains information from the changed
                        files for each repo. The file should be formatted like
                        this: { "context": "The execution context, same as
                        --execution-context and command line will override
                        this setting.", "changes": [ { "name": "string
                        representing the changed item, for example file path",
                        "repository": "Repository (optional), for separating
                        between changed items with identical names.",
                        "item_type": "Separating items (optional) and for
                        filtering subsets when prioritising", "subtype":
                        "(optional, for separating items for filtering subsets
                        when prioritising" } ] }
  --execution-id EXECUTION_ID
                        Identifier or version of the tested application for
                        given execution-context. Stored in ChangeEngine and
                        returned by "last_update" query.
```

## Data model

[Schema and data model](https://github.com/salabs/TestArchiver/tree/master/test_archiver/schemas) (NOTICE: this points to latest version)

## Useful metadata

There are meta data that are useful to add with the results. Some testing frameworks allow adding metadata to your test results and for those frameworks (e.g. Robot Framework) it is recommended to add that metadata already to the tests so the same information is also available in the results. Additional metadata can be added when parsing the results using the `--metadata` option. Metadata given during the parsing is linked to the top level test suite.

`--metadata NAME:VALUE`

## Test series and teams

In the data model, each test result file is represented as single test run. These test runs are linked and organized into builds in in different result series. Depending on the situation the series can be e.g. CI build jobs or different branches. By default if no series is specified the results are linked to a default series with autoincrementing build numbers. Different test runs (from different testing frameworks or parallel executions) that belong together can be organized into the same build. Different test series are additionally organized by team. Series name and build number/id are separated by `#`.

Some examples using the `--series` and `--team` options of `testarchiver`

-   `--series ${JENKINS_JOB_NAME}#${BUILD_NUMBER}`
-   `--series "UI tests"#<commit hash>`
-   `--series ${CURRENT_BRANCH}#${BUILD_ID} --team Team-A`
-   `--series manually_run`

Each build will have a build number in the series. If the build number is specified then that number is used. If the build number/id is omitted then the build number will be checked from the previous build in that series and incremented. If the build number/id is not a number it is considered a build identifier string. If that id is new to the series the build number is incremented just as if it no build number was specified. If the same build id is found in the same test series then the results are added under that same previously archived build.

If the tests are executed in a CI environment the build number/id is an excellent way to link the archived results to the actual builds.

The series can also be indicated using metadata. Any metadata with name prefixed with `series` are interpreted as series information. This is especially useful when using listeners. For example when using Robot Framework metadata `--metadata team:A-Team --metadata series:JENKINS_JOB_NAME#BUILD_NUMBER`

## Timestamp adjustment

Some test frameworks use local time in their timestamps. For archiving into databases this can be problematic if tests
are viewed and or run in different timezones. To address this two ways to adjust the time back to GMT/UTC are provided.

The first allows the user to apply an adjustment of a fixed time in seconds of their choosing. This is useful for cases
where tests were already run and the place/timezone where they were run are known. This option is useful if you are
archiving in a different location to where tests are  run. The time value provided as an option is added to the
timestamp. Care must be taken with places where summer time is different (usually +1hr).

For example if test were run in Finland (GMT+2), plus 1 hour in summer, calculate total hours by minutes and seconds
and invert to adjust in correct direction, i.e. -(2+1)*60*60, so --time-adjust-secs -10800 in summer time,
and -7200 otherwise.

The second provides for automated adjustment based on the system timezone and/or daylight savings if it applies. This
is useful if the tests and archiving are performed in the same place and time.
This assumes that if multiple computers are used that their timezone and daylight savings settings are identical.
Care must also be taken that tests are not run just before a daylight savings time adjust and archived just after
as times will be out by one hour. This could easily happen if long running tests cross a timezone adjust boundary.
This can be set using --time-adjust-with-system-timezone.

The ArchiverRobotListener allows for the second option if its adjust_with_system_timezone argument is set to True.

To ensure any of the optional adjustments are traceable, two meta data values are added to the suites' test run.
If time-adjust-secs is set to a value, time_adjust_secs with that value is written to the suite_metadata table.
If `--time-adjust-with-system-timezone` option is included, then the addition of the time-adjust-secs and the
system timezone is written to the suite_metadata tables as time_adjust_secs_total.

e.g with command line

`output_parser.py --time-adjust-secs -3600 --time-adjust-with-system-timezone ...`

the following values would be added to suite_metadata table for (GMT+2)

 - time_adjust_secs with value -3600
 - time_adjust_secs_total with -10800.

This example is mimicking adding daylight savings (1hr = 3600 secs) onto
a system offset secs of 7200 (GMT+2). i.e. if the computer being used had the 'daylight savings' setting
of and you want to manually add it during archiving.


# Release notes
- 2.6.1 (2022-10-19)
  * Fixes a bug/regression that caused data of log messages not to be archived.

- 2.6.0 (2022-09-15)
  * `--max_log_message_length` option to control the length of log messages archived.
    Defaults to 2000 chars. Negative values will archive log messages from the end.
  * Ignores return statements without warnigns from Robot Framework 5.x inputs

- 2.5.1 (2022-09-06)
  * JUnit parsers updated to accept results where time value is missing from a testcase
  * XUnit parsers updated to accept results where time value is missing from a testcase

- 2.5.0 (2022-06-23)
  * Time adjustments effect also test_run's generated field and start_time of all items
  * Fixes pytest parser by always using keyword on failure
  * The port option is now used when connecting to databases

- 2.4.0 (2021-04-28)
  * Updates to support archiving Robot Framework 4.0
  * Fixes bug in execution path calculation for log messages

- 2.3.0 (2021-03-16)
  * Better support for feeding changes and execution context for ChangeEngine
    - `--changes` for feeding changes information
    - `--execution-id` Identifier or version of the tested application for given execution-context. Stored in ChangeEngine and returned by `last_update` query.

- 2.2.0 (2020-12-21)
  * Ability to adjust times as reported by timestamps in test results.
    - `--time-adjust-secs` allows for manual adjustment of the timestamps with given value
    - `--time-adjust-with-system-timezone` allows for automatic adjustment of timestamps by timezone and/or daylight savings.
  * Support for parsing PHPUnit output
  * ChangeEngine:
    - Listener ignores skipped tests
    - Adds test type to all parsers
    - `--execution-context` option for setting the execution context for the results
  * diff2change_context_list.py now uses the term change context instead of simply context for clarity
  * Adds Dockerfiles for an empty database and database with sample data
    generated from project's tests

- 2.1.0 (2020-09-16)
  * New options for controlling archiving of keywords and log messages
    - `--no-keywords` for ignoring all keyword data
    - `--no-keyword-stats` for not collecting keyword statistics data
    - `--ignore-logs` for not collecting any log message data
    - `--ignore-logs-below` for ignoring all log messages below the given log level

- 2.0.0 (2020-09-04)
  * Distribution as pip package `pip3 install testarchiver` and it installs:
    - `testarchiver` script (aka: output_parser.py)
    - `testarchive_schematool` script (aka: database.py)
    - `diff2change_context_list.py` script
    - `test_archiver` module
  * Functionality for managing schema updates
    - TestArchiver version has to match with the schema version
    - TestArchiver can apply schema updates when explicitly allowed
    - Updates are divided to major and minor updates
    - Minor updates are backwards compatible for applications reading the database
    - Major updates are backwards incompatible for applications reading the database
  * Major schema update #1:
    - Adds `schema_updates` table for recording schema updates
    - Adds `schema_version` column to `test_run` table to make schema incompatible with
      old versions TestArchiver
    - Adds index for log messages for query performance
  * Renamed `output_parser.py` cli option `--change_engine_url` to `--change-engine-url`
  * Record an execution path for test cases, suites and log messages.
    - The path explains the position of the item in its test run.
    - E.g. `s1-s2-t3` means the third test in the second subsuite of the top suite.
  * Minor schema update #2:
    - Adds `execution_path` column to `test_result`, `suite_result` and `log_message` tables
  * Renamed Robot Framework listener `ArchiverListener.py` as `ArchiverRobotListener.py` for clarity


- 1.2.0 (2020-08-18)
  * Important database integrity fix when using sqlite database
  * Record test criticality (Robot Framework specific)
  * Redesign of configurations management
    - Allows using both config file and command line arguments uniformly
    - CLI arguments override options set in config file

- 1.1.3 (2020-06-09)
  * Performance fix for the schema existence check
  * Improved error messages:
    - Error when trying to archive results that have already been archived
    - Error when psycopg2 module is not found




%prep
%autosetup -n testarchiver-2.6.1

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-testarchiver -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 2.6.1-1
- Package Spec generated