Skip to content

Integer schema error happens when setting up precondition #336

@sallyr0823

Description

@sallyr0823

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions