Revision fe81ddd7 snf-tools/synnefo_tools/burnin/pithos_tests.py

b/snf-tools/synnefo_tools/burnin/pithos_tests.py
198 198
        self.info('Container meta exists')
199 199

  
200 200
        self.obj_metakey = 'metakey%s' % random.randint(1000, 9999)
201
        obj = 'object%s' % random.randint(1000, 9999)
201
        obj = 'object_with_meta'
202 202
        pithos.create_object(obj)
203 203
        pithos.set_object_meta(obj, {self.obj_metakey: 'our value'})
204 204
        r = pithos.get_container_object_meta()
......
268 268
        except ClientError:
269 269
            pass
270 270

  
271
    # def test_050_stop_test(self):
272
    #     """STOP TESTING ALREADY"""
273
    #     self.assertTrue(False)
271
    def test_030_container_put(self):
272
        """Test container PUT"""
273
        pithos = self.clients.pithos
274
        pithos.container = 'cont%s%s' % (
275
            self.run_id or 0, random.randint(1000, 9999))
276
        self.temp_containers.append(pithos.container)
277

  
278
        r = pithos.create_container()
279
        self.assertTrue(isinstance(r, dict))
280

  
281
        r = pithos.get_container_limit(pithos.container)
282
        cquota = r.values()[0]
283
        newquota = 2 * int(cquota)
284
        self.info('Limit is OK')
285
        pithos.del_container()
286

  
287
        r = pithos.create_container(sizelimit=newquota)
288
        self.assertTrue(isinstance(r, dict))
289

  
290
        r = pithos.get_container_limit(pithos.container)
291
        xquota = int(r.values()[0])
292
        self.assertEqual(newquota, xquota)
293
        self.info('Can set container limit')
294
        pithos.del_container()
295

  
296
        r = pithos.create_container(versioning='auto')
297
        self.assertTrue(isinstance(r, dict))
298

  
299
        r = pithos.get_container_versioning(pithos.container)
300
        nvers = r.values()[0]
301
        self.assertEqual('auto', nvers)
302
        self.info('Versioning=auto is OK')
303
        pithos.del_container()
304

  
305
        r = pithos.container_put(versioning='none')
306
        self.assertEqual(r.status_code, 201)
307

  
308
        r = pithos.get_container_versioning(pithos.container)
309
        nvers = r.values()[0]
310
        self.assertEqual('none', nvers)
311
        self.info('Versioning=none is OK')
312
        pithos.del_container()
313

  
314
        r = pithos.create_container(metadata={'m1': 'v1', 'm2': 'v2'})
315
        self.assertTrue(isinstance(r, dict))
316

  
317
        r = pithos.get_container_meta(pithos.container)
318
        self.assertTrue('x-container-meta-m1' in r)
319
        self.assertEqual(r['x-container-meta-m1'], 'v1')
320
        self.assertTrue('x-container-meta-m2' in r)
321
        self.assertEqual(r['x-container-meta-m2'], 'v2')
322

  
323
        r = pithos.container_put(metadata={'m1': '', 'm2': 'v2a'})
324
        self.assertEqual(r.status_code, 202)
325

  
326
        r = pithos.get_container_meta(pithos.container)
327
        self.assertTrue('x-container-meta-m1' not in r)
328
        self.assertTrue('x-container-meta-m2' in r)
329
        self.assertEqual(r['x-container-meta-m2'], 'v2a')
330
        self.info('Container meta is OK')
331

  
332
        pithos.del_container_meta(pithos.container)
333

  
334
    def test_035_container_post(self):
335
        """Test container POST"""
336
        pithos = self.clients.pithos
337

  
338
        r = pithos.container_post()
339
        self.assertEqual(r.status_code, 202)
340
        self.info('Status is OK')
341

  
342
        pithos.set_container_meta({'m1': 'v1', 'm2': 'v2'})
343
        r = pithos.get_container_meta(pithos.container)
344
        self.assertTrue('x-container-meta-m1' in r)
