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

Integer schema error happens when setting up precondition #336

Open
sallyr0823 opened this issue Feb 29, 2024 · 2 comments
Open

Integer schema error happens when setting up precondition #336

sallyr0823 opened this issue Feb 29, 2024 · 2 comments
Assignees

Comments

@sallyr0823
Copy link

I'm using percona-postgres-operator. When configure precondition, some field will fail. Then it will be manually set up based on engine.py(line 466~):

  # precondition fails, first run setup
  logger.info(
      "Precondition of %s fails, try setup first",
      field_path_str,
  )

  self.apply_testcase_f(
      curr_input_with_schema,
      field_path,
      testcase,
      setup=True,
if not testcase.test_precondition(
          curr_input_with_schema.get_value_by_path(
              list(field_path)
          )
      ):
          # just in case the setup does not work correctly, drop this testcase
          logger.error("Setup does not work correctly")
          group.discard_testcase(self.discarded_testcases)
          continue
  )

For example, in this case precondition fails because it's not present in custom resource yaml file. Then it will aotu-generate a value for the field.
image

While in integer.py in schema, there may incur <IndexError> or <Value Error> due to wrong random.choice range. The error will cause whole thread to crash and exit.

  if exclude_value is not None:
      return random.choice(
          [
              x
              for x in range(self.minimum + 1, self.maximum + 1)
              if x != exclude_value
          ]
      )
  else:
      return random.randrange(self.minimum + 1, self.maximum + 1)

@tylergu tylergu self-assigned this Feb 29, 2024
@tylergu
Copy link
Member

tylergu commented Feb 29, 2024

Thanks for reporting this @sallyr0823 ! Will be fixed soon

@tianyin
Copy link
Member

tianyin commented Feb 29, 2024

@sallyr0823 would you be able to help us fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants