本文整理汇总了Golang中github.com/janelia-flyem/dvid/datastore.OpenTest函数的典型用法代码示例。如果您正苦于以下问题:Golang OpenTest函数的具体用法?Golang OpenTest怎么用?Golang OpenTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OpenTest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestNewKeyvalueDifferent
// Make sure new keyvalue data have different IDs.
func TestNewKeyvalueDifferent(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
// Add data
config := dvid.NewConfig()
dataservice1, err := datastore.NewData(uuid, kvtype, "instance1", config)
if err != nil {
t.Errorf("Error creating new keyvalue instance: %v\n", err)
}
kv1, ok := dataservice1.(*Data)
if !ok {
t.Errorf("Returned new data instance 1 is not keyvalue.Data\n")
}
if kv1.DataName() != "instance1" {
t.Errorf("New keyvalue data instance name set incorrectly: %q != %q\n",
kv1.DataName(), "instance1")
}
dataservice2, err := datastore.NewData(uuid, kvtype, "instance2", config)
if err != nil {
t.Errorf("Error creating new keyvalue instance: %v\n", err)
}
kv2, ok := dataservice2.(*Data)
if !ok {
t.Errorf("Returned new data instance 2 is not keyvalue.Data\n")
}
if kv1.InstanceID() == kv2.InstanceID() {
t.Errorf("Instance IDs should be different: %d == %d\n",
kv1.InstanceID(), kv2.InstanceID())
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:36,代码来源:keyvalue_test.go
示例2: TestLabelblkDirectAPI
func TestLabelblkDirectAPI(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, versionID := initTestRepo()
labels := newDataInstance(uuid, t, "mylabels")
labelsCtx := datastore.NewVersionedCtx(labels, versionID)
// Create a fake block-aligned label volume
offset := dvid.Point3d{32, 0, 64}
size := dvid.Point3d{96, 64, 160}
subvol := dvid.NewSubvolume(offset, size)
data := makeVolume(offset, size)
// Store it into datastore at root
v, err := labels.NewVoxels(subvol, data)
if err != nil {
t.Fatalf("Unable to make new labels Voxels: %v\n", err)
}
if err = labels.IngestVoxels(versionID, 1, v, ""); err != nil {
t.Errorf("Unable to put labels for %s: %v\n", labelsCtx, err)
}
if v.NumVoxels() != int64(len(data))/8 {
t.Errorf("# voxels (%d) after PutVoxels != # original voxels (%d)\n",
v.NumVoxels(), int64(len(data))/8)
}
// Read the stored image
v2, err := labels.NewVoxels(subvol, nil)
if err != nil {
t.Errorf("Unable to make new labels ExtHandler: %v\n", err)
}
if err = labels.GetVoxels(versionID, v2, ""); err != nil {
t.Errorf("Unable to get voxels for %s: %v\n", labelsCtx, err)
}
// Make sure the retrieved image matches the original
if v.Stride() != v2.Stride() {
t.Errorf("Stride in retrieved subvol incorrect\n")
}
if v.Interpolable() != v2.Interpolable() {
t.Errorf("Interpolable bool in retrieved subvol incorrect\n")
}
if !reflect.DeepEqual(v.Size(), v2.Size()) {
t.Errorf("Size in retrieved subvol incorrect: %s vs expected %s\n",
v2.Size(), v.Size())
}
if v.NumVoxels() != v2.NumVoxels() {
t.Errorf("# voxels in retrieved is different: %d vs expected %d\n",
v2.NumVoxels(), v.NumVoxels())
}
byteData := v2.Data()
for i := int64(0); i < v2.NumVoxels()*8; i++ {
if byteData[i] != data[i] {
t.Logf("Size of data: %d bytes from GET, %d bytes in PUT\n", len(data), len(data))
t.Fatalf("GET subvol (%d) != PUT subvol (%d) @ uint64 #%d", byteData[i], data[i], i)
}
}
}
开发者ID:janelia-flyem,项目名称:dvid,代码行数:60,代码来源:labelblk_test.go
示例3: TestNewLabelgraphDifferent
// Make sure new labelgraph data have different IDs.
func TestNewLabelgraphDifferent(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
// Add data
config := dvid.NewConfig()
dataservice1, err := datastore.NewData(uuid, dtype, "lg1", config)
if err != nil {
t.Errorf("Error creating new labelgraph instance 1: %v\n", err)
}
data1, ok := dataservice1.(*Data)
if !ok {
t.Errorf("Returned new data instance 1 is not labelgraph.Data\n")
}
dataservice2, err := datastore.NewData(uuid, dtype, "lg2", config)
if err != nil {
t.Errorf("Error creating new labelgraph instance 2: %v\n", err)
}
data2, ok := dataservice2.(*Data)
if !ok {
t.Errorf("Returned new data instance 2 is not labelgraph.Data\n")
}
if data1.InstanceID() == data2.InstanceID() {
t.Errorf("Instance IDs should be different: %d == %d\n",
data1.InstanceID(), data2.InstanceID())
}
}
开发者ID:tartavull,项目名称:dvid,代码行数:30,代码来源:labelgraph_test.go
示例4: TestROICreateAndSerialize
func TestROICreateAndSerialize(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
// Add data
config := dvid.NewConfig()
dataservice1, err := datastore.NewData(uuid, roitype, "myroi", config)
if err != nil {
t.Errorf("Error creating new roi instance: %v\n", err)
}
roi1, ok := dataservice1.(*Data)
if !ok {
t.Errorf("Returned new data instance 1 is not roi.Data\n")
}
if roi1.DataName() != "myroi" {
t.Errorf("New roi data instance name set incorrectly: %q != %q\n",
roi1.DataName(), "myroi")
}
config.Set("BlockSize", "15,16,17")
dataservice2, err := datastore.NewData(uuid, roitype, "myroi2", config)
if err != nil {
t.Errorf("Error creating new roi instance: %v\n", err)
}
roi2, ok := dataservice2.(*Data)
if !ok {
t.Errorf("Returned new data instance 2 is not roi.Data\n")
}
if roi1.InstanceID() == roi2.InstanceID() {
t.Errorf("Instance IDs should be different: %d == %d\n",
roi1.InstanceID(), roi2.InstanceID())
}
// Test persistence of storage.
roi2.MinZ = 13
roi2.MaxZ = 3098
gobBytes, err := roi2.GobEncode()
if err != nil {
t.Fatalf("Could not Gob encode roi: %v\n", err)
}
var received Data
if err = received.GobDecode(gobBytes); err != nil {
t.Fatalf("Could not decode Gob-encoded roi: %v\n", err)
}
if !roi2.Data.Equals(received.Data) {
t.Errorf("ROI base Data has bad roundtrip:\nOriginal:\n%v\nReceived:\n%v\n",
*(roi2.Data), *(received.Data))
}
if !reflect.DeepEqual(roi2.Properties, received.Properties) {
t.Errorf("ROI extended properties has bad roundtrip:\nOriginal:\n%v\nReceived:\n%v\n",
roi2.Properties, received.Properties)
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:59,代码来源:roi_test.go
示例5: TestKeyvalueRequests
func TestKeyvalueRequests(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, versionID := initTestRepo()
testRequest(t, uuid, versionID, "mykeyvalue")
}
开发者ID:jmptrader,项目名称:dvid,代码行数:8,代码来源:keyvalue_test.go
示例6: TestFloatInstanceCreation
func TestFloatInstanceCreation(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := datastore.NewTestRepo()
// Create new voxels instance with optional parameters
name := "weights"
metadata := fmt.Sprintf(`{
"typename": "float32blk",
"dataname": %q,
"blocksize": "64,43,28",
"VoxelSize": "13.1, 14.2, 15.3",
"VoxelUnits": "picometers,nanometers,microns"
}`, name)
apiStr := fmt.Sprintf("%srepo/%s/instance", server.WebAPIPath, uuid)
server.TestHTTP(t, "POST", apiStr, bytes.NewBufferString(metadata))
// Get metadata and make sure optional settings have been set.
apiStr = fmt.Sprintf("%snode/%s/%s/info", server.WebAPIPath, uuid, name)
result := server.TestHTTP(t, "GET", apiStr, nil)
var parsed = struct {
Base struct {
TypeName, Name string
}
Extended struct {
BlockSize dvid.Point3d
VoxelSize dvid.NdFloat32
VoxelUnits dvid.NdString
}
}{}
if err := json.Unmarshal(result, &parsed); err != nil {
t.Fatalf("Error parsing JSON response of new instance metadata: %v\n", err)
}
if parsed.Base.Name != name {
t.Errorf("Parsed new instance has unexpected name: %s != %s (expected)\n",
parsed.Base.Name, name)
}
if parsed.Base.TypeName != "float32blk" {
t.Errorf("Parsed new instance has unexpected type name: %s != uint8blk (expected)\n",
parsed.Base.TypeName)
}
if !parsed.Extended.BlockSize.Equals(dvid.Point3d{64, 43, 28}) {
t.Errorf("Bad block size in new uint8blk instance: %s\n", parsed.Extended.BlockSize)
}
if !parsed.Extended.VoxelSize.Equals(dvid.NdFloat32{13.1, 14.2, 15.3}) {
t.Errorf("Bad voxel size in new uint8blk instance: %s\n", parsed.Extended.VoxelSize)
}
if parsed.Extended.VoxelUnits[0] != "picometers" {
t.Errorf("Got %q for X voxel units, not picometers\n", parsed.Extended.VoxelUnits[0])
}
if parsed.Extended.VoxelUnits[1] != "nanometers" {
t.Errorf("Got %q for X voxel units, not picometers\n", parsed.Extended.VoxelUnits[0])
}
if parsed.Extended.VoxelUnits[2] != "microns" {
t.Errorf("Got %q for X voxel units, not picometers\n", parsed.Extended.VoxelUnits[0])
}
}
开发者ID:janelia-flyem,项目名称:dvid,代码行数:58,代码来源:float32_test.go
示例7: TestRequests
func TestRequests(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
config := dvid.NewConfig()
dataservice, err := datastore.NewData(uuid, syntype, "mysynapses", config)
if err != nil {
t.Fatalf("Error creating new data instance: %v\n", err)
}
data, ok := dataservice.(*Data)
if !ok {
t.Fatalf("Returned new data instance is not synapse.Data\n")
}
// PUT first batch of synapses
testJSON, err := json.Marshal(testData)
if err != nil {
t.Fatal(err)
}
url1 := fmt.Sprintf("%snode/%s/%s/elements", server.WebAPIPath, uuid, data.DataName())
server.TestHTTP(t, "POST", url1, strings.NewReader(string(testJSON)))
// GET synapses back within superset bounding box and make sure all data is there.
testResponse(t, testData, "%snode/%s/%s/elements/1000_1000_1000/0_0_0", server.WebAPIPath, uuid, data.DataName())
// Test subset GET
testResponse(t, expected3, "%snode/%s/%s/elements/5_5_5/126_60_97", server.WebAPIPath, uuid, data.DataName())
// Test Tag 1
tag := Tag("Synapse2")
synapse2 := getTag(tag, testData)
testResponse(t, synapse2, "%snode/%s/%s/tag/%s?relationships=true", server.WebAPIPath, uuid, data.DataName(), tag)
// Test Tag 2
tag2 := Tag("Zlt90")
zlt90 := getTag(tag2, testData)
testResponse(t, zlt90, "%snode/%s/%s/tag/%s?relationships=true", server.WebAPIPath, uuid, data.DataName(), tag2)
// Test move
url5 := fmt.Sprintf("%snode/%s/%s/move/127_63_99/127_64_100", server.WebAPIPath, uuid, data.DataName())
server.TestHTTP(t, "POST", url5, nil)
testResponse(t, afterMove, "%snode/%s/%s/elements/1000_1000_1000/0_0_0", server.WebAPIPath, uuid, data.DataName())
// --- check tag
synapse2 = getTag(tag, afterMove)
testResponse(t, synapse2, "%snode/%s/%s/tag/%s?relationships=true", server.WebAPIPath, uuid, data.DataName(), tag)
// Test delete
url6 := fmt.Sprintf("%snode/%s/%s/element/127_64_100", server.WebAPIPath, uuid, data.DataName())
server.TestHTTP(t, "DELETE", url6, nil)
testResponse(t, afterDelete, "%snode/%s/%s/elements/1000_1000_1000/0_0_0", server.WebAPIPath, uuid, data.DataName())
// --- check tag
synapse2 = getTag(tag, afterDelete)
testResponse(t, synapse2, "%snode/%s/%s/tag/%s?relationships=true", server.WebAPIPath, uuid, data.DataName(), tag)
}
开发者ID:tartavull,项目名称:dvid,代码行数:58,代码来源:annotation_test.go
示例8: TestLog
func TestLog(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid := createRepo(t)
// Post a log
payload := bytes.NewBufferString(`{"log": ["line1", "line2", "some more stuff in a line"]}`)
apiStr := fmt.Sprintf("%snode/%s/log", WebAPIPath, uuid)
TestHTTP(t, "POST", apiStr, payload)
// Verify it was saved.
r := TestHTTP(t, "GET", apiStr, nil)
jsonResp := make(map[string][]string)
if err := json.Unmarshal(r, &jsonResp); err != nil {
t.Fatalf("Unable to unmarshal log response: %s\n", string(r))
}
if len(jsonResp) != 1 {
t.Errorf("Bad log return: %s\n", string(r))
}
data, ok := jsonResp["log"]
if !ok {
t.Fatalf("No 'log' data returned: %s\n", string(r))
}
if len(data) != 3 {
t.Fatalf("Got wrong # of lines in log: %v\n", data)
}
testLog(t, data[0], "line1")
testLog(t, data[1], "line2")
testLog(t, data[2], "some more stuff in a line")
// Add some more to log
payload = bytes.NewBufferString(`{"log": ["line4", "line5"]}`)
apiStr = fmt.Sprintf("%snode/%s/log", WebAPIPath, uuid)
TestHTTP(t, "POST", apiStr, payload)
// Verify it was appended.
r = TestHTTP(t, "GET", apiStr, nil)
jsonResp = make(map[string][]string)
if err := json.Unmarshal(r, &jsonResp); err != nil {
t.Fatalf("Unable to unmarshal log response: %s\n", string(r))
}
if len(jsonResp) != 1 {
t.Errorf("Bad log return: %s\n", string(r))
}
data, ok = jsonResp["log"]
if !ok {
t.Fatalf("No 'log' data returned: %s\n", string(r))
}
if len(data) != 5 {
t.Errorf("Got wrong # of lines in log: %v\n", data)
}
testLog(t, data[3], "line4")
testLog(t, data[4], "line5")
}
开发者ID:jmptrader,项目名称:dvid,代码行数:55,代码来源:web_test.go
示例9: TestBasic
func TestBasic(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
config := dvid.NewConfig()
_, err := datastore.NewData(uuid, dtype, "instance1", config)
if err != nil {
t.Errorf("Error creating new multichan16 instance: %v\n", err)
}
}
开发者ID:tartavull,项目名称:dvid,代码行数:12,代码来源:multichan16_test.go
示例10: TestROIPartition
func TestROIPartition(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
// Create the ROI dataservice.
uuid, versionID := initTestRepo()
config := dvid.NewConfig()
dataservice, err := datastore.NewData(uuid, roitype, "roi", config)
if err != nil {
t.Errorf("Error creating new roi instance: %v\n", err)
}
data, ok := dataservice.(*Data)
if !ok {
t.Errorf("Returned new data instance is not roi.Data\n")
}
// PUT an ROI
roiRequest := fmt.Sprintf("%snode/%s/%s/roi", server.WebAPIPath, uuid, data.DataName())
req, err := http.NewRequest("POST", roiRequest, getSpansJSON(testSpans))
if err != nil {
t.Errorf("Unsuccessful POST request (%s): %v\n", roiRequest, err)
}
ctx := datastore.NewVersionedCtx(data, versionID)
w := httptest.NewRecorder()
data.ServeHTTP(uuid, ctx, w, req)
if w.Code != http.StatusOK {
t.Errorf("Bad server response roi POST, status %s, for roi %q\n", w.Code, data.DataName())
}
// Request the standard subvolume partitioning
partitionReq := fmt.Sprintf("%snode/%s/%s/partition?batchsize=5&optimized=true", server.WebAPIPath, uuid,
data.DataName())
req, err = http.NewRequest("GET", partitionReq, nil)
if err != nil {
t.Errorf("Unsuccessful GET request (%s): %v\n", partitionReq, err)
}
w = httptest.NewRecorder()
data.ServeHTTP(uuid, ctx, w, req)
if w.Code != http.StatusOK {
t.Errorf("Bad server response roi GET, status %s, for roi %q\n", w.Code, data.DataName())
}
var subvolJSON, expectedJSON interface{}
response := w.Body.Bytes()
if err := json.Unmarshal(response, &subvolJSON); err != nil {
t.Errorf("Can't unmarshal JSON: %s\n", w.Body.Bytes())
}
json.Unmarshal([]byte(expectedPartition), &expectedJSON)
if !reflect.DeepEqual(subvolJSON, expectedJSON) {
t.Errorf("Error doing optimized subvolume partitioning. Got bad result:\n%s\n",
string(response))
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:53,代码来源:roi_test.go
示例11: TestDiamondGetOnMerge
// Test added after error in getting two paths to the same ancestor k/v after merge.
func TestDiamondGetOnMerge(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
config := dvid.NewConfig()
dataservice, err := datastore.NewData(uuid, kvtype, "mergetest", config)
if err != nil {
t.Fatalf("Error creating new keyvalue instance: %v\n", err)
}
data, ok := dataservice.(*Data)
if !ok {
t.Fatalf("Returned new data instance is not roi.Data\n")
}
// PUT a value
key1 := "mykey"
value1 := "some stuff"
key1req := fmt.Sprintf("%snode/%s/%s/key/%s", server.WebAPIPath, uuid, data.DataName(), key1)
server.TestHTTP(t, "POST", key1req, strings.NewReader(value1))
if err = datastore.Commit(uuid, "my commit msg", []string{"stuff one", "stuff two"}); err != nil {
t.Errorf("Unable to lock root node %s: %v\n", uuid, err)
}
uuid2, err := datastore.NewVersion(uuid, "first child", nil)
if err != nil {
t.Fatalf("Unable to create 1st child off root %s: %v\n", uuid, err)
}
if err = datastore.Commit(uuid2, "first child", nil); err != nil {
t.Errorf("Unable to commit node %s: %v\n", uuid2, err)
}
uuid3, err := datastore.NewVersion(uuid, "second child", nil)
if err != nil {
t.Fatalf("Unable to create 2nd child off root %s: %v\n", uuid, err)
}
if err = datastore.Commit(uuid3, "second child", nil); err != nil {
t.Errorf("Unable to commit node %s: %v\n", uuid3, err)
}
child, err := datastore.Merge([]dvid.UUID{uuid2, uuid3}, "merging stuff", datastore.MergeConflictFree)
if err != nil {
t.Errorf("Error doing merge: %v\n", err)
}
// We should be able to see just the original uuid value of the k/v
childreq := fmt.Sprintf("%snode/%s/%s/key/%s", server.WebAPIPath, child, data.DataName(), key1)
returnValue := server.TestHTTP(t, "GET", childreq, nil)
if string(returnValue) != value1 {
t.Errorf("Error on merged child, key %q: expected %q, got %q\n", key1, value1, string(returnValue))
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:53,代码来源:keyvalue_test.go
示例12: TestBlockAPI
func TestBlockAPI(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
grayscale := makeGrayscale(uuid, t, "grayscale")
// construct random blocks of data.
numBlockBytes := int32(grayscale.BlockSize().Prod())
testBlocks := 1001
var blockData []byte
for i := 0; i < testBlocks; i++ {
blockData = append(blockData, dvid.RandomBytes(numBlockBytes)...)
}
// set start of span
x := rand.Int31()
y := rand.Int31()
z := rand.Int31()
// Test uncompressed roundtrip
// send the blocks
blockReq := fmt.Sprintf("%snode/%s/grayscale/blocks/%d_%d_%d/%d", server.WebAPIPath, uuid, x, y, z, testBlocks)
server.TestHTTP(t, "POST", blockReq, bytes.NewBuffer(blockData))
// read same span of blocks
returnedData := server.TestHTTP(t, "GET", blockReq, nil)
// make sure blocks are same
totBytes := testBlocks * int(numBlockBytes)
if len(returnedData) != totBytes {
t.Errorf("Returned %d bytes, expected %d bytes", len(returnedData), totBytes)
}
if !reflect.DeepEqual(returnedData, blockData) {
t.Errorf("Returned block data != original block data\n")
}
// We should get blank blocks at different z
z += 1
blockReq = fmt.Sprintf("%snode/%s/grayscale/blocks/%d_%d_%d/%d", server.WebAPIPath, uuid, x, y, z, testBlocks)
returnedData = server.TestHTTP(t, "GET", blockReq, nil)
if len(returnedData) != totBytes {
t.Errorf("Returned %d bytes, expected %d bytes", len(returnedData), totBytes)
}
for i, b := range returnedData {
if b != 0 {
t.Fatalf("Expected 0 at returned byte %d, got %d instead.\n", i, b)
}
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:51,代码来源:uint8_test.go
示例13: TestCommitAndBranch
func TestCommitAndBranch(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
apiStr := fmt.Sprintf("%srepos", server.WebAPIPath)
r := server.TestHTTP(t, "POST", apiStr, nil)
var jsonResp map[string]interface{}
if err := json.Unmarshal(r, &jsonResp); err != nil {
t.Fatalf("Unable to unmarshal repo creation response: %s\n", string(r))
}
v, ok := jsonResp["root"]
if !ok {
t.Fatalf("No 'root' metadata returned: %s\n", string(r))
}
uuidStr, ok := v.(string)
if !ok {
t.Fatalf("Couldn't cast returned 'root' data (%v) into string.\n", v)
}
uuid := dvid.UUID(uuidStr)
// Shouldn't be able to create branch on open node.
branchReq := fmt.Sprintf("%snode/%s/branch", server.WebAPIPath, uuid)
server.TestBadHTTP(t, "POST", branchReq, nil)
// Add a keyvalue instance.
server.CreateTestInstance(t, uuid, "keyvalue", "mykv", dvid.Config{})
// Commit it.
payload := bytes.NewBufferString(`{"note": "This is my test commit", "log": ["line1", "line2", "some more stuff in a line"]}`)
apiStr = fmt.Sprintf("%snode/%s/commit", server.WebAPIPath, uuid)
server.TestHTTP(t, "POST", apiStr, payload)
// Make sure committed nodes can only be read.
// We shouldn't be able to write to keyvalue..
keyReq := fmt.Sprintf("%snode/%s/mykv/key/foo", server.WebAPIPath, uuid)
server.TestBadHTTP(t, "POST", keyReq, bytes.NewBufferString("some data"))
// Should be able to create branch now that we've committed parent.
respData := server.TestHTTP(t, "POST", branchReq, nil)
resp := struct {
Child dvid.UUID `json:"child"`
}{}
if err := json.Unmarshal(respData, &resp); err != nil {
t.Errorf("Expected 'child' JSON response. Got %s\n", string(respData))
}
// We should be able to write to that keyvalue now in the child.
keyReq = fmt.Sprintf("%snode/%s/mykv/key/foo", server.WebAPIPath, resp.Child)
server.TestHTTP(t, "POST", keyReq, bytes.NewBufferString("some data"))
}
开发者ID:jmptrader,项目名称:dvid,代码行数:51,代码来源:api_test.go
示例14: TestDeleteInstance
func TestDeleteInstance(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid := createRepo(t)
// Shouldn't be able to delete instance without "imsure"
delReq := fmt.Sprintf("%srepo/%s/%s", WebAPIPath, uuid, "absent-name")
TestBadHTTP(t, "DELETE", delReq, nil)
// Shouldn't be able to delete an instance that doesn't exist.
delReq = fmt.Sprintf("%srepo/%s/%s?imsure=true", WebAPIPath, uuid, "absent-name")
TestBadHTTP(t, "DELETE", delReq, nil)
}
开发者ID:jmptrader,项目名称:dvid,代码行数:14,代码来源:web_test.go
示例15: TestReloadMetadata
func TestReloadMetadata(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := datastore.NewTestRepo()
// Add data instances
var config dvid.Config
server.CreateTestInstance(t, uuid, "keyvalue", "foo", config)
server.CreateTestInstance(t, uuid, "labelblk", "labels", config)
server.CreateTestInstance(t, uuid, "roi", "someroi", config)
// Reload the metadata
apiStr := fmt.Sprintf("%sserver/reload-metadata", server.WebAPIPath)
server.TestHTTP(t, "POST", apiStr, nil)
// Make sure repo UUID still there
jsonStr, err := datastore.MarshalJSON()
if err != nil {
t.Fatalf("can't get repos JSON: %v\n", err)
}
var jsonResp map[string](map[string]interface{})
if err := json.Unmarshal(jsonStr, &jsonResp); err != nil {
t.Fatalf("Unable to unmarshal repos info response: %s\n", jsonStr)
}
if len(jsonResp) != 1 {
t.Errorf("reloaded repos had more than one repo: %v\n", jsonResp)
}
for k := range jsonResp {
if dvid.UUID(k) != uuid {
t.Fatalf("Expected uuid %s, got %s. Full JSON:\n%v\n", uuid, k, jsonResp)
}
}
// Make sure the data instances are still there.
_, err = datastore.GetDataByUUIDName(uuid, "foo")
if err != nil {
t.Errorf("Couldn't get keyvalue data instance after reload\n")
}
_, err = datastore.GetDataByUUIDName(uuid, "labels")
if err != nil {
t.Errorf("Couldn't get labelblk data instance after reload\n")
}
_, err = datastore.GetDataByUUIDName(uuid, "someroi")
if err != nil {
t.Errorf("Couldn't get roi data instance after reload\n")
}
}
开发者ID:tartavull,项目名称:dvid,代码行数:49,代码来源:api_test.go
示例16: TestLabelsSyncing
func TestLabelsSyncing(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid := dvid.UUID(server.NewTestRepo(t))
if len(uuid) < 5 {
t.Fatalf("Bad root UUID for new repo: %s\n", uuid)
}
// Create a labelblk instance
vol := labelVol{
size: dvid.Point3d{5, 5, 5}, // in blocks
blockSize: dvid.Point3d{32, 32, 32},
offset: dvid.Point3d{32, 64, 96},
}
vol.postLabelVolume(t, "labels", uuid)
// TODO -- Test syncing across labelblk, labelvol, labelsz.
}
开发者ID:jmptrader,项目名称:dvid,代码行数:19,代码来源:api_test.go
示例17: TestLabelgraphPostAndDelete
// check subgraph endpoint
func TestLabelgraphPostAndDelete(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
// Create the ROI dataservice.
uuid, _ := initTestRepo()
config := dvid.NewConfig()
dataservice, err := datastore.NewData(uuid, dtype, "lg", config)
if err != nil {
t.Errorf("Error creating new labelgraph instance: %v\n", err)
}
data, ok := dataservice.(*Data)
if !ok {
t.Errorf("Returned new data instance is not labelgraph.Data\n")
}
// PUT a labelraph
subgraphRequest := fmt.Sprintf("%snode/%s/%s/subgraph", server.WebAPIPath, uuid, data.DataName())
server.TestHTTP(t, "POST", subgraphRequest, getGraphJSON())
// Get back the labelgraph
returnedData := server.TestHTTP(t, "GET", subgraphRequest, nil)
retgraph, err := loadGraphJSON(returnedData)
if err != nil {
t.Errorf("Error on getting back JSON from roi GET: %v\n", err)
}
// Make sure the two are the same.
if !reflect.DeepEqual(retgraph, getTestGraph()) {
t.Errorf("Bad PUT/GET ROI roundtrip\nOriginal:\n%s\nReturned:\n%s\n", getTestGraph(), retgraph)
}
// Delete the labelgraph
_ = server.TestHTTP(t, "DELETE", subgraphRequest, nil)
// Subgraph should now be empty
returnedData = server.TestHTTP(t, "GET", subgraphRequest, nil)
expectedResp := "{\"Transactions\":[],\"Vertices\":[],\"Edges\":[]}"
if string(returnedData) != expectedResp {
t.Errorf("Bad ROI after ROI delete. Should be %s got: %s\n", expectedResp, string(returnedData))
}
}
开发者ID:tartavull,项目名称:dvid,代码行数:44,代码来源:labelgraph_test.go
示例18: TestDeleteInstance
func TestDeleteInstance(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
apiStr := fmt.Sprintf("%srepos", server.WebAPIPath)
r := server.TestHTTP(t, "POST", apiStr, nil)
var jsonResp map[string]interface{}
if err := json.Unmarshal(r, &jsonResp); err != nil {
t.Fatalf("Unable to unmarshal repo creation response: %s\n", string(r))
}
v, ok := jsonResp["root"]
if !ok {
t.Fatalf("No 'root' metadata returned: %s\n", string(r))
}
uuidStr, ok := v.(string)
if !ok {
t.Fatalf("Couldn't cast returned 'root' data (%v) into string.\n", v)
}
uuid := dvid.UUID(uuidStr)
// Add a data instance.
var config dvid.Config
server.CreateTestInstance(t, uuid, "keyvalue", "foo", config)
// Make sure it exists.
_, err := datastore.GetDataByUUID(uuid, "foo")
if err != nil {
t.Errorf("Couldn't create data instance 'foo'\n")
}
// Shouldn't be able to delete instance without "imsure"
delReq := fmt.Sprintf("%srepo/%s/%s", server.WebAPIPath, uuid, "foo")
server.TestBadHTTP(t, "DELETE", delReq, nil)
delReq = fmt.Sprintf("%srepo/%s/%s?imsure=true", server.WebAPIPath, uuid, "foo")
server.TestHTTP(t, "DELETE", delReq, nil)
// Make sure it no longer exists.
_, err = datastore.GetDataByUUID(uuid, "foo")
if err == nil {
t.Errorf("Shouldn't be able to access a deleted data instance 'foo'\n")
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:43,代码来源:api_test.go
示例19: TestROIPostAndDelete
func TestROIPostAndDelete(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
// Create the ROI dataservice.
uuid, _ := initTestRepo()
config := dvid.NewConfig()
dataservice, err := datastore.NewData(uuid, roitype, "roi", config)
if err != nil {
t.Errorf("Error creating new roi instance: %v\n", err)
}
data, ok := dataservice.(*Data)
if !ok {
t.Errorf("Returned new data instance is not roi.Data\n")
}
// PUT an ROI
roiRequest := fmt.Sprintf("%snode/%s/%s/roi", server.WebAPIPath, uuid, data.DataName())
server.TestHTTP(t, "POST", roiRequest, getSpansJSON(testSpans))
// Get back the ROI
returnedData := server.TestHTTP(t, "GET", roiRequest, nil)
spans, err := putSpansJSON(returnedData)
if err != nil {
t.Errorf("Error on getting back JSON from roi GET: %v\n", err)
}
// Make sure the two are the same.
if !reflect.DeepEqual(spans, testSpans) {
t.Errorf("Bad PUT/GET ROI roundtrip\nOriginal:\n%s\nReturned:\n%s\n", testSpans, spans)
}
// Delete the ROI
_ = server.TestHTTP(t, "DELETE", roiRequest, nil)
// ROI should now be empty
returnedData = server.TestHTTP(t, "GET", roiRequest, nil)
if string(returnedData) != "[]" {
t.Errorf("Bad ROI after ROI delete. Should be [ ] got: %s\n", string(returnedData))
}
}
开发者ID:jmptrader,项目名称:dvid,代码行数:42,代码来源:roi_test.go
示例20: TestTileKey
func TestTileKey(t *testing.T) {
datastore.OpenTest()
defer datastore.CloseTest()
uuid, _ := initTestRepo()
server.CreateTestInstance(t, uuid, "imagetile", "tiles", dvid.Config{})
keyURL := fmt.Sprintf("%snode/%s/tiles/tilekey/xy/0/1_2_3", server.WebAPIPath, uuid)
respStr := server.TestHTTP(t, "GET", keyURL, nil)
keyResp := struct {
Key string `json:"key"`
}{}
if err := json.Unmarshal(respStr, &keyResp); err != nil {
t.Fatalf("Couldn't parse JSON response to tilekey request (%v):\n%s\n", err, keyResp)
}
kb := make([]byte, hex.DecodedLen(len(keyResp.Key)))
_, err := hex.Decode(kb, []byte(keyResp.Key))
if err != nil {
t.Fatalf("Couldn't parse return hex key: %s", keyResp.Key)
}
// Decipher TKey portion to make sure it's correct.
key := storage.Key(kb)
tk, err := storage.TKeyFromKey(key)
if err != nil {
t.Fatalf("Couldn't get TKey from returned key (%v): %x", err, kb)
}
tile, plane, scale, err := DecodeTKey(tk)
if err != nil {
t.Fatalf("Bad decode of TKey (%v): %x", err, tk)
}
expectTile := dvid.ChunkPoint3d{1, 2, 3}
if tile != expectTile {
t.Errorf("Expected tile %v, got %v\n", expectTile, tile)
}
if !plane.Equals(dvid.XY) {
t.Errorf("Expected plane to be XY, got %v\n", plane)
}
if scale != 0 {
t.Errorf("Expected scale to be 0, got %d\n", scale)
}
}
开发者ID:tartavull,项目名称:dvid,代码行数:42,代码来源:imagetile_test.go
注:本文中的github.com/janelia-flyem/dvid/datastore.OpenTest函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论