Ejemplo n.º 1
0
 def testDeleteAnonymous(self):
     # test delete works with anonymous dataset
     domain = 'tall_dset22_deleted.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     g2_uuid = helper.getUUID(domain, root_uuid, 'g2')
     self.assertTrue(helper.validateId(g2_uuid))
     d22_uuid = helper.getUUID(domain, g2_uuid, 'dset2.2')
     self.assertTrue(helper.validateId(d22_uuid))
     
     # delete g2, that will make dataset anonymous
     req = self.endpoint + "/groups/" + g2_uuid
     headers = {'host': domain}
     rsp = requests.delete(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     
     # verify that a GET on the dataset succeeds still
     req = helper.getEndpoint() + "/datasets/" + d22_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     
     # delete dataset...
     req = self.endpoint + "/datasets/" + d22_uuid
     headers = {'host': domain}
     rsp = requests.delete(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     
     # verify that a GET on the dataset fails
     req = helper.getEndpoint() + "/datasets/" + d22_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 410)
Ejemplo n.º 2
0
 def testGet(self):
     for domain_name in ('tall', 'tall_ro'):
         domain = domain_name + '.' + config.get('domain') 
         rootUUID = helper.getRootUUID(domain)
         g1UUID = helper.getUUID(domain, rootUUID, 'g1')
         g11UUID = helper.getUUID(domain, g1UUID, 'g1.1')
            
         # rank 1 dataset
         dset112UUID = helper.getUUID(domain, g11UUID, 'dset1.1.2') 
         req = helper.getEndpoint() + "/datasets/" + dset112UUID
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertEqual(rspJson['id'], dset112UUID)
         typeItem = rspJson['type']  
         self.assertEqual(typeItem['base'], 'H5T_STD_I32BE')
         shape = rspJson['shape']
         self.assertEqual(shape['class'], 'H5S_SIMPLE')
         self.assertEqual(len(shape['dims']), 1)
         self.assertEqual(shape['dims'][0], 20)  
         req = helper.getEndpoint() + "/datasets/" + dset112UUID + "/value"
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         data = rspJson['value'] 
         self.assertEqual(len(data), 20)
         for i in range(20):
             self.assertEqual(data[i], i)
     
         # rank 2 dataset
         dset111UUID = helper.getUUID(domain, g11UUID, 'dset1.1.1') 
         req = helper.getEndpoint() + "/datasets/" + dset111UUID
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertEqual(rspJson['id'], dset111UUID)
         typeItem = rspJson['type']  
         self.assertEqual(typeItem['base'], 'H5T_STD_I32BE')
         shape = rspJson['shape']
         self.assertEqual(shape['class'], 'H5S_SIMPLE')
         self.assertEqual(len(shape['dims']), 2)
         self.assertEqual(shape['dims'][0], 10) 
         self.assertEqual(shape['dims'][1], 10)    
         req = helper.getEndpoint() + "/datasets/" + dset111UUID + "/value"
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         data = rspJson['value'] 
         self.assertEqual(len(data), 10)  
         for i in range(10):
             arr = data[i]
             self.assertEqual(len(arr), 10)
             for j in range(10):
                 self.assertEqual(arr[j], i*j)
Ejemplo n.º 3
0
    def testGetDimensionScale(self):
        domain = 'dim_scale.' + config.get('domain')  
        root_uuid = helper.getRootUUID(domain)
        dset_uuid = helper.getUUID(domain, root_uuid, 'temperatures') 
        scale_x_uuid = helper.getUUID(domain, root_uuid, 'scale_x') 
        scale_y_uuid = helper.getUUID(domain, root_uuid, 'scale_y') 
        scale_z_uuid = helper.getUUID(domain, root_uuid, 'scale_z') 
        # now try reading the dimension list attribute
        req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/DIMENSION_LIST"
        headers = {'host': domain}
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        shape = rspJson['shape']
        self.assertEqual(shape['class'], 'H5S_SIMPLE')
        self.assertTrue('dims'  in shape)
        dims = shape['dims']
        self.assertEqual(len(dims), 1)
        self.assertEqual(dims[0], 3)

        typeItem = rspJson['type']
        self.assertEqual(typeItem['class'], 'H5T_VLEN')
        baseType = typeItem['base']
        self.assertEqual(baseType['class'], 'H5T_REFERENCE')
        self.assertEqual(baseType['base'], 'H5T_STD_REF_OBJ')
        data = rspJson['value'] 
        self.assertEqual(len(data), 3)
        self.assertEqual(data[0], ['datasets/' + scale_x_uuid])
        self.assertEqual(data[1], ['datasets/' + scale_y_uuid])
        self.assertEqual(data[2], ['datasets/' + scale_z_uuid])

        # read the x dimenscale and verify it refernces the temperature dataset
        req = helper.getEndpoint() + "/datasets/" + scale_x_uuid + "/attributes/REFERENCE_LIST"
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        typeItem = rspJson['type']
        self.assertEqual(typeItem['class'], 'H5T_COMPOUND')
        fields = typeItem['fields']
        self.assertEqual(len(fields), 2)
        refType = fields[0]["type"]
        self.assertEqual(refType["class"], 'H5T_REFERENCE')
        intType = fields[1]["type"]
        self.assertEqual(intType["class"], 'H5T_INTEGER')
        shape = rspJson['shape']
        self.assertEqual(shape['class'], 'H5S_SIMPLE')
        self.assertTrue('dims'  in shape)
        dims = shape['dims']
        self.assertEqual(len(dims), 1)
        self.assertEqual(dims[0], 1)
        data = rspJson['value']
        elem = data[0]
       
        self.assertEqual(len(elem), 2)  # two fields of a compound type
        self.assertEqual(elem[0], 'datasets/' + dset_uuid) #  reference primary dataset
        self.assertEqual(elem[1], 0)  # first dimension    
Ejemplo n.º 4
0
 def testGetResizable(self):
     domain = 'resizable.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     resizable_1d_uuid = helper.getUUID(domain, root_uuid, 'resizable_1d') 
     req = helper.getEndpoint() + "/datasets/" + resizable_1d_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('shape' in rspJson)
     shape = rspJson['shape']
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 10)  
     self.assertEqual(shape['maxdims'][0], 20)  
     
     resizable_2d_uuid = helper.getUUID(domain, root_uuid, 'resizable_2d') 
     req = helper.getEndpoint() + "/datasets/" + resizable_2d_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('shape' in rspJson)
     shape = rspJson['shape']
     self.assertEqual(len(shape['dims']), 2)
     self.assertEqual(shape['dims'][1], 10)  
     self.assertTrue('maxdims'  in shape)  # is re-sizeable!
     self.assertEqual(shape['maxdims'][1], 20)
     
     unlimited_1d_uuid = helper.getUUID(domain, root_uuid, 'unlimited_1d') 
     req = helper.getEndpoint() + "/datasets/" + unlimited_1d_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('shape' in rspJson)
     shape = rspJson['shape']
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 10)  
     self.assertTrue('maxdims' in shape)  # is re-sizeable
     self.assertEqual(shape['maxdims'][0], 0)
     
     unlimited_2d_uuid = helper.getUUID(domain, root_uuid, 'unlimited_2d') 
     req = helper.getEndpoint() + "/datasets/" + unlimited_2d_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('shape' in rspJson)
     shape = rspJson['shape']
     self.assertEqual(len(shape['dims']), 2)
     self.assertEqual(shape['dims'][1], 10)  
     self.assertTrue('maxdims' in shape)  # is re-sizeable
     self.assertEqual(shape['maxdims'][1], 0)