345
        self.assertEqual(r['x-container-meta-m1'], 'v1')
346
        self.assertTrue('x-container-meta-m2' in r)
347
        self.assertEqual(r['x-container-meta-m2'], 'v2')
348
        self.info('Set metadata works')
349

  
350
        r = pithos.del_container_meta('m1')
351
        r = pithos.set_container_meta({'m2': 'v2a'})
352
        r = pithos.get_container_meta(pithos.container)
353
        self.assertTrue('x-container-meta-m1' not in r)
354
        self.assertTrue('x-container-meta-m2' in r)
355
        self.assertEqual(r['x-container-meta-m2'], 'v2a')
356
        self.info('Delete metadata works')
357

  
358
        r = pithos.get_container_limit(pithos.container)
359
        cquota = r.values()[0]
360
        newquota = 2 * int(cquota)
361
        r = pithos.set_container_limit(newquota)
362
        r = pithos.get_container_limit(pithos.container)
363
        xquota = int(r.values()[0])
364
        self.assertEqual(newquota, xquota)
365
        self.info('Set quota works')
366

  
367
        pithos.set_container_versioning('auto')
368
        r = pithos.get_container_versioning(pithos.container)
369
        nvers = r.values()[0]
370
        self.assertEqual('auto', nvers)
371
        pithos.set_container_versioning('none')
372
        r = pithos.get_container_versioning(pithos.container)
373
        nvers = r.values()[0]
374
        self.assertEqual('none', nvers)
375
        self.info('Set versioning works')
376

  
377
        f = self._create_large_file(1024 * 1024 * 100)
378
        self.info('Created file %s of 100 MB' % f.name)
379

  
380
        pithos.create_directory('dir')
381
        r = pithos.upload_object('/dir/sample.file', f)
382
        for term in ('content-length', 'content-type', 'x-object-version'):
383
            self.assertTrue(term in r)
384
        r = pithos.get_object_info('/dir/sample.file')
385
        self.assertTrue(int(r['content-length']) > 100000000)
386
        self.info('Made remote directory /dir and object /dir/sample.file')
387

  
388
        """What is tranfer_encoding? What should I check about it? """
389
        #TODO
390

  
391
        obj = 'object_with_meta'
392
        pithos.container = self.temp_containers[-2]
393
        r = pithos.object_post(
394
            obj, update='False', metadata={'newmeta': 'newval'})
395

  
396
        r = pithos.get_object_info(obj)
397
        self.assertTrue('x-object-meta-newmeta' in r)
398
        self.assertFalse('x-object-meta-%s' % self.obj_metakey not in r)
399
        self.info('Metadata with update=False works')
400

  
401
    def test_050_stop_test(self):
402
        """STOP TESTING ALREADY"""
403
        self.assertTrue(False)
274 404

  
275 405
    def test_051_list_containers(self):
276 406
        """Test container list actually returns containers"""
......
284 414
        names = sorted(names)
285 415
        self.assertEqual(sorted(list(set(names))), names)
286 416

  
287
    def test_053_create_container(self):
288
        """Test creating a new container"""
289
        names = [n['name'] for n in self.containers]
290
        while True:
291
            rand_num = random.randint(1000, 9999)
292
            rand_name = "%s%s" % (self.run_id or 0, rand_num)
293
            self.info("Trying container name %s", rand_name)
294
            if rand_name not in names:
295
                break
296
            self.info("Container name %s already exists", rand_name)
297
        # Create container
298
        self._create_pithos_container(rand_name)
299
        # Verify that container is created
300
        containers = self._get_list_of_containers()
301
        self.info("Verify that container %s is created", rand_name)
302
        names = [n['name'] for n in containers]
303
        self.assertIn(rand_name, names)
304
        # Keep the name of the container so we can remove it
305
        # at cleanup phase, if something goes wrong.
306
        self.created_container = rand_name
307

  
308 417
    def test_054_upload_file(self):
309 418
        """Test uploading a txt file to Pithos"""
310 419
        # Create a tmp file

Also available in: Unified diff