Ejemplo n.º 1
0
func BenchmarkCommitBlobUpdate(b *testing.B) {
	err := services.InsertRepo(benchmarkRepo, "commitFound", benchmarkCommitHkid)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err = services.InsertRepo(benchmarkRepo, "commitFound", benchmarkCommitHkid)
		if err != nil {
			b.Fatal(err)
		}
	}
}
Ejemplo n.º 2
0
func BenchmarkCommitBlobInsert(b *testing.B) {
	for i := 0; i < b.N; i++ {
		err := services.InsertRepo(benchmarkRepo, "commitFound", benchmarkCommitHkid)
		//TODO clear list after each insert
		if err != nil {
			b.Fatal(err)
		}
	}
}
Ejemplo n.º 3
0
func BenchmarkTagBlobUpdate(b *testing.B) {
	err := services.InsertRepo(benchmarkRepo, "tagFound", benchmarkTagHkid)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err = services.InsertDomain(benchmarkRepo, "tagFound", benchmarkTagHkid)
		if err != nil {
			b.Fatal(err)
		}
	}
}
Ejemplo n.º 4
0
func TestPostCommitBlob(t *testing.T) {
	testhkid := objects.HkidFromDString("65232373562705602286177837897283"+
		"2941659551264911224937349783059207224141689361121606942380473043"+
		"7860475300564272976762085068519188612732562106886379081213385", 10)
	testRepoHkid := objects.HkidFromDString("22371143209450593169269383669277"+
		"1410459232098247632372342448006863927240156318431751613873181811"+
		"3842641285036340692759591635625837820111726090732747634977413", 10)
	services.InsertRepo(testhkid, "TestPostCommit", testRepoHkid)
	testpath := "TestPostCommit/TestPostBlob"
	indata := []byte("TestPostCommitBlobData")
	services.Post(testhkid, testpath, objects.Blob(indata))
	outdata, err := services.Get(testhkid, testpath)
	if !bytes.Equal(indata, outdata) || err != nil {
		t.Fail()
	}
}
Ejemplo n.º 5
0
func BenchmarkCommitBlobFound(b *testing.B) {
	err := services.InsertRepo(benchmarkRepo, "commitFound", benchmarkCommitHkid)
	if err != nil {
		b.Fatalf("Unable to insert Commit: %s", err)
	}
	_, err = services.Post(benchmarkRepo, "commitFound/benchmarkBlob",
		objects.Blob("Benchmark Blob Data"))
	if err != nil {
		b.Fatalf("Unable to post Commit Blob: %s", err)
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		_, err := services.Get(benchmarkRepo, "commitFound/benchmarkBlob")
		if err != nil {
			b.Fatalf("Unable to retrieve Commit Blob: %s", err)
		}
	}
}
Ejemplo n.º 6
0
func TestPostTagCommitBlob(t *testing.T) {
	testhkid := objects.HkidFromDString("46298148238932964800164113348087"+
		"9383618612455972320097996217675372497646408870646300138355611242"+
		"4820911870650421151988906751710824965155500230480521264034469", 10)
	domainHkid := objects.HkidFromDString("39968110670682397993178679825250"+
		"9423226869972672234437068973021071131498376777586055610149840018"+
		"5744208447673206609026128894016152514163591905578729891874833", 10)
	repoHkid := objects.HkidFromDString("94522678075182002377842140271746"+
		"1502019766737301062946423046280258817349516439546479625226895211"+
		"80808353215150536034481206091147220911087792299373183736254", 10)
	err := services.InsertDomain(testhkid, "testTag", domainHkid)
	if err != nil {
		t.Errorf("InsertDomain with error: %s", err)
	}
	err = services.InsertRepo(testhkid, "testTag/testCommit", repoHkid)
	indata := objects.Blob([]byte("TestTagCommitBlobData"))
	testpath := "testTag/testCommit/testBlob"
	_, err = services.Post(testhkid, testpath, indata)
	outdata, err := services.Get(testhkid, testpath)
	if !bytes.Equal(indata, outdata) || err != nil {
		t.Fail()
	}
}
Ejemplo n.º 7
0
func addCurators(inCommand struct {
	createDomain     *bool
	createRepository *bool
	insertDomain     *bool
	insertRepository *bool
	path             *string
	hkid             *string
}) {

	if *inCommand.path != "" {
		//log.Printf("HKID: %s", *hkid)
		in := bufio.NewReader(os.Stdin)
		var err error
		h, collectionPath := fileSystemPath2CollectionPath(inCommand.path)
		//log.Printf("systemPath %s", *path)
		//log.Printf("collectionPath %s", collectionPath)

		FileInfos, err := ioutil.ReadDir(*inCommand.path)
		if err != nil {
			log.Printf("Error reading directory %s", err)
			os.Exit(2)
			return
		}

		if len(FileInfos) != 0 {
			fmt.Printf("The folder is not empty")
			os.Exit(2)
			return // Ends function
		}

		collectionName := filepath.Base(*inCommand.path)
		//fmt.Printf("Name of Collection: %s\n", collectionName)

		switch {
		case *inCommand.createDomain:
			//err = InitDomain(h, fmt.Sprintf("%s/%s", collectionPath, collectionName))
			err = services.InitDomain(h, collectionPath)
			if err != nil {
				log.Println(err)
				return
			}

		case *inCommand.createRepository:
			//err = InitRepo(h, fmt.Sprintf("%s/%s", collectionPath, collectionName))
			err = services.InitRepo(h, collectionPath)
			if err != nil {
				log.Println(err)
				return
			}
		case *inCommand.insertDomain:
			fmt.Println("Insert HKID as a hexadecimal number:")
			hex := *inCommand.hkid
			if *inCommand.hkid == "" {
				hex, _ = in.ReadString('\n')
				hex = strings.Trim(hex, "\n")
			}
			log.Print(len(hex))
			foreignHkid, err := objects.HkidFromHex(hex)
			if err != nil {
				log.Printf("Somethng went wrong in insertDomain %s", err)
				os.Exit(2)
			}
			log.Printf("hkid: %s\n", h)
			err = services.InsertDomain(h, fmt.Sprintf("%s/%s", collectionPath, collectionName), foreignHkid)
			if err != nil {
				log.Println(err)
				return
			}
		case *inCommand.insertRepository:
			fmt.Println("Insert HKID as a hexadecimal number:")
			hex := *inCommand.hkid
			if *inCommand.hkid == "" {
				hex, _ = in.ReadString('\n')
				hex = strings.Trim(hex, "\n")
			}
			fmt.Printf("%s", hex)
			foreignHkid, err := objects.HkidFromHex(hex)
			if err != nil {
				log.Printf("Somethng went wrong in insertRepo %s", err)
				os.Exit(2)

			}
			fmt.Printf("hkid: %s", h)
			err = services.InsertRepo(h, fmt.Sprintf("%s/%s", collectionPath, collectionName), foreignHkid)
			if err != nil {
				log.Println(err)
				return
			}
		}
	}

}