Ejemplo n.º 5
0
 def testGetSimpleOneElement(self):
     domain = 'scalar.' + config.get('domain') 
     headers = {'host': domain} 
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, '1d') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     data = rspJson['value'] 
     self.assertEqual(data, [42,])
Ejemplo n.º 6
0
 def testGetDatasetAttr(self):
     for domain_name in ('tall',  'tall_ro'):
         domain = domain_name + '.' + config.get('domain') 
         rootUUID = helper.getRootUUID(domain)
         # get dataset uuid at path: 'g1/g1.1/dset1.1.1'
         req = helper.getEndpoint() + "/groups/" + rootUUID + "/links/g1"
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertTrue('link' in rspJson)
         link = rspJson['link']
         g1UUID = link['id']
         req = helper.getEndpoint() + "/groups/" + g1UUID + "/links/g1.1"
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertTrue('link' in rspJson)
         link = rspJson['link']
         g11UUID = link['id']
         req = helper.getEndpoint() + "/groups/" + g11UUID + "/links/dset1.1.1"
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertTrue('link' in rspJson)
         link = rspJson['link']
         dset111UUID = link['id']
         
         req = helper.getEndpoint() + "/datasets/" + dset111UUID + "/attributes/attr1"
         rsp = requests.get(req, headers=headers)
         rspJson = json.loads(rsp.text)
        
         self.assertEqual(rspJson['name'], 'attr1')
         self.assertTrue('type' in rspJson)
         type = rspJson['type']
         self.assertEqual(type['class'], 'H5T_INTEGER')
         self.assertEqual(type['base'], 'H5T_STD_I8LE')
         self.assertTrue('shape' in rspJson)
         shape = rspJson['shape']
         self.assertEqual(shape['class'], 'H5S_SIMPLE')
         self.assertEqual(len(shape['dims']), 1)
         self.assertEqual(shape['dims'][0], 27) 
         self.assertTrue('maxdims' not in shape) 
         data = rspJson['value'] 
         self.assertEqual(len(data), 27)
         # first value is 49           
         self.assertEqual(data[0], 49) 
         self.assertEqual(len(rspJson['hrefs']), 4)
Ejemplo n.º 7
0
 def testGetBatch(self):
     domain = 'attr1k.' + config.get('domain')   
     rootUUID = helper.getRootUUID(domain)     
     req = helper.getEndpoint() + "/groups/" + rootUUID + "/attributes"
     headers = {'host': domain}
     params = {'Limit': 50 }
     names = set()
     # get attributes in 20 batches of 50 links each
     lastName = None
     for batchno in range(20):
         if lastName:
             params['Marker'] = lastName
         rsp = requests.get(req, headers=headers, params=params)
         self.failUnlessEqual(rsp.status_code, 200)
         if rsp.status_code != 200:
             break
         rspJson = json.loads(rsp.text)
         attrs = rspJson['attributes']
         self.failUnlessEqual(len(attrs) <= 50, True)
         for attr in attrs:
             lastName = attr['name']
             names.add(lastName)
         if len(attrs) == 0:
             break
     self.failUnlessEqual(len(names), 1000)  # should get 1000 unique attributes
