Revision 5d640672

b/qa/ganeti-qa.py
119 119
  try:
120 120
    if qa_config.TestEnabled('instance-add-plain-disk'):
121 121
      instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, node)
122
      RunTest(qa_instance.TestInstanceShutdown, instance)
123
      RunTest(qa_instance.TestInstanceStartup, instance)
122

  
123
      if qa_config.TestEnabled('instance-shutdown'):
124
        RunTest(qa_instance.TestInstanceShutdown, instance)
125
        RunTest(qa_instance.TestInstanceStartup, instance)
124 126

  
125 127
      if qa_config.TestEnabled('instance-info'):
126 128
        RunTest(qa_instance.TestInstanceInfo, instance)
......
131 133
      if qa_config.TestEnabled('instance-consecutive-failures'):
132 134
        RunTest(qa_daemon.TestInstanceConsecutiveFailures, node, instance)
133 135

  
136
      if qa_config.TestEnabled('instance-export'):
137
        expnode = qa_config.AcquireNode(exclude=node)
138
        try:
139
          name = RunTest(qa_instance.TestInstanceExport, instance, expnode)
140

  
141
          if qa_config.TestEnabled('instance-import'):
142
            newinst = qa_config.AcquireInstance()
143
            try:
144
              RunTest(qa_instance.TestInstanceImport, node, newinst,
145
                      expnode, name)
146
              RunTest(qa_instance.TestInstanceRemove, newinst)
147
            finally:
148
              qa_config.ReleaseInstance(newinst)
149
        finally:
150
          qa_config.ReleaseNode(expnode)
151

  
134 152
      if qa_config.TestEnabled('node-volumes'):
135 153
        RunTest(qa_node.TestNodeVolumes)
136 154

  
......
139 157

  
140 158
    if qa_config.TestEnabled('instance-add-local-mirror-disk'):
141 159
      instance = RunTest(qa_instance.TestInstanceAddWithLocalMirrorDisk, node)
142
      RunTest(qa_instance.TestInstanceShutdown, instance)
143
      RunTest(qa_instance.TestInstanceStartup, instance)
160

  
161
      if qa_config.TestEnabled('instance-shutdown'):
162
        RunTest(qa_instance.TestInstanceShutdown, instance)
163
        RunTest(qa_instance.TestInstanceStartup, instance)
144 164

  
145 165
      if qa_config.TestEnabled('instance-info'):
146 166
        RunTest(qa_instance.TestInstanceInfo, instance)
......
156 176
      try:
157 177
        instance = RunTest(qa_instance.TestInstanceAddWithRemoteRaidDisk,
158 178
                           node, node2)
159
        RunTest(qa_instance.TestInstanceShutdown, instance)
160
        RunTest(qa_instance.TestInstanceStartup, instance)
179

  
180
        if qa_config.TestEnabled('instance-shutdown'):
181
          RunTest(qa_instance.TestInstanceShutdown, instance)
182
          RunTest(qa_instance.TestInstanceStartup, instance)
161 183

  
162 184
        if qa_config.TestEnabled('instance-info'):
163 185
          RunTest(qa_instance.TestInstanceInfo, instance)
b/qa/qa-sample.yaml
41 41
  instance-add-remote-raid-disk: True
42 42
  instance-failover: True
43 43
  instance-info: True
44
  instance-export: True
45
  instance-import: True
46
  instance-shutdown: True
44 47

  
45 48
  # This test takes up to 6 minutes to complete
46 49
  instance-automatic-restart: False
b/qa/qa_daemon.py
21 21
"""
22 22

  
23 23
import time
24
import subprocess
25 24

  
26 25
from ganeti import utils
27 26
from ganeti import constants
......
33 32
from qa_utils import AssertEqual, StartSSH
34 33

  
35 34

  
36
def _ResolveInstanceName(instance):
37
  """Gets the full Xen name of an instance.
38

  
39
  """
40
  master = qa_config.GetMasterNode()
41

  
42
  info_cmd = utils.ShellQuoteArgs(['gnt-instance', 'info', instance['name']])
43
  sed_cmd = utils.ShellQuoteArgs(['sed', '-n', '-e', 's/^Instance name: *//p'])
44

  
45
  cmd = '%s | %s' % (info_cmd, sed_cmd)
46
  ssh_cmd = qa_utils.GetSSHCommand(master['primary'], cmd)
47
  p = subprocess.Popen(ssh_cmd, shell=False, stdout=subprocess.PIPE)
48
  AssertEqual(p.wait(), 0)
49

  
50
  return p.stdout.read().strip()
51

  
52

  
53 35
def _InstanceRunning(node, name):
54 36
  """Checks whether an instance is running.
55 37

  
......
72 54
  master = qa_config.GetMasterNode()
73 55

  
74 56
  cmd = ['xm', 'shutdown', name]
75
  AssertEqual(StartSSH(master['primary'],
57
  AssertEqual(StartSSH(node['primary'],
76 58
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
77 59

  
78 60
  # Wait up to a minute
......
102 84
  Note: takes up to 6 minutes to complete.
103 85
  """
104 86
  master = qa_config.GetMasterNode()
105
  inst_name = _ResolveInstanceName(instance)
87
  inst_name = qa_utils.ResolveInstanceName(instance)
106 88

  
107 89
  _ResetWatcherDaemon(node)
108 90
  _XmShutdownInstance(node, inst_name)
......
129 111
  Note: takes at least 35 minutes to complete.
130 112
  """
131 113
  master = qa_config.GetMasterNode()
132
  inst_name = _ResolveInstanceName(instance)
114
  inst_name = qa_utils.ResolveInstanceName(instance)
133 115

  
134 116
  _ResetWatcherDaemon(node)
135 117
  _XmShutdownInstance(node, inst_name)
b/qa/qa_instance.py
21 21
"""
22 22

  
23 23
from ganeti import utils
24
from ganeti import constants
24 25

  
25 26
import qa_config
27
import qa_utils
26 28

  
27 29
from qa_utils import AssertEqual, StartSSH
28 30

  
29 31

  
32
def _GetGenericAddParameters():
33
  return ['--os-size=%s' % qa_config.get('os-size'),
34
          '--swap-size=%s' % qa_config.get('swap-size'),
35
          '--memory=%s' % qa_config.get('mem')]
36

  
37

  
30 38
def _DiskTest(node, args):
31 39
  master = qa_config.GetMasterNode()
32 40

  
33 41
  instance = qa_config.AcquireInstance()
34 42
  try:
35
    cmd = ['gnt-instance', 'add',
36
           '--os-type=%s' % qa_config.get('os'),
37
           '--os-size=%s' % qa_config.get('os-size'),
38
           '--swap-size=%s' % qa_config.get('swap-size'),
39
           '--memory=%s' % qa_config.get('mem'),
40
           '--node=%s' % node['primary']]
43
    cmd = (['gnt-instance', 'add',
44
            '--os-type=%s' % qa_config.get('os'),
45
            '--node=%s' % node['primary']] +
46
           _GetGenericAddParameters())
41 47
    if args:
42 48
      cmd += args
43 49
    cmd.append(instance['name'])
......
112 118
  cmd = ['gnt-instance', 'info', instance['name']]
113 119
  AssertEqual(StartSSH(master['primary'],
114 120
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
121

  
122

  
123
def TestInstanceExport(instance, node):
124
  """gnt-backup export"""
125
  master = qa_config.GetMasterNode()
126

  
127
  cmd = ['gnt-backup', 'export', '-n', node['primary'], instance['name']]
128
  AssertEqual(StartSSH(master['primary'],
129
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
130

  
131
  return qa_utils.ResolveInstanceName(instance)
132

  
133

  
134
def TestInstanceImport(node, newinst, expnode, name):
135
  """gnt-backup import"""
136
  master = qa_config.GetMasterNode()
137

  
138
  cmd = (['gnt-backup', 'import',
139
          '--disk-template=plain',
140
          '--no-ip-check',
141
          '--src-node=%s' % expnode['primary'],
142
          '--src-dir=%s/%s' % (constants.EXPORT_DIR, name),
143
          '--node=%s' % node['primary']] +
144
         _GetGenericAddParameters())
145
  cmd.append(newinst['name'])
146
  AssertEqual(StartSSH(master['primary'],
147
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
b/qa/qa_utils.py
96 96
    return p.stdout.read().strip()
97 97
  finally:
98 98
    f.close()
99
# }}}
99

  
100

  
101
def ResolveInstanceName(instance):
102
  """Gets the full name of an instance.
103

  
104
  """
105
  master = qa_config.GetMasterNode()
106

  
107
  info_cmd = utils.ShellQuoteArgs(['gnt-instance', 'info', instance['name']])
108
  sed_cmd = utils.ShellQuoteArgs(['sed', '-n', '-e', 's/^Instance name: *//p'])
109

  
110
  cmd = '%s | %s' % (info_cmd, sed_cmd)
111
  ssh_cmd = GetSSHCommand(master['primary'], cmd)
112
  p = subprocess.Popen(ssh_cmd, shell=False, stdout=subprocess.PIPE)
113
  AssertEqual(p.wait(), 0)
114

  
115
  return p.stdout.read().strip()

Also available in: Unified diff