|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -import random as insecure_random |
| 15 | +from random import Random, randrange |
| 16 | +from inspect import currentframe |
16 | 17 | from itertools import permutations |
17 | 18 | from logging import WARNING |
18 | 19 | from math import ldexp |
19 | | -from sys import float_info |
| 20 | +from sys import float_info, maxsize |
20 | 21 | from types import MethodType |
21 | 22 | from unittest.mock import Mock, patch |
22 | 23 |
|
@@ -1092,10 +1093,17 @@ def collect_and_validate() -> None: |
1092 | 1093 | assert result.zero_count == len([v for v in values if v == 0]) |
1093 | 1094 | assert scale >= 3 |
1094 | 1095 |
|
1095 | | - random = insecure_random.Random("opentelemetry2") |
| 1096 | + seed = randrange(maxsize) |
| 1097 | + # This test case is executed with random values every time. In order to |
| 1098 | + # run this test case with the same values used in a previous execution, |
| 1099 | + # check the value printed by that previous execution of this test case |
| 1100 | + # and use the same value for the seed variable in the line below. |
| 1101 | + # seed = 4539544373807492135 |
| 1102 | + print(f"seed for {currentframe().f_code.co_name} is {seed}") |
| 1103 | + |
1096 | 1104 | values = [] |
1097 | 1105 | for i in range(2000): |
1098 | | - value = random.randint(0, 1000) |
| 1106 | + value = Random(seed).randint(0, 1000) |
1099 | 1107 | values.append(value) |
1100 | 1108 | histogram.aggregate(Measurement(value, Mock())) |
1101 | 1109 | if i % 20 == 0: |
|
0 commit comments