Ejemplo n.º 8
0
 def testQueryBatch(self):
     domain = 'compound.' + config.get('domain')  
     headers = {'host': domain}
     root_uuid = helper.getRootUUID(domain)
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"  
     start = 0
     stop = 72
     count = 0
     count = req_count=0
     limit = 10
     req += "?query=date == 23"     # values where date field = 23
     req += "&Limit=" + str(limit)  # return no more than 10 results at a time
     for i in range(50):
         sreq = req+"&select=[" + str(start) + ":" + str(stop) + "]" 
         rsp = requests.get(sreq, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         req_count += 1
         rspJson = json.loads(rsp.text)
         self.assertTrue('hrefs' in rspJson)
         self.assertTrue('index' in rspJson)
         index = rspJson['index']
         self.assertTrue(len(index) <= limit)
         self.assertTrue('value' in rspJson)
         value = rspJson['value']
         self.assertEqual(len(value), len(index))
         count += len(index)
         if len(index) < limit:
             break  # no more results
         start = index[-1] + 1  # start at next index
     self.assertEqual(count, 24)
     self.assertEqual(req_count, 3)
Ejemplo n.º 9
0
 def testQueries(self):
     # use '%26' rather than '&' since otherwise it will be 
     # interpreted as a http query param seperator
     queries = { "date == 23": 24,
                 "wind == 'W 5'": 3,
                 "temp > 61": 53,
                 "(date >=22) %26 (date <= 24)": 62,
                 "(date == 21) %26 (temp > 70)": 4,
                 "(wind == 'E 7') | (wind == 'S 7')": 7 }
    
     #queries = {    "(date == 21) %26 (temp >= 72)": 4 }
     domain = 'compound.' + config.get('domain') 
     headers = {'host': domain} 
     root_uuid = helper.getRootUUID(domain)
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     for key in queries.keys():
         query = req + "?query=" + key
         rsp = requests.get(query, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertTrue('hrefs' in rspJson)
         self.assertTrue('index' in rspJson)
         index = rspJson['index']
         self.assertTrue(len(index), queries[key])
         self.assertTrue('value' in rspJson)
         value = rspJson['value']
         self.assertEqual(len(value), queries[key])
Ejemplo n.º 10
0
 def testGetArray(self):
     domain = 'array_attr.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/A1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 4) 
     typeItem = rspJson['type']    
     self.assertEqual(typeItem['class'], 'H5T_ARRAY')
     self.assertTrue('dims' in typeItem)
     typeShape = typeItem['dims']
     self.assertEqual(len(typeShape), 2)
     self.assertEqual(typeShape[0], 3)
     self.assertEqual(typeShape[1], 5)
     typeBase = typeItem['base']
     self.assertEqual(typeBase['class'], 'H5T_INTEGER')
     self.assertEqual(typeBase['base'], 'H5T_STD_I64LE')
     # bug! - unable to read value from attribute with array type
     # code is not returning 'value' key in this case
     # h5py issue: https://github.com/h5py/h5py/issues/498 
     if 'value' in rspJson:
         print 'remove above if check once h5py 2.4 is released'
         self.assertTrue('value' in rspJson)
         value = rspJson['value']
         self.assertEqual(len(value), 4)
         elem = value[0] # elem should be a 3x5 array 
         self.assertEqual(elem[2], [0, -2, -4, -6, -8])
Ejemplo n.º 11
0
 def testGetFixedString(self):
     domain = 'fixed_string_attr.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/A1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 4)  
     typeItem = rspJson['type']
     
     self.assertEqual(typeItem['class'], 'H5T_STRING')
     self.assertEqual(typeItem['cset'], 'H5T_CSET_ASCII')
     self.assertEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.assertEqual(typeItem['strsize'], 7)
     self.assertEqual(typeItem['strpad'], 'H5T_STR_NULLPAD')
     self.assertTrue('value' in rspJson)
     value = rspJson['value']
     self.assertEqual(len(value), 4) 
     self.assertEqual(value[0], "Parting")
     self.assertEqual(value[1], "is such")
     self.assertEqual(value[2], "sweet")
     self.assertEqual(value[3], "sorrow.")
Ejemplo n.º 12
0
 def testGet(self):
     for domain_name in ('tall', 'tall_ro'):
         domain = domain_name + '.' + config.get('domain') 
         rootUUID = helper.getRootUUID(domain)
         req = helper.getEndpoint() + "/groups/" + rootUUID + "/attributes/attr1"
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertEqual(rspJson['name'], 'attr1')
         self.assertTrue('type' in rspJson)
         type = rspJson['type']
         self.assertEqual(type['class'], 'H5T_INTEGER')
         self.assertEqual(type['base'], 'H5T_STD_I8LE')
         self.assertTrue('shape' in rspJson)
         shape = rspJson['shape']
         self.assertEqual(shape['class'], 'H5S_SIMPLE')
         self.assertEqual(len(shape['dims']), 1)
         self.assertEqual(shape['dims'][0], 10) 
         self.assertTrue('maxdims' not in shape) 
         data = rspJson['value'] 
         self.assertEqual(len(data), 10)
         # data should be the array [97, 98, 99, ..., 105, 0]
         expected = range(97, 107)
         expected[9] = 0
         self.assertEqual(data, expected) 
         self.assertEqual(len(rspJson['hrefs']), 4)
Ejemplo n.º 13
0
 def testGetVlen(self):
     domain = 'vlen_attr.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/A1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 2)
     typeItem = rspJson['type']
     
     self.assertEqual(typeItem['class'], 'H5T_VLEN')
     baseType = typeItem['base']
     self.assertEqual(baseType['class'], 'H5T_INTEGER')
     self.assertEqual(baseType['base'], 'H5T_STD_I32LE')
     #verify data returned
     value = rspJson['value']
     self.assertEqual(len(value), 2)
     self.assertEqual(len(value[1]), 12)
     self.assertEqual(value[1][11], 144)
Ejemplo n.º 14
0
 def testGetCompoundCommitted(self):
     domain = 'compound_committed.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 72)  
     typeItem = rspJson['type']   
     self.assertEqual(typeItem['class'], 'H5T_COMPOUND')
     self.assertTrue('fields' in typeItem)
     fields = typeItem['fields']
     self.assertEqual(len(fields), 3)
     timeField = fields[1]
     self.assertEqual(timeField['name'], 'time')
     self.assertTrue('type' in timeField)
     timeFieldType = timeField['type']
     self.assertEqual(timeFieldType['class'], 'H5T_STRING')
     self.assertEqual(timeFieldType['cset'], 'H5T_CSET_ASCII')
     self.assertEqual(timeFieldType['order'], 'H5T_ORDER_NONE')
     self.assertEqual(timeFieldType['strsize'], 6)
     self.assertEqual(timeFieldType['strpad'], 'H5T_STR_NULLPAD')
     tempField = fields[2]
     self.assertEqual(tempField['name'], 'temp')
     tempFieldType = tempField['type']
     self.assertEqual(tempFieldType['class'], 'H5T_INTEGER')
     self.assertEqual(tempFieldType['base'], 'H5T_STD_I32LE')
Ejemplo n.º 15
0
 def testGetArray(self):
     domain = 'array_dset.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 4)   
     typeItem = rspJson['type']
     
     self.assertEqual(typeItem['class'], 'H5T_ARRAY')
     self.assertTrue('dims' in typeItem)
     typeShape = typeItem['dims']
     self.assertEqual(len(typeShape), 2)
     self.assertEqual(typeShape[0], 3)
     self.assertEqual(typeShape[1], 5)
     typeItemBase = typeItem['base']
     self.assertEqual(typeItemBase['class'], 'H5T_INTEGER')
     self.assertEqual(typeItemBase['base'], 'H5T_STD_I64LE')
Ejemplo n.º 16
0
 def testGetEnum(self):
     domain = 'enum_dset.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 2)
     self.assertEqual(shape['dims'][0], 4)  
     self.assertEqual(shape['dims'][1], 7)
     typeItem = rspJson['type']
     
     self.assertEqual(typeItem['class'], 'H5T_ENUM')
     typeBase = typeItem['base']
     self.assertEqual(typeBase['class'], 'H5T_INTEGER')
     self.assertEqual(typeBase['base'], 'H5T_STD_I16BE')
     self.assertTrue('mapping' in typeItem)
     mapping = typeItem['mapping']
     self.assertEqual(len(mapping), 4)
     self.assertEqual(mapping['SOLID'], 0)
     self.assertEqual(mapping['LIQUID'], 1)
     self.assertEqual(mapping['GAS'], 2)
     self.assertEqual(mapping['PLASMA'], 3)
Ejemplo n.º 17
0
 def testPutExternalLink(self):
     logging.info("LinkTest.testPutExternalLink")
     domain = 'tall_updated.' + config.get('domain') 
     target_domain = 'external_target.' + config.get('domain')  
     target_path = '/dset1'
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'extlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"h5path": target_path, "h5domain": target_domain}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201) 
     # verify link is created
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     # verify that it is an external link
     rspJson = json.loads(rsp.text)   
     target = rspJson['link']
           
     self.failUnlessEqual(target['class'], 'H5L_TYPE_EXTERNAL')
     self.failUnlessEqual(target['h5domain'], target_domain)
     self.failUnlessEqual(target['h5path'], target_path)
Ejemplo n.º 18
0
 def testGetInvalidName(self):
     domain = 'tall.' + config.get('domain')
     rootUUID = helper.getRootUUID(domain)
     req = helper.getEndpoint() + "/groups/" + rootUUID + "/attributes/no_attr_here"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
Ejemplo n.º 19
0
 def testGetArray(self):
     domain = 'array_attr.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/A1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 4) 
     typeItem = rspJson['type']    
     self.assertEqual(typeItem['class'], 'H5T_ARRAY')
     self.assertTrue('dims' in typeItem)
     typeShape = typeItem['dims']
     self.assertEqual(len(typeShape), 2)
     self.assertEqual(typeShape[0], 3)
     self.assertEqual(typeShape[1], 5)
     typeBase = typeItem['base']
     self.assertEqual(typeBase['class'], 'H5T_INTEGER')
     self.assertEqual(typeBase['base'], 'H5T_STD_I64LE')
     self.assertTrue('value' in rspJson)
      
     value = rspJson['value']
     self.assertEqual(len(value), 4)   
     elem = value[0] # elem should be a 3x5 array 
     self.assertEqual(len(elem), 3)
     self.assertEqual(elem[2], [0, -2, -4, -6, -8])
Ejemplo n.º 20
0
 def testGetBatch(self):
     logging.info("LinkTest.testGetBatch")
     domain = 'group1k.' + config.get('domain')   
     root_uuid = helper.getRootUUID(domain)     
     req = helper.getEndpoint() + "/groups/" + root_uuid + "/links"
     headers = {'host': domain}
     params = {'Limit': 50 }
     names = set()
     # get links in 20 batches of 50 links each
     lastName = None
     for batchno in range(20):
         if lastName:
             params['Marker'] = lastName
         rsp = requests.get(req, headers=headers, params=params)
         self.failUnlessEqual(rsp.status_code, 200)
         if rsp.status_code != 200:
             break
         rspJson = json.loads(rsp.text)
         links = rspJson['links']
         self.failUnlessEqual(len(links) <= 50, True)
         for link in links:
             lastName = link['title']
             names.add(lastName)
         if len(links) == 0:
             break
     self.failUnlessEqual(len(names), 1000)  # should get 1000 unique links
Ejemplo n.º 21
0
 def testGetCompoundArray(self):
     for domain_name in ('compound_array_attr', ):
         domain = domain_name + '.' + config.get('domain') 
         root_uuid = helper.getRootUUID(domain)
         dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
         req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/attributes/A1"
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertEqual(rspJson['name'], 'A1')
         shape = rspJson['shape']
         self.assertEqual(shape['class'], 'H5S_SCALAR')
         typeItem = rspJson['type']
         self.assertEqual(typeItem['class'], 'H5T_COMPOUND')
         self.assertEqual(len(typeItem['fields']), 2)
         fields = typeItem['fields']
         field0 = fields[0]
         self.assertEqual(field0['name'], 'temp')
         field0Type = field0['type']
         self.assertEqual(field0Type['class'], 'H5T_FLOAT')
         self.assertEqual(field0Type['base'], 'H5T_IEEE_F64LE')
         field1 = fields[1]
         self.assertEqual(field1['name'], '2x2')
         field1Type = field1['type']
         self.assertEqual(field1Type['class'], 'H5T_ARRAY')
         self.assertEqual(field1Type['dims'], [2, 2])
         baseType = field1Type['base']
         self.assertEqual(baseType['class'], 'H5T_FLOAT')
         self.assertEqual(baseType['base'], 'H5T_IEEE_F32LE')
Ejemplo n.º 22
0
 def testDelete(self):
     domain = 'namedtype_deleted.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     dtype_uuid = helper.getUUID(domain, root_uuid, 'dtype_simple')
     self.assertTrue(helper.validateId(dtype_uuid))
      
     req = helper.getEndpoint() + "/datatypes/" + dtype_uuid
     headers = {'host': domain}
     rsp = requests.delete(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     
     # verify that it's gone
     req = helper.getEndpoint() + "/datatypes/" + dtype_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 410)
Ejemplo n.º 23
0
 def testBadQuery(self):
     domain = 'compound.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     req += "?query=foobar"  
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
Ejemplo n.º 24
0
 def testGetBadParam(self):
     logging.info("LinkTest.testGetBatchBadParam")
     domain = 'tall.' + config.get('domain')   
     root_uuid = helper.getRootUUID(domain)     
     req = helper.getEndpoint() + "/groups/" + root_uuid + "/links"
     headers = {'host': domain}
     params = {'Limit': 'abc' }
     rsp = requests.get(req, headers=headers, params=params)
     self.failUnlessEqual(rsp.status_code, 400)
Ejemplo n.º 25
0
 def testPutNoName(self):
     logging.info("LinkTest.testPutNoName")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/"  
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
Ejemplo n.º 26
0
 def testGetOpaque(self):
     domain = 'opaque_dset.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     # get for Opaque data is not supported yet.  Check that the call returns 501
     self.failUnlessEqual(rsp.status_code, 501)
Ejemplo n.º 27
0
 def testPutBadName(self):
     logging.info("LinkTest.testPutBadName")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)   
     name = 'bad/name'  # forward slash not allowed
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 400)
Ejemplo n.º 28
0
 def testPutBadReqId(self):
     logging.info("LinkTest.testPutBadReqId")
     domain = 'tall_updated.' + config.get('domain') 
     grpId = helper.createGroup(domain)
     badReqId  = 'b2771194-347f-11e4-bb67-3c15c2da029e' # doesn't exist in tall.h5
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + badReqId + "/links/" + name 
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
Ejemplo n.º 29
0
 def testGetSelectionBadQuery(self):
     domain = 'tall.' + config.get('domain')  
     headers = {'host': domain}
     rootUUID = helper.getRootUUID(domain)
     g1UUID = helper.getUUID(domain, rootUUID, 'g1')
     g11UUID = helper.getUUID(domain, g1UUID, 'g1.1')
            
     # rank 1 dataset
     dset112UUID = helper.getUUID(domain, g11UUID, 'dset1.1.2') 
      
     # pass in non-numeric start
     req = helper.getEndpoint() + "/datasets/" + dset112UUID + "/value" + \
          "?dim1_start=abc"
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
     
     # pass in 0 step
     req = helper.getEndpoint() + "/datasets/" + dset112UUID + "/value" + \
          "?dim1_start=2&dim1_step=0"
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)  
Ejemplo n.º 30
0
 def testGetCommitted(self):
     domain = 'committed_type.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1') 
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     data = rspJson['value'] 
     self.failUnlessEqual(len(data), 4)
