[Core] Make iterations numeration starting from `1'

As discussed on daily meeting, iterations numbers
in logging and reports must be synchronized and
starting from `1'

Change-Id: I5967c51b033e1a98f2617c5aa8f8e7916de90a08
This commit is contained in:
Alexander Maretskiy 2016-07-12 18:51:27 +03:00
parent 949b0ebca8
commit a082416462
2 changed files with 8 additions and 5 deletions

View File

@ -87,12 +87,15 @@ class UserContextMixin(object):
else:
# Second and last case - 'round_robin'.
tenants_amount = len(context_obj["tenants"])
tenant_id = sorted(context_obj["tenants"].keys())[
context_obj["iteration"] % tenants_amount]
# NOTE(amaretskiy): iteration is subtracted by `1' because it
# starts from `1' but we count from `0'
tenant_index = int((context_obj["iteration"] - 1) % tenants_amount)
tenant_id = sorted(context_obj["tenants"].keys())[tenant_index]
tenant = context_obj["tenants"][tenant_id]
users = context_obj["tenants"][tenant_id]["users"]
user = users[
int(context_obj["iteration"] / tenants_amount) % len(users)]
user_index = int(((context_obj["iteration"] - 1) / tenants_amount)
% len(users))
user = users[user_index]
scenario_ctx["user"], scenario_ctx["tenant"] = user, tenant

View File

@ -120,7 +120,7 @@ class UserContextMixinTestCase(test.TestCase):
}
expected_ids = ["0_0", "1_0", "0_1", "1_1"] * 4
mapped_ids = []
for i in range(16):
for i in range(1, 17):
context["iteration"] = i
user = self.mixin.map_for_scenario(context)
mapped_ids.append(user["user"]["id"])