Robottelo: Pagination control config not working for content host in host collection

Created on 1 Aug 2016  路  4Comments  路  Source: SatelliteQE/robottelo

See BZ 1343583

Bug CLI

All 4 comments

After playing around this issue, I found 3 approaches:

Changing cli_config.yml

In fact I have already pushed a version for it.

Pro

  • It test exactly what was described on BZ by the client
    Con
  • cli_config.yml is used globally for all calls, so there is a chance that it can affect another tests when running in multi thread environment

Passing another configuration file

Hammer cli accepts -c option to pass another configuration file when making calls.
Example:

hammer -u admin -p changeme -c /tmp/cli_config.yml --output json host-collection hosts --organization-id 3 --id 8

Result

[
  {
    "ID": 3,
    "Name": "fdaxvztljrfehac"
  },
  {
    "ID": 4,
    "Name": "hwhnekpyeodpdeh"
  }
]

Pro

  • A random file could be generated for each test not so it would not cause side effects when running in multi trhread
    Cons
  • Doesn't test exactly what was described on BZ
  • It would required some refactoring on base class to pass a -c option, once it current doesnt offer this paremetre. Another approache would be making a ssh comand directly to fethc data.

Using per_page parameter

Hammer cli subcommand accepts --per_page option. Example:

hammer -u admin -p changeme --output json host-collection hosts --organization-id 3 --id 8 --per_page 1

Result

[
  {
    "ID": 3,
    "Name": "fdaxvztljrfehac"
  }
]

Pro

  • Would not cause side effects when running in multi thread
  • Dont have to refactor code once host_colletcion hosts accepts this kind of option as parameter
    Cons
  • Most far from BZ description

I like the options 2 and 3 (passing -c or passing parameter directly and explicitly), we do not want to affect multi threading processes.

@rochacbruno: I am going with number 3 because it is easier. Besides that, I am including the manual test I done to check if both global and command configuration is working:

[root@foo ~]# grep per_page /etc/hammer/cli_config.yml 
  # :per_page: 20

[root@foo ~]# hammer -u admin -p changeme host-collection hosts --organization-id 3 --id 1 
---|----------------
ID | NAME           
---|----------------
2  | bizndtpogcpxiah
3  | wihfxmdfmpzxdjq
---|----------------

[root@foo ~]# hammer -u admin -p changeme host-collection hosts --organization-id 3 --id 1 --per-page 1
---|----------------
ID | NAME           
---|----------------
2  | bizndtpogcpxiah
---|----------------
Page 1 of 2 (use --page and --per-page for navigation)

[root@foo ~]# grep per_page /etc/hammer/cli_config.yml 
  :per_page: 1

[root@foo ~]# hammer -u admin -p changeme host-collection hosts --organization-id 3 --id 1 --per-page 2
---|----------------
ID | NAME           
---|----------------
2  | bizndtpogcpxiah
3  | wihfxmdfmpzxdjq
---|----------------

[root@foo ~]# hammer -u admin -p changeme host-collection hosts --organization-id 3 --id 1 
---|----------------
ID | NAME           
---|----------------
2  | bizndtpogcpxiah
---|----------------
Page 1 of 2 (use --page and --per-page for navigation)

worth mentioning that robottelo set --per_page to 10000 if that option is not defined check https://github.com/SatelliteQE/robottelo/blob/master/robottelo/cli/base.py#L332-L333 for more information.

Was this page helpful?
0 / 5 - 0 ratings