Ejemplo n.º 31
0
 def testGetNullObjReference(self):
     domain = 'null_objref_dset.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('value' in rspJson)
     value = rspJson['value']
     self.assertEqual(len(value), 1)
     self.assertEqual(value[0], "null")
Ejemplo n.º 32
0
 def testGetSimpleOneElementString(self):
     domain = 'scalar.' + config.get('domain')
     headers = {'host': domain}
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, '1ds')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     data = rspJson['value']
     self.assertEqual(data, [
         "hello",
     ])
Ejemplo n.º 33
0
    def testGetDomainVerbose(self):
        domain = helper.getTestDomain("tall.h5")
        print("testGetDomainVerbose", domain)
        headers = helper.getRequestHeaders(domain=domain)

        req = helper.getEndpoint() + '/'
        params = {"verbose": 1}

        rsp = requests.get(req, params=params, headers=headers)
        if rsp.status_code == 404:
            print("WARNING: Failed to get domain: {}. Is test data setup?".
                  format(domain))
            return  # abort rest of test
        self.assertEqual(rsp.status_code, 200)
        self.assertEqual(rsp.headers['content-type'],
                         'application/json; charset=utf-8')
        rspJson = json.loads(rsp.text)

        for name in ("lastModified", "created", "hrefs", "root", "owner",
                     "class"):
            self.assertTrue(name in rspJson)
        now = time.time()
        self.assertTrue(rspJson["created"] < now - 10)
        self.assertTrue(rspJson["lastModified"] < now - 10)
        self.assertEqual(len(rspJson["hrefs"]), 7)
        self.assertTrue(rspJson["root"].startswith("g-"))
        self.assertTrue(rspJson["owner"])
        self.assertEqual(rspJson["class"], "domain")

        root_uuid = rspJson["root"]

        helper.validateId(root_uuid)

        # restore when sqlite changes are complete
        self.assertTrue("num_groups" in rspJson)
        self.assertEqual(rspJson["num_groups"], 6)
        self.assertTrue("num_datasets" in rspJson)
        self.assertEqual(rspJson["num_datasets"], 4)
        self.assertTrue("num_datatypes" in rspJson)
        self.assertEqual(rspJson["num_datatypes"], 0)
        self.assertTrue("allocated_bytes" in rspJson)
        # test that allocated_bytes falls in a given range

        self.assertEqual(rspJson["allocated_bytes"], 580)
        # total_size may change slightly based on specifics of JSON serialization
        self.assertTrue(rspJson["total_size"] > 5000)
        self.assertTrue(rspJson["total_size"] < 7000)
        # TODO - num_chunks should be present
        self.assertTrue("num_objects" in rspJson)
        self.assertTrue(rspJson["num_objects"], 14)
Ejemplo n.º 34
0
 def make_dset(parent_id, name):
     type_vstr = {"charSet": "H5T_CSET_ASCII",
         "class": "H5T_STRING",
         "strPad": "H5T_STR_NULLTERM",
         "length": "H5T_VARIABLE" }
     payload = {'type': type_vstr, 'shape': 10,
         'link': {'id': parent_id, 'name': name} }
     req = helper.getEndpoint() + "/datasets"
     rsp = requests.post(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 201)  # create dataset
     rspJson = json.loads(rsp.text)
     dset_id = rspJson["id"]
     self.assertTrue(helper.validateId(dset_id))
     return dset_id
Ejemplo n.º 35
0
 def testGetFill(self):
     domain = 'fillvalue.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertEqual(rspJson['class'], 'H5S_SIMPLE')
     self.assertEqual(len(rspJson['dims']), 2)
     self.assertEqual(rspJson['dims'][0], 10)
     self.assertEqual(rspJson['maxdims'][1], 10)
     self.assertEqual(rspJson['fillvalue'], 42)
Ejemplo n.º 36
0
 def testGet(self):
     domain = 'tall.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     g2_uuid = helper.getUUID(domain, root_uuid, 'g2')
     dset21_uuid = helper.getUUID(domain, g2_uuid, 'dset2.1')
     req = helper.getEndpoint() + "/datasets/" + dset21_uuid + '/type'
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     typeItem = rspJson['type']
     self.assertEqual(typeItem['base'], 'H5T_IEEE_F32BE')
     self.assertEqual(typeItem['class'], 'H5T_FLOAT')
Ejemplo n.º 37
0
    def testCreateFolder(self):
        domain = self.base_domain + "/newfolder"
        print("testCreateFolder", domain)
        headers = helper.getRequestHeaders(domain=domain)
        req = helper.getEndpoint() + '/'
        body = {"folder": True}
        rsp = requests.put(req, data=json.dumps(body), headers=headers)
        self.assertEqual(rsp.status_code, 201)
        rspJson = json.loads(rsp.text)
        for k in ("owner", "acls", "created", "lastModified"):
            self.assertTrue(k in rspJson)
        self.assertFalse("root" in rspJson)  # no root -> folder

        # verify that putting the same domain again fails with a 409 error
        rsp = requests.put(req, data=json.dumps(body), headers=headers)
        self.assertEqual(rsp.status_code, 409)

        # do a get on the new folder
        rsp = requests.get(req, headers=headers)
        self.assertEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)

        self.assertTrue("owner" in rspJson)
        self.assertTrue("class" in rspJson)
        self.assertEqual(rspJson["class"], "folder")

        # try doing a un-authenticated request
        if config.get("test_noauth") and config.get("default_public"):
            headers = helper.getRequestHeaders()
            req = helper.getEndpoint() + "/?host=" + domain
            # do a get on the folder with a query arg for host
            rsp = requests.get(req)
            self.assertEqual(rsp.status_code, 200)
            rspJson = json.loads(rsp.text)
            for k in ("class", "owner"):
                self.assertTrue(k in rspJson)
            self.assertFalse("root" in rspJson)
Ejemplo n.º 38
0
 def testGetAll(self):
     for domain_name in ('tall', 'tall_ro'):
         domain = domain_name + '.' + config.get('domain')
         rootUUID = helper.getRootUUID(domain)
         req = helper.getEndpoint() + "/groups/" + rootUUID + "/attributes"
         headers = {'host': domain}
         rsp = requests.get(req, headers=headers)
         self.failUnlessEqual(rsp.status_code, 200)
         rspJson = json.loads(rsp.text)
         self.assertEqual(len(rspJson['hrefs']), 4)
         attrsJson = rspJson['attributes']
         self.assertEqual(len(attrsJson), 2)
         self.assertEqual(attrsJson[0]['name'], 'attr1')
         self.assertEqual(attrsJson[1]['name'], 'attr2')
         self.assertFalse('value' in attrsJson[0])
Ejemplo n.º 39
0
 def testGetCompound(self):
     domain = 'compound.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     dset_uuid = helper.getUUID(domain, root_uuid, 'dset')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     data = rspJson['value']
     self.failUnlessEqual(len(data), 72)
     first = data[0]
     self.failUnlessEqual(len(first), 5)
     self.failUnlessEqual(first[0], 24)
     self.failUnlessEqual(first[1], "13:53")
Ejemplo n.º 40
0
    def testPutInvalidShape(self):
        domain = 'resized.' + config.get('domain')
        headers = {'host': domain}
        root_uuid = helper.getRootUUID(domain)
        resizable_1d_uuid = helper.getUUID(domain, root_uuid, 'resizable_1d')
        req = helper.getEndpoint(
        ) + "/datasets/" + resizable_1d_uuid + "/shape"
        payload = {'shape': [20, 10]}  # wrong rank
        headers = {'host': domain}
        rsp = requests.put(req, data=json.dumps(payload), headers=headers)
        self.failUnlessEqual(rsp.status_code, 400)

        payload = {'shape': 8}  # try to shrink
        headers = {'host': domain}
        rsp = requests.put(req, data=json.dumps(payload), headers=headers)
        self.failUnlessEqual(rsp.status_code, 400)

        resizable_2d_uuid = helper.getUUID(domain, root_uuid, 'resizable_2d')
        req = helper.getEndpoint(
        ) + "/datasets/" + resizable_2d_uuid + "/shape"
        payload = {'shape': [12, 20]}  # try to extend non-extendable dimension
        headers = {'host': domain}
        rsp = requests.put(req, data=json.dumps(payload), headers=headers)
        self.failUnlessEqual(rsp.status_code, 400)
Ejemplo n.º 41
0
 def make_ctype(parent_id, name):
     payload = {
         'type': 'H5T_IEEE_F64LE',
         'link': {
             'id': parent_id,
             'name': name
         }
     }
     req = helper.getEndpoint() + "/datatypes"
     rsp = requests.post(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 201)
     rspJson = json.loads(rsp.text)
     dtype_id = rspJson["id"]
     self.assertTrue(helper.validateId(dtype_id))
     return dtype_id
Ejemplo n.º 42
0
 def testGetScalar(self):
     domain = 'scalar.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, '0d')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + '/type'
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     typeItem = rspJson['type']
     self.assertEqual(typeItem['base'], 'H5T_STD_I32LE')
     self.assertEqual(typeItem['order'], 'H5T_ORDER_LE')
     self.assertEqual(typeItem['class'], 'H5T_INTEGER')
     self.assertEqual(typeItem['size'], 4)
