Revision fdd9ac5b test/cfgupgrade_unittest.py

b/test/cfgupgrade_unittest.py
57 57
    self.config_path = utils.PathJoin(self.tmpdir, "config.data")
58 58
    self.noded_cert_path = utils.PathJoin(self.tmpdir, "server.pem")
59 59
    self.rapi_cert_path = utils.PathJoin(self.tmpdir, "rapi.pem")
60
    self.rapi_users_path = utils.PathJoin(self.tmpdir, "rapi", "users")
61
    self.rapi_users_path_pre24 = utils.PathJoin(self.tmpdir, "rapi_users")
60 62
    self.known_hosts_path = utils.PathJoin(self.tmpdir, "known_hosts")
61 63
    self.confd_hmac_path = utils.PathJoin(self.tmpdir, "hmac.key")
62 64
    self.cds_path = utils.PathJoin(self.tmpdir, "cluster-domain-secret")
......
122 124
    newcfg = self._LoadConfig()
123 125
    self.assertEqual(newcfg["version"], expversion)
124 126

  
127
  def testRapiUsers(self):
128
    self.assertFalse(os.path.exists(self.rapi_users_path))
129
    self.assertFalse(os.path.exists(self.rapi_users_path_pre24))
130

  
131
    utils.WriteFile(self.rapi_users_path_pre24, data="some user\n")
132
    self._TestSimpleUpgrade(constants.BuildVersion(2, 3, 0), False)
133

  
134
    self.assert_(os.path.islink(self.rapi_users_path_pre24))
135
    self.assert_(os.path.isfile(self.rapi_users_path))
136
    for path in [self.rapi_users_path, self.rapi_users_path_pre24]:
137
      self.assertEqual(utils.ReadFile(path), "some user\n")
138

  
139
  def testRapiUsers24AndAbove(self):
140
    self.assertFalse(os.path.exists(self.rapi_users_path))
141
    self.assertFalse(os.path.exists(self.rapi_users_path_pre24))
142

  
143
    os.mkdir(os.path.dirname(self.rapi_users_path))
144
    utils.WriteFile(self.rapi_users_path, data="other user\n")
145
    self._TestSimpleUpgrade(constants.BuildVersion(2, 3, 0), False)
146

  
147
    self.assert_(os.path.islink(self.rapi_users_path_pre24))
148
    self.assert_(os.path.isfile(self.rapi_users_path))
149
    for path in [self.rapi_users_path, self.rapi_users_path_pre24]:
150
      self.assertEqual(utils.ReadFile(path), "other user\n")
151

  
152
  def testRapiUsersExistingSymlink(self):
153
    self.assertFalse(os.path.exists(self.rapi_users_path))
154
    self.assertFalse(os.path.exists(self.rapi_users_path_pre24))
155

  
156
    os.symlink(self.rapi_users_path, self.rapi_users_path_pre24)
157
    utils.WriteFile(self.rapi_users_path_pre24, data="hello world\n")
158

  
159
    self._TestSimpleUpgrade(constants.BuildVersion(2, 2, 0), False)
160

  
161
    self.assert_(os.path.isfile(self.rapi_users_path))
162
    self.assert_(os.path.islink(self.rapi_users_path_pre24))
163
    for path in [self.rapi_users_path, self.rapi_users_path_pre24]:
164
      self.assertEqual(utils.ReadFile(path), "hello world\n")
165

  
125 166
  def testUpgradeFrom_2_0(self):
126 167
    self._TestSimpleUpgrade(constants.BuildVersion(2, 0, 0), False)
127 168

  
128 169
  def testUpgradeFrom_2_1(self):
129 170
    self._TestSimpleUpgrade(constants.BuildVersion(2, 1, 0), False)
130 171

  
172
  def testUpgradeFrom_2_2(self):
173
    self._TestSimpleUpgrade(constants.BuildVersion(2, 2, 0), False)
174

  
175
  def testUpgradeFrom_2_3(self):
176
    self._TestSimpleUpgrade(constants.BuildVersion(2, 3, 0), False)
177

  
131 178
  def testUpgradeCurrent(self):
132 179
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
133 180

  
......
137 184
  def testUpgradeDryRunFrom_2_1(self):
138 185
    self._TestSimpleUpgrade(constants.BuildVersion(2, 1, 0), True)
139 186

  
187
  def testUpgradeDryRunFrom_2_2(self):
188
    self._TestSimpleUpgrade(constants.BuildVersion(2, 2, 0), True)
189

  
190
  def testUpgradeDryRunFrom_2_3(self):
191
    self._TestSimpleUpgrade(constants.BuildVersion(2, 3, 0), True)
192

  
140 193
  def testUpgradeCurrentDryRun(self):
141 194
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, True)
142 195

  

Also available in: Unified diff