本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pfs/pfsutil.StartCommit函数的典型用法代码示例。如果您正苦于以下问题:Golang StartCommit函数的具体用法?Golang StartCommit怎么用?Golang StartCommit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartCommit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFromCommit
func TestFromCommit(t *testing.T) {
t.Parallel()
repo := uniqueString("TestFromCommit")
pachClient := getPachClient(t)
seed := time.Now().UnixNano()
rand := rand.New(rand.NewSource(seed))
err := pfsutil.CreateRepo(pachClient, repo)
require.NoError(t, err)
commit1, err := pfsutil.StartCommit(pachClient, repo, "")
require.NoError(t, err)
_, err = pfsutil.PutFile(pachClient, repo, commit1.Id, "file", 0, workload.NewReader(rand, KB))
require.NoError(t, err)
err = pfsutil.FinishCommit(pachClient, repo, commit1.Id)
require.NoError(t, err)
commit2, err := pfsutil.StartCommit(pachClient, repo, commit1.Id)
require.NoError(t, err)
_, err = pfsutil.PutFile(pachClient, repo, commit2.Id, "file", 0, workload.NewReader(rand, KB))
require.NoError(t, err)
err = pfsutil.FinishCommit(pachClient, repo, commit2.Id)
require.NoError(t, err)
var buffer bytes.Buffer
require.NoError(t, pfsutil.GetFile(pachClient, repo, commit2.Id, "file", 0, 0, commit1.Id, nil, &buffer))
require.Equal(t, buffer.Len(), KB)
buffer = bytes.Buffer{}
require.NoError(t, pfsutil.GetFile(pachClient, repo, commit2.Id, "file", 0, 0, "", nil, &buffer))
require.Equal(t, buffer.Len(), 2*KB)
}
示例2: testFailures
func testFailures(t *testing.T, apiClient pfs.APIClient, cluster Cluster) {
repoName := "testFailuresRepo"
err := pfsutil.CreateRepo(apiClient, repoName)
require.NoError(t, err)
commit, err := pfsutil.StartCommit(apiClient, repoName, "")
require.NoError(t, err)
require.NotNil(t, commit)
newCommitID := commit.Id
err = pfsutil.MakeDirectory(apiClient, repoName, newCommitID, "a/b")
require.NoError(t, err)
err = pfsutil.MakeDirectory(apiClient, repoName, newCommitID, "a/c")
require.NoError(t, err)
doWrites(t, apiClient, repoName, newCommitID)
err = pfsutil.FinishCommit(apiClient, repoName, newCommitID)
require.NoError(t, err)
checkWrites(t, apiClient, repoName, newCommitID)
cluster.KillRoleAssigner()
for server := 0; server < testNumReplicas; server++ {
cluster.Kill(server)
}
cluster.RestartRoleAssigner()
cluster.WaitForAvailability()
checkWrites(t, apiClient, repoName, newCommitID)
}
示例3: testMountBig
func testMountBig(t *testing.T, apiClient pfs.APIClient, cluster Cluster) {
repoName := "testMountBigRepo"
err := pfsutil.CreateRepo(apiClient, repoName)
require.NoError(t, err)
directory := "/compile/testMount"
mounter := fuse.NewMounter("localhost", apiClient)
ready := make(chan bool)
go func() {
err = mounter.Mount(directory, 0, 1, ready)
require.NoError(t, err)
}()
<-ready
_, err = os.Stat(filepath.Join(directory, repoName))
require.NoError(t, err)
_, err = os.Stat(filepath.Join(directory, repoName, "scratch"))
require.NoError(t, err)
commit, err := pfsutil.StartCommit(apiClient, repoName, "scratch")
require.NoError(t, err)
require.NotNil(t, commit)
newCommitID := commit.Id
bigValue := make([]byte, 1024*1024*300)
for i := 0; i < 1024*1024*300; i++ {
bigValue[i] = 'a'
}
wg := sync.WaitGroup{}
for j := 0; j < 5; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
err := ioutil.WriteFile(filepath.Join(directory, repoName, newCommitID, fmt.Sprintf("big%d", j)), bigValue, 0666)
require.NoError(t, err)
}(j)
}
wg.Wait()
err = pfsutil.FinishCommit(apiClient, repoName, newCommitID)
require.NoError(t, err)
wg = sync.WaitGroup{}
for j := 0; j < 5; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
data, err := ioutil.ReadFile(filepath.Join(directory, repoName, newCommitID, fmt.Sprintf("big%d", j)))
require.NoError(t, err)
require.Equal(t, bigValue, data)
}(j)
}
wg.Wait()
err = mounter.Unmount(directory)
require.NoError(t, err)
}
示例4: TestMountBig
func TestMountBig(t *testing.T) {
t.Skip()
t.Parallel()
apiClient := getPfsClient(t)
repoName := uniqueString("testMountBigRepo")
err := pfsutil.CreateRepo(apiClient, repoName)
require.NoError(t, err)
directory := "/compile/testMount"
mounter := fuse.NewMounter("localhost", apiClient)
ready := make(chan bool)
go func() {
err = mounter.Mount(directory, &pfs.Shard{Number: 0, Modulus: 1}, nil, ready)
require.NoError(t, err)
}()
<-ready
_, err = os.Stat(filepath.Join(directory, repoName))
require.NoError(t, err)
commit, err := pfsutil.StartCommit(apiClient, repoName, "")
require.NoError(t, err)
require.NotNil(t, commit)
newCommitID := commit.Id
bigValue := make([]byte, 1024*1024*300)
for i := 0; i < 1024*1024*300; i++ {
bigValue[i] = 'a'
}
wg := sync.WaitGroup{}
for j := 0; j < 5; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
err := ioutil.WriteFile(filepath.Join(directory, repoName, newCommitID, fmt.Sprintf("big%d", j)), bigValue, 0666)
require.NoError(t, err)
}(j)
}
wg.Wait()
err = pfsutil.FinishCommit(apiClient, repoName, newCommitID)
require.NoError(t, err)
wg = sync.WaitGroup{}
for j := 0; j < 5; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
data, err := ioutil.ReadFile(filepath.Join(directory, repoName, newCommitID, fmt.Sprintf("big%d", j)))
require.NoError(t, err)
require.Equal(t, bigValue, data)
}(j)
}
wg.Wait()
err = mounter.Unmount(directory)
require.NoError(t, err)
}
示例5: TestJob
func TestJob(t *testing.T) {
t.Parallel()
dataRepo := uniqueString("TestJob.data")
pachClient := getPachClient(t)
require.NoError(t, pfsutil.CreateRepo(pachClient, dataRepo))
commit, err := pfsutil.StartCommit(pachClient, dataRepo, "")
require.NoError(t, err)
_, err = pfsutil.PutFile(pachClient, dataRepo, commit.Id, "file", 0, strings.NewReader("foo\n"))
require.NoError(t, err)
require.NoError(t, pfsutil.FinishCommit(pachClient, dataRepo, commit.Id))
job, err := ppsutil.CreateJob(
pachClient,
"",
[]string{"cp", path.Join("/pfs", dataRepo, "file"), "/pfs/out/file"},
nil,
1,
[]*pps.JobInput{{Commit: commit}},
"",
)
require.NoError(t, err)
inspectJobRequest := &pps.InspectJobRequest{
Job: job,
BlockOutput: true,
BlockState: true,
}
jobInfo, err := pachClient.InspectJob(context.Background(), inspectJobRequest)
require.NoError(t, err)
require.Equal(t, pps.JobState_JOB_STATE_SUCCESS.String(), jobInfo.State.String())
commitInfo, err := pfsutil.InspectCommit(pachClient, jobInfo.OutputCommit.Repo.Name, jobInfo.OutputCommit.Id)
require.NoError(t, err)
require.Equal(t, pfs.CommitType_COMMIT_TYPE_READ, commitInfo.CommitType)
var buffer bytes.Buffer
require.NoError(t, pfsutil.GetFile(pachClient, jobInfo.OutputCommit.Repo.Name, jobInfo.OutputCommit.Id, "file", 0, 0, "", nil, &buffer))
require.Equal(t, "foo\n", buffer.String())
}
示例6: TestJob
func TestJob(t *testing.T) {
dataRepo := uniqueString("TestJob.data")
pfsClient := getPfsClient(t)
require.NoError(t, pfsutil.CreateRepo(pfsClient, dataRepo))
commit, err := pfsutil.StartCommit(pfsClient, dataRepo, "")
require.NoError(t, err)
_, err = pfsutil.PutFile(pfsClient, dataRepo, commit.Id, "file", 0, strings.NewReader("foo"))
require.NoError(t, err)
require.NoError(t, pfsutil.FinishCommit(pfsClient, dataRepo, commit.Id))
ppsClient := getPpsClient(t)
job, err := ppsutil.CreateJob(
ppsClient,
"",
[]string{"cp", path.Join("/pfs", dataRepo, "file"), "/pfs/out/file"},
"",
1,
[]*pfs.Commit{commit},
"",
)
require.NoError(t, err)
inspectJobRequest := &pps.InspectJobRequest{
Job: job,
BlockOutput: true,
BlockState: true,
}
jobInfo, err := ppsClient.InspectJob(context.Background(), inspectJobRequest)
require.NoError(t, err)
var buffer bytes.Buffer
require.NoError(t, pfsutil.GetFile(pfsClient, jobInfo.OutputCommit.Repo.Name, jobInfo.OutputCommit.Id, "file", 0, 0, nil, &buffer))
require.Equal(t, "foo", buffer.String())
}
示例7: BenchmarkFuse
func BenchmarkFuse(b *testing.B) {
apiClient := getPfsClient(b)
repoName := uniqueString("benchMountRepo")
if err := pfsutil.CreateRepo(apiClient, repoName); err != nil {
b.Error(err)
}
directory := "/compile/benchMount"
mounter := fuse.NewMounter("localhost", apiClient)
ready := make(chan bool)
go func() {
err := mounter.Mount(directory, &pfs.Shard{Number: 0, Modulus: 1}, nil, ready)
require.NoError(b, err)
}()
<-ready
defer func() {
if err := mounter.Unmount(directory); err != nil {
b.Error(err)
}
}()
bigValue := make([]byte, 1024*1024)
for i := 0; i < 1024*1024; i++ {
bigValue[i] = 'a'
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
commit, err := pfsutil.StartCommit(apiClient, repoName, "")
if err != nil {
b.Error(err)
}
if commit == nil {
b.Error("nil branch")
}
newCommitID := commit.Id
var wg sync.WaitGroup
for j := 0; j < 1024; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
if err = ioutil.WriteFile(filepath.Join(directory, repoName, newCommitID, fmt.Sprintf("big%d", j)), bigValue, 0666); err != nil {
b.Error(err)
}
}(j)
}
wg.Wait()
if err := pfsutil.FinishCommit(apiClient, repoName, newCommitID); err != nil {
b.Error(err)
}
}
}
示例8: benchMount
func benchMount(b *testing.B, apiClient pfs.ApiClient) {
repositoryName := "benchMountRepo"
if err := pfsutil.CreateRepo(apiClient, repositoryName); err != nil {
b.Error(err)
}
directory := "/compile/benchMount"
mounter := fuse.NewMounter(apiClient)
if err := mounter.Mount(repositoryName, "", directory, 0, 1); err != nil {
b.Error(err)
}
defer func() {
if err := mounter.Unmount(directory); err != nil {
b.Error(err)
}
if err := mounter.Wait(directory); err != nil {
b.Error(err)
}
}()
bigValue := make([]byte, 1024*1024)
for i := 0; i < 1024*1024; i++ {
bigValue[i] = 'a'
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
commit, err := pfsutil.StartCommit(apiClient, repositoryName, "scratch")
if err != nil {
b.Error(err)
}
if commit == nil {
b.Error("nil branch")
}
newCommitID := commit.Id
var wg sync.WaitGroup
for j := 0; j < 1024; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
if err = ioutil.WriteFile(filepath.Join(directory, newCommitID, fmt.Sprintf("big%d", j)), bigValue, 0666); err != nil {
b.Error(err)
}
}(j)
}
wg.Wait()
if err := pfsutil.FinishCommit(apiClient, repositoryName, newCommitID); err != nil {
b.Error(err)
}
}
}
示例9: TestGrep
func TestGrep(t *testing.T) {
t.Skip()
t.Parallel()
dataRepo := uniqueString("TestGrep.data")
pfsClient := getPfsClient(t)
require.NoError(t, pfsutil.CreateRepo(pfsClient, dataRepo))
commit, err := pfsutil.StartCommit(pfsClient, dataRepo, "")
require.NoError(t, err)
for i := 0; i < 100; i++ {
_, err = pfsutil.PutFile(pfsClient, dataRepo, commit.Id, fmt.Sprintf("file%d", i), 0, strings.NewReader("foo\nbar\nfizz\nbuzz\n"))
require.NoError(t, err)
}
require.NoError(t, pfsutil.FinishCommit(pfsClient, dataRepo, commit.Id))
ppsClient := getPpsClient(t)
job1, err := ppsutil.CreateJob(
ppsClient,
"",
[]string{"bash"},
fmt.Sprintf("grep foo /pfs/%s/* >/pfs/out/foo", dataRepo),
1,
[]*pps.JobInput{{Commit: commit}},
"",
)
require.NoError(t, err)
job2, err := ppsutil.CreateJob(
ppsClient,
"",
[]string{"bash"},
fmt.Sprintf("grep foo /pfs/%s/* >/pfs/out/foo", dataRepo),
4,
[]*pps.JobInput{{Commit: commit}},
"",
)
require.NoError(t, err)
inspectJobRequest := &pps.InspectJobRequest{
Job: job1,
BlockOutput: true,
BlockState: true,
}
job1Info, err := ppsClient.InspectJob(context.Background(), inspectJobRequest)
require.NoError(t, err)
inspectJobRequest.Job = job2
job2Info, err := ppsClient.InspectJob(context.Background(), inspectJobRequest)
require.NoError(t, err)
repo1Info, err := pfsutil.InspectRepo(pfsClient, job1Info.OutputCommit.Repo.Name)
require.NoError(t, err)
repo2Info, err := pfsutil.InspectRepo(pfsClient, job2Info.OutputCommit.Repo.Name)
require.NoError(t, err)
require.Equal(t, repo1Info.SizeBytes, repo2Info.SizeBytes)
}
示例10: TestSharding
func TestSharding(t *testing.T) {
t.Parallel()
repo := uniqueString("TestSharding")
pachClient := getPachClient(t)
err := pfsutil.CreateRepo(pachClient, repo)
require.NoError(t, err)
commit, err := pfsutil.StartCommit(pachClient, repo, "")
require.NoError(t, err)
var wg sync.WaitGroup
for i := 0; i < NUMFILES; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
rand := rand.New(rand.NewSource(int64(i)))
_, err = pfsutil.PutFile(pachClient, repo, commit.Id, fmt.Sprintf("file%d", i), 0, workload.NewReader(rand, KB))
require.NoError(t, err)
}()
}
wg.Wait()
err = pfsutil.FinishCommit(pachClient, repo, commit.Id)
require.NoError(t, err)
wg = sync.WaitGroup{}
for i := 0; i < NUMFILES; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
var buffer1Shard bytes.Buffer
var buffer4Shard bytes.Buffer
shard := &pfs.Shard{FileModulus: 1, BlockModulus: 1}
err := pfsutil.GetFile(pachClient, repo, commit.Id,
fmt.Sprintf("file%d", i), 0, 0, "", shard, &buffer1Shard)
require.NoError(t, err)
shard.BlockModulus = 4
for blockNumber := uint64(0); blockNumber < 4; blockNumber++ {
shard.BlockNumber = blockNumber
err := pfsutil.GetFile(pachClient, repo, commit.Id,
fmt.Sprintf("file%d", i), 0, 0, "", shard, &buffer4Shard)
require.NoError(t, err)
}
require.Equal(t, buffer1Shard.Len(), buffer4Shard.Len())
}()
}
wg.Wait()
}
示例11: TestBigWrite
func TestBigWrite(t *testing.T) {
t.Parallel()
protolog.SetLevel(protolog.Level_LEVEL_DEBUG)
repo := uniqueString("TestBigWrite")
pfsClient := getPfsClient(t)
err := pfsutil.CreateRepo(pfsClient, repo)
require.NoError(t, err)
commit, err := pfsutil.StartCommit(pfsClient, repo, "")
require.NoError(t, err)
rand := rand.New(rand.NewSource(5))
_, err = pfsutil.PutFile(pfsClient, repo, commit.Id, "file", 0, workload.NewReader(rand, 10000))
require.NoError(t, err)
err = pfsutil.FinishCommit(pfsClient, repo, commit.Id)
require.NoError(t, err)
var buffer bytes.Buffer
err = pfsutil.GetFile(pfsClient, repo, commit.Id, "file", 0, 0, nil, &buffer)
require.NoError(t, err)
}
示例12: branch
func (b *brancher) branch(
repositoryName string,
commitID string,
) (string, error) {
commit, err := pfsutil.StartCommit(
b.pfsAPIClient,
repositoryName,
commitID,
)
if err != nil {
return "", err
}
b.lock.Lock()
defer b.lock.Unlock()
if existingCommitID, ok := b.outputRepositoryToBranchID[repositoryName]; ok {
// TODO(pedge) delete new branch
return existingCommitID, nil
}
b.outputRepositoryToBranchID[repositoryName] = commit.Id
return commit.Id, nil
}
示例13: TestSharding
func TestSharding(t *testing.T) {
t.Parallel()
repo := uniqueString("TestSharding")
pfsClient := getPfsClient(t)
err := pfsutil.CreateRepo(pfsClient, repo)
require.NoError(t, err)
commit, err := pfsutil.StartCommit(pfsClient, repo, "")
require.NoError(t, err)
var wg sync.WaitGroup
for i := 0; i < NUMFILES; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
rand := rand.New(rand.NewSource(int64(i)))
_, err = pfsutil.PutFile(pfsClient, repo, commit.Id, fmt.Sprintf("file%d", i), 0, workload.NewReader(rand, 128*1024*1024))
require.NoError(t, err)
}()
}
wg.Wait()
err = pfsutil.FinishCommit(pfsClient, repo, commit.Id)
require.NoError(t, err)
}
示例14: TestGrep
func TestGrep(t *testing.T) {
t.Parallel()
dataRepo := uniqueString("pachyderm.TestGrep.data")
pfsClient := getPfsClient(t)
require.NoError(t, pfsutil.CreateRepo(pfsClient, dataRepo))
commit, err := pfsutil.StartCommit(pfsClient, dataRepo, "")
require.NoError(t, err)
for i := 0; i < 100; i++ {
_, err = pfsutil.PutFile(pfsClient, dataRepo, commit.Id, fmt.Sprintf("file%d", i), 0, strings.NewReader("foo\nbar\nfizz\nbuzz\n"))
require.NoError(t, err)
}
require.NoError(t, pfsutil.FinishCommit(pfsClient, dataRepo, commit.Id))
ppsClient := getPpsClient(t)
_, err = ppsutil.CreateJob(
ppsClient,
"",
[]string{"bash"},
fmt.Sprintf("grep foo /pfs/%s/* >/pfs/out/foo", dataRepo),
1,
[]*pps.JobInput{{Commit: commit}},
"",
)
require.NoError(t, err)
}
示例15: TestBlockListCommits
func TestBlockListCommits(t *testing.T) {
t.Parallel()
apiClient := getPfsClient(t)
repoName := uniqueString("testBlockListCommitsRepo")
err := pfsutil.CreateRepo(apiClient, repoName)
require.NoError(t, err)
baseCommit, err := pfsutil.StartCommit(apiClient, repoName, "")
require.NoError(t, err)
err = pfsutil.FinishCommit(apiClient, repoName, baseCommit.Id)
require.NoError(t, err)
repo := &pfs.Repo{
Name: repoName,
}
listCommitRequest := &pfs.ListCommitRequest{
Repo: []*pfs.Repo{repo},
FromCommit: []*pfs.Commit{baseCommit},
}
commitInfos, err := apiClient.ListCommit(
context.Background(),
listCommitRequest,
)
require.NoError(t, err)
require.Equal(t, len(commitInfos.CommitInfo), 0)
var newCommit *pfs.Commit
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(1)
commit, err := pfsutil.StartCommit(apiClient, repoName, baseCommit.Id)
require.NoError(t, err)
require.NotNil(t, commit)
newCommit = commit
}()
listCommitRequest.Block = true
listCommitRequest.CommitType = pfs.CommitType_COMMIT_TYPE_WRITE
commitInfos, err = apiClient.ListCommit(
context.Background(),
listCommitRequest,
)
wg.Wait()
require.NoError(t, err)
require.Equal(t, len(commitInfos.CommitInfo), 1)
require.Equal(t, newCommit, commitInfos.CommitInfo[0].Commit)
wg = sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(1)
err := pfsutil.FinishCommit(apiClient, repoName, newCommit.Id)
require.NoError(t, err)
}()
listCommitRequest.Block = true
listCommitRequest.CommitType = pfs.CommitType_COMMIT_TYPE_READ
commitInfos, err = apiClient.ListCommit(
context.Background(),
listCommitRequest,
)
wg.Wait()
require.NoError(t, err)
require.Equal(t, len(commitInfos.CommitInfo), 1)
require.Equal(t, newCommit, commitInfos.CommitInfo[0].Commit)
}