Ejemplo n.º 43
0
 def testPutLink(self):
     req = self.endpoint + "/"
     rsp = requests.get(req)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('root' in rspJson)
     root_uuid = rspJson['root']
     name = 'dirtest.testPutLink'
     req = helper.getEndpoint() + "/groups/" + root_uuid + "/links/" + name
     payload = {"h5path": "somewhere"}
     # verify softlink does not exist
     rsp = requests.get(req, data=json.dumps(payload))
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload))
     self.failUnlessEqual(rsp.status_code, 403)
Ejemplo n.º 44
0
 def testGetVLenString(self):
     domain = 'vlen_string_dset.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     rspJson = json.loads(rsp.text)
     self.assertTrue('value' in rspJson)
     value = rspJson['value']
     self.assertEqual(len(value), 4)
     self.assertEqual(value[0], "Parting")
     self.assertEqual(value[1], "is such")
     self.assertEqual(value[2], "sweet")
     self.assertEqual(value[3], "sorrow.")
Ejemplo n.º 45
0
 def testGet(self):
     domain = 'tall.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     g2_uuid = helper.getUUID(domain, root_uuid, 'g2')
     dset21_uuid = helper.getUUID(domain, g2_uuid, 'dset2.1') 
     req = helper.getEndpoint() + "/datasets/" + dset21_uuid + "/shape"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('shape' in rspJson)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 10)  
     self.assertTrue('maxdims' not in shape)  # not re-sizeable
Ejemplo n.º 46
0
 def testGetCommitted(self):
     domain = 'committed_type.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     req = helper.getEndpoint() + "/groups/" + root_uuid + "/attributes/attr1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SCALAR')
     self.assertTrue('dims' not in shape)
     typeItem = rspJson['type']  # returns '/datatypes/<uuid>'
     npos = typeItem.rfind('/')
     type_uuid = typeItem[(npos+1):]
     self.assertTrue(helper.validateId(type_uuid))
Ejemplo n.º 47
0
    def testGet(self):
        domain = 'namedtype.' + config.get('domain')
        root_uuid = helper.getRootUUID(domain)
        dtype_uuid = helper.getUUID(domain, root_uuid, 'dtype_simple')
        self.assertTrue(helper.validateId(dtype_uuid))

        req = helper.getEndpoint() + "/datatypes/" + dtype_uuid
        headers = {'host': domain}
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        self.assertEqual(rspJson['id'], dtype_uuid)
        typeItem = rspJson['type']
        self.assertEqual(typeItem['class'], 'H5T_FLOAT')
        self.assertEqual(typeItem['base'], 'H5T_IEEE_F32LE')
        self.assertEqual(rspJson['attributeCount'], 1)
Ejemplo n.º 48
0
 def testGetSimpleOneElementString(self):
     domain = 'scalar.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, '1ds')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     type = rspJson['type']
     self.assertEqual(type['class'], 'H5T_STRING')
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertTrue('dims' in shape)
     self.assertEqual(shape['dims'][0], 1)
Ejemplo n.º 49
0
 def testPutExternalLink(self):
     logging.info("LinkTest.testPutExternalLink")
     domain = 'tall_updated.' + config.get('domain')
     href = 'http://external_target.' + config.get(
         'domain') + '/#h5path(/dset1)'
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlink'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"href": href}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
Ejemplo n.º 50
0
 def testGetArray(self):
     domain = 'array_dset.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid + "/value"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     self.assertTrue('value' in rspJson)
     value = rspJson['value']
     self.assertEqual(len(value),
                      4)  # four dataset elements (each an array)
     self.assertEqual(len(value[0]), 3)  # 3x5 array shape
     self.assertEqual(len((value[0])[0]), 5)  # 3x5 array shape
     self.assertEqual(value[0][2][4], -8)  # pull out a value from the array
Ejemplo n.º 51
0
 def testGetRegionReference(self):
     domain = 'regionref_dset.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 2)
     typeItem = rspJson['type']
     self.assertEqual(typeItem['class'], 'H5T_REFERENCE')
     self.assertEqual(typeItem['base'], 'H5T_STD_REF_DSETREG')
Ejemplo n.º 52
0
 def testPutExternalMissingPath(self):
     logging.info("LinkTest.testPutExternalMissingPath")
     fakeId = "14bfeeb8-68b1-11e4-a69a-3c15c2da029e"
     domain = 'tall_updated.' + config.get('domain')
     external_domain = 'external_target.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlinkid'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"h5domain": external_domain}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.assertEqual(rsp.status_code, 400)
Ejemplo n.º 53
0
    def testGetRegionReference(self):
        domain = 'regionref_attr.' + config.get('domain')
        root_uuid = helper.getRootUUID(domain)
        self.assertTrue(helper.validateId(root_uuid))
        ds1_uuid = helper.getUUID(domain, root_uuid, 'DS1')
        ds2_uuid = helper.getUUID(domain, root_uuid, 'DS2')
        req = helper.getEndpoint() + "/datasets/" + ds1_uuid + "/attributes/A1"
        headers = {'host': domain}
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        shape = rspJson['shape']
        self.assertEqual(shape['class'], 'H5S_SIMPLE')
        self.assertEqual(len(shape['dims']), 1)
        self.assertEqual(shape['dims'][0], 2)
        typeItem = rspJson['type']
        self.assertEqual(typeItem['class'], 'H5T_REFERENCE')
        self.assertEqual(typeItem['base'], 'H5T_STD_REF_DSETREG')
        self.assertTrue('value' in rspJson)
        value = rspJson['value']
        self.assertEqual(len(value), 2)
        value = rspJson['value']
        self.assertEqual(len(value), 2)
        ref0 = value[0]
        self.assertEqual(ref0['select_type'], 'H5S_SEL_POINTS')
        self.assertEqual(ref0['id'], ds2_uuid)
        points = ref0['selection']
        self.assertEqual(len(points), 4)
        self.assertEqual(points[0], [0, 1])
        self.assertEqual(points[1], [2, 11])
        self.assertEqual(points[2], [1, 0])
        self.assertEqual(points[3], [2, 4])

        ref1 = value[1]
        self.assertEqual(ref1['select_type'], 'H5S_SEL_HYPERSLABS')
        self.assertEqual(ref1['id'], ds2_uuid)
        hyperslabs = ref1['selection']
        self.assertEqual(len(hyperslabs), 4)
        self.assertEqual(hyperslabs[0][0], [0, 0])
        self.assertEqual(hyperslabs[0][1], [0, 2])
        self.assertEqual(hyperslabs[1][0], [0, 11])
        self.assertEqual(hyperslabs[1][1], [0, 13])
        self.assertEqual(hyperslabs[2][0], [2, 0])
        self.assertEqual(hyperslabs[2][1], [2, 2])
        self.assertEqual(hyperslabs[3][0], [2, 11])
        self.assertEqual(hyperslabs[3][1], [2, 13])
