summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/test/integration/oc_scale.yml
blob: 43a42c5897a37425bd02e6804c48b0dcea7d9cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/ansible-playbook --module-path=../../../library/
# ./oc_scale.yml -e "cli_master_test=$OPENSHIFT_MASTER
---
- hosts: "{{ cli_master_test }}"
  gather_facts: no
  user: root
  tasks:
  - name: list oc scale for default router dc
    oc_scale:
      state: list
      name: router
      namespace: default
      kind: dc
    register: scaleout
  - debug: var=scaleout

  - assert:
      that:
      - "'result' in scaleout"
      - scaleout.result > 0
      msg: "Did not find 'result' in returned value or result not > 0."

  - name: get the rc for router
    oc_obj:
      state: list
      kind: dc
      namespace: default
      selector: router=router
    register: rcout
  - debug:
      msg: "{{ rcout.results.results[0]['items'][-1]['metadata']['name'] }}"

  - name: scale dc to 1
    oc_scale:
      name: router
      namespace: default
      kind: dc
      replicas: 1
    register: scaleout
  - debug: var=scaleout

  # The preferred method here would be to let the module
  # detect when its finished and time out
  - name: let the scale happen
    pause:
      seconds: 10
    when: scaleout.changed

  - name: fetch the current router pods
    oc_obj:
      selector: router=router
      namespace: default
      kind: pod
      state: list
    register: pods
  - debug: var=pods

  - assert:
      that:
      - "'results' in pods and 'results' in pods.results"
      - "{{ pods.results.results[0]['items']|length }} == 1"
      msg: "Did not find 1 replica in scale results."

  - name: scale dc to 2
    oc_scale:
      name: router
      namespace: default
      kind: dc
      replicas: 2
    register: scaleout
  - debug: var=scaleout

  # The preferred method here would be to let the module
  # detect when its finished and time out
  - name: let the scale happen
    pause:
      seconds: 30

  - name: fetch the current router pods
    oc_obj:
      selector: router=router
      namespace: default
      kind: pod
      state: list
    register: pods
  - debug: var=pods

  - assert:
      that:
      - "'results' in pods and 'results' in pods.results"
      - "{{ pods.results.results[0]['items']|length }} == 2"
      msg: "Did not find 1 replica in scale results."


  # Test scale on non-existent dc
  - name: scale non-existent dc
    oc_scale:
      name: not_there
      kind: dc
      replicas: 2
    register: scaleout
    ignore_errors: True

  - debug: var=scaleout

  - assert:
      that:
      - scaleout.changed == False
      - scaleout.msg.returncode == 1
      - "'msg' in scaleout and 'stderr' in scaleout.msg"
      msg: "Deploymentconfig exists.  This should error."