Ejemplo n.º 54
0
 def testGetScalar(self):
     domain = 'scalar.' + config.get('domain')  
     root_uuid = helper.getRootUUID(domain)
     req = helper.getEndpoint() + "/groups/" + root_uuid + "/attributes/attr1"
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.assertEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SCALAR')
     self.assertTrue('dims' not in shape)
     typeItem = rspJson['type']
     self.assertEqual(typeItem['class'], 'H5T_INTEGER')
     self.assertEqual(typeItem['base'], 'H5T_STD_I64LE')
     data = rspJson['value'] 
     self.assertEqual(type(data), int)
     self.assertEqual(data, 42)
Ejemplo n.º 55
0
 def testGetNullSpace(self):
     domain = 'null_space_dset.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     type = rspJson['type']
     self.assertEqual(type['class'], 'H5T_INTEGER')
     self.assertEqual(type['base'], 'H5T_STD_I32LE')
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_NULL')
     self.assertTrue('dims' not in shape)
     self.assertTrue('maxdims' not in shape)
Ejemplo n.º 56
0
 def testPutExternalLinkBadHref(self):
     logging.info("LinkTest.testPutExternalLinkId")
     fakeId = "14bfeeb8-68b1-11e4-a69a-3c15c2da029e"
     domain = 'tall_updated.' + config.get('domain')
     href = 'http://external_target.' + config.get(
         'domain') + '/foobar/' + fakeId
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'extlinkid'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"href": href}
     headers = {'host': domain}
     # verify extlink does not exist
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)
     # make request
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 400)
Ejemplo n.º 57
0
 def testPut(self):
     logging.info("LinkTest.testPut")
     domain = 'tall_updated.' + config.get('domain')
     grpId = helper.createGroup(domain)
     rootId = helper.getRootUUID(domain)
     name = 'g3'
     req = helper.getEndpoint() + "/groups/" + rootId + "/links/" + name
     payload = {"id": grpId}
     headers = {'host': domain}
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 404)  # link doesn't exist
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
     rsp = requests.get(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)  # it's there now!
     # make a request second time (verify idempotent)
     rsp = requests.put(req, data=json.dumps(payload), headers=headers)
     self.failUnlessEqual(rsp.status_code, 201)
Ejemplo n.º 58
0
    def testGetOpaque(self):
        domain = 'opaque_dset.' + config.get('domain')
        root_uuid = helper.getRootUUID(domain)
        self.assertTrue(helper.validateId(root_uuid))
        dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
        req = helper.getEndpoint() + "/datasets/" + dset_uuid
        headers = {'host': domain}
        rsp = requests.get(req, headers=headers)
        self.failUnlessEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        shape = rspJson['shape']
        self.assertEqual(shape['class'], 'H5S_SIMPLE')
        self.assertEqual(len(shape['dims']), 1)
        self.assertEqual(shape['dims'][0], 4)
        typeItem = rspJson['type']

        self.assertEqual(typeItem['class'], 'H5T_OPAQUE')
        self.assertEqual(typeItem['size'], 7)
Ejemplo n.º 59
0
 def testGetInfo(self):
     req = helper.getEndpoint() + "/info"
     rsp = requests.get(req)
     self.assertEqual(rsp.status_code, 200)
     self.assertEqual(rsp.headers["Content-Type"],
                      "application/json; charset=utf-8")
     rspJson = json.loads(rsp.text)
     self.assertTrue("node" in rspJson)
     node = rspJson["node"]
     self.assertTrue("id" in node)
     self.assertTrue(node["id"].startswith("sn-"))
     self.assertTrue("node_number" not in node)  # only for dn nodes
     self.assertTrue("node_count" in node)
     self.assertTrue(node["node_count"] >= 0)
     self.assertTrue("type" in node)
     self.assertEqual(node["type"], "sn")
     self.assertTrue("state" in node)
     self.assertEqual(node["state"], "READY")
Ejemplo n.º 60
0
 def testGetCommitted(self):
     domain = 'committed_type.' + config.get('domain')
     root_uuid = helper.getRootUUID(domain)
     self.assertTrue(helper.validateId(root_uuid))
     dset_uuid = helper.getUUID(domain, root_uuid, 'DS1')
     req = helper.getEndpoint() + "/datasets/" + dset_uuid
     headers = {'host': domain}
     rsp = requests.get(req, headers=headers)
     self.failUnlessEqual(rsp.status_code, 200)
     rspJson = json.loads(rsp.text)
     shape = rspJson['shape']
     self.assertEqual(shape['class'], 'H5S_SIMPLE')
     self.assertEqual(len(shape['dims']), 1)
     self.assertEqual(shape['dims'][0], 4)
     typeItem = rspJson['type']  # returns '/datatypes/<uuid>'
     npos = typeItem.rfind('/')
     type_uuid = typeItem[(npos + 1):]
     self.assertTrue(helper.validateId(type_uuid))