本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pfs/pfsutil.FinishCommit函数的典型用法代码示例。如果您正苦于以下问题:Golang FinishCommit函数的具体用法?Golang FinishCommit怎么用?Golang FinishCommit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FinishCommit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:tv42,项目名称:pachyderm,代码行数:27,代码来源:pachyderm_test.go
示例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)
}
开发者ID:Antobiotics,项目名称:pachyderm,代码行数:32,代码来源:testing_test.go
示例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)
}
开发者ID:alexdebrie,项目名称:pachyderm,代码行数:60,代码来源:testing_test.go
示例4: 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())
}
开发者ID:tv42,项目名称:pachyderm,代码行数:35,代码来源:pachyderm_test.go
示例5: 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)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:60,代码来源:testing_test.go
示例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())
}
开发者ID:tjyang,项目名称:pachyderm,代码行数:31,代码来源:pachyderm_test.go
示例7: CommitOutstanding
func (b *brancher) CommitOutstanding() error {
if err := b.destroyable.Destroy(); err != nil {
return err
}
for repositoryName, commitID := range b.outputRepositoryToBranchID {
if err := pfsutil.FinishCommit(
b.pfsAPIClient,
repositoryName,
commitID,
); err != nil {
return err
}
for inputRepositoryCommit := range b.outputRepositoryToInputRepositories[repositoryName] {
if err := b.storeClient.CreatePfsCommitMapping(
&pps.PfsCommitMapping{
InputRepository: inputRepositoryCommit.repositoryName,
InputCommitId: inputRepositoryCommit.commitID,
OutputRepository: repositoryName,
OutputCommitId: commitID,
Timestamp: prototime.TimeToTimestamp(b.timer.Now()),
},
); err != nil {
return err
}
}
}
return nil
}
开发者ID:sr,项目名称:pachyderm,代码行数:28,代码来源:brancher.go
示例8: 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)
}
}
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:54,代码来源:testing_test.go
示例9: 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)
}
}
}
开发者ID:sr,项目名称:pachyderm,代码行数:53,代码来源:testing_test.go
示例10: 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)
}
开发者ID:tottok-ug,项目名称:pachyderm,代码行数:50,代码来源:pachyderm_test.go
示例11: 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()
}
开发者ID:tv42,项目名称:pachyderm,代码行数:46,代码来源:pachyderm_test.go
示例12: 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)
}
开发者ID:vsayer,项目名称:pachyderm,代码行数:18,代码来源:pachyderm_test.go
示例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)
}
开发者ID:tottok-ug,项目名称:pachyderm,代码行数:23,代码来源:pachyderm_test.go
示例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)
}
开发者ID:vsayer,项目名称:pachyderm,代码行数:24,代码来源:pachyderm_test.go
示例15: TestCommitFinishedReadDir
//.........这里部分代码省略.........
default:
t.Errorf("grpc serve: %v", err)
}
}
}()
clientConn, err := grpc.Dial(localAddress, grpc.WithInsecure())
if err != nil {
t.Fatalf("grpc dial: %v", err)
}
apiClient := pfs.NewAPIClient(clientConn)
mounter := fuse.NewMounter(localAddress, apiClient)
mountpoint := filepath.Join(tmp, "mnt")
if err := os.Mkdir(mountpoint, 0700); err != nil {
t.Fatalf("mkdir mountpoint: %v", err)
}
ready := make(chan bool)
wg.Add(1)
go func() {
defer wg.Done()
if err := mounter.Mount(mountpoint, nil, nil, ready); err != nil {
t.Errorf("mount and serve: %v", err)
}
}()
<-ready
defer func() {
if err := mounter.Unmount(mountpoint); err != nil {
t.Errorf("unmount: %v", err)
}
}()
const (
repoName = "foo"
)
if err := pfsutil.CreateRepo(apiClient, repoName); err != nil {
t.Fatalf("CreateRepo: %v", err)
}
commit, err := pfsutil.StartCommit(apiClient, repoName, "")
if err != nil {
t.Fatalf("StartCommit: %v", err)
}
t.Logf("open commit %v", commit.Id)
const (
greetingName = "greeting"
greeting = "Hello, world\n"
greetingPerm = 0644
)
if err := ioutil.WriteFile(filepath.Join(mountpoint, repoName, commit.Id, greetingName), []byte(greeting), greetingPerm); err != nil {
t.Fatalf("WriteFile: %v", err)
}
const (
scriptName = "script"
script = "#!/bin/sh\necho foo\n"
scriptPerm = 0750
)
if err := ioutil.WriteFile(filepath.Join(mountpoint, repoName, commit.Id, scriptName), []byte(script), scriptPerm); err != nil {
t.Fatalf("WriteFile: %v", err)
}
if err := pfsutil.FinishCommit(apiClient, repoName, commit.Id); err != nil {
t.Fatalf("FinishCommit: %v", err)
}
if err := fstestutil.CheckDir(filepath.Join(mountpoint, repoName, commit.Id), map[string]fstestutil.FileInfoCheck{
greetingName: func(fi os.FileInfo) error {
// TODO respect greetingPerm
if g, e := fi.Mode(), os.FileMode(0666); g != e {
return fmt.Errorf("wrong mode: %v != %v", g, e)
}
if g, e := fi.Size(), int64(len(greeting)); g != e {
t.Errorf("wrong size: %v != %v", g, e)
}
// TODO show fileModTime as mtime
// if g, e := fi.ModTime().UTC(), fileModTime; g != e {
// t.Errorf("wrong mtime: %v != %v", g, e)
// }
return nil
},
scriptName: func(fi os.FileInfo) error {
// TODO respect scriptPerm
if g, e := fi.Mode(), os.FileMode(0666); g != e {
return fmt.Errorf("wrong mode: %v != %v", g, e)
}
if g, e := fi.Size(), int64(len(script)); g != e {
t.Errorf("wrong size: %v != %v", g, e)
}
// TODO show fileModTime as mtime
// if g, e := fi.ModTime().UTC(), fileModTime; g != e {
// t.Errorf("wrong mtime: %v != %v", g, e)
// }
return nil
},
}); err != nil {
t.Errorf("wrong directory content: %v", err)
}
}
开发者ID:tv42,项目名称:pachyderm,代码行数:101,代码来源:filesystem_test.go
示例16: testBlockListCommits
func testBlockListCommits(t *testing.T, apiClient pfs.APIClient, cluster Cluster) {
repoName := "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: repo,
From: 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)
}
开发者ID:Antobiotics,项目名称:pachyderm,代码行数:66,代码来源:testing_test.go
示例17: 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)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:68,代码来源:testing_test.go
示例18: Cmds
//.........这里部分代码省略.........
}
startCommit := &cobra.Command{
Use: "start-commit repo-name [parent-commit-id]",
Short: "Start a new commit.",
Long: "Start a new commit with parent-commit-id as the parent.",
Run: pkgcobra.RunBoundedArgs(pkgcobra.Bounds{Min: 1, Max: 2}, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
parentCommitID := ""
if len(args) == 2 {
parentCommitID = args[1]
}
commit, err := pfsutil.StartCommit(apiClient, args[0], parentCommitID)
if err != nil {
return err
}
fmt.Println(commit.Id)
return nil
}),
}
finishCommit := &cobra.Command{
Use: "finish-commit repo-name commit-id",
Short: "Finish a started commit.",
Long: "Finish a started commit. Commit-id must be a writeable commit.",
Run: pkgcobra.RunFixedArgs(2, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
return pfsutil.FinishCommit(apiClient, args[0], args[1])
}),
}
inspectCommit := &cobra.Command{
Use: "inspect-commit repo-name commit-id",
Short: "Return info about a commit.",
Long: "Return info about a commit.",
Run: pkgcobra.RunFixedArgs(2, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
commitInfo, err := pfsutil.InspectCommit(apiClient, args[0], args[1])
if err != nil {
return err
}
if commitInfo == nil {
return fmt.Errorf("commit %s not found", args[1])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintCommitInfoHeader(writer)
pretty.PrintCommitInfo(writer, commitInfo)
return writer.Flush()
}),
}
listCommit := &cobra.Command{
Use: "list-commit repo-name",
Short: "Return all commits on a repo.",
Long: "Return all commits on a repo.",
Run: pkgcobra.RunFixedArgs(1, func(args []string) error {
apiClient, err := getAPIClient(address)
开发者ID:tv42,项目名称:pachyderm,代码行数:67,代码来源:cmds.go
示例19: Cmds
//.........这里部分代码省略.........
}
startCommit := &cobra.Command{
Use: "start-commit repo-name [parent-commit-id]",
Short: "Start a new commit.",
Long: "Start a new commit with parent-commit-id as the parent.",
Run: pkgcobra.RunBoundedArgs(pkgcobra.Bounds{Min: 1, Max: 2}, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
parentCommitID := ""
if len(args) == 2 {
parentCommitID = args[1]
}
commit, err := pfsutil.StartCommit(apiClient, args[0], parentCommitID)
if err != nil {
return err
}
fmt.Println(commit.Id)
return nil
}),
}
finishCommit := &cobra.Command{
Use: "finish-commit repo-name commit-id",
Short: "Finish a started commit.",
Long: "Finish a started commit. Commit-id must be a writeable commit.",
Run: pkgcobra.RunFixedArgs(2, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
return pfsutil.FinishCommit(apiClient, args[0], args[1])
}),
}
inspectCommit := &cobra.Command{
Use: "inspect-commit repo-name commit-id",
Short: "Return info about a commit.",
Long: "Return info about a commit.",
Run: pkgcobra.RunFixedArgs(2, func(args []string) error {
apiClient, err := getAPIClient(address)
if err != nil {
return err
}
commitInfo, err := pfsutil.InspectCommit(apiClient, args[0], args[1])
if err != nil {
return err
}
if commitInfo == nil {
return fmt.Errorf("commit %s not found", args[1])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintCommitInfoHeader(writer)
pretty.PrintCommitInfo(writer, commitInfo)
return writer.Flush()
}),
}
listCommit := &cobra.Command{
Use: "list-commit repo-name",
Short: "Return all commits on a repo.",
Long: "Return all commits on a repo.",
Run: pkgcobra.RunFixedArgs(1, func(args []string) error {
apiClient, err := getAPIClient(address)
开发者ID:angelabier1,项目名称:pachyderm,代码行数:67,代码来源:cmds.go
示例20: do
func do(appEnvObj interface{}) error {
appEnv := appEnvObj.(*appEnv)
logrus.Register()
address := appEnv.PachydermPfsd1Port
if address == "" {
address = appEnv.Address
} else {
address = strings.Replace(address, "tcp://", "", -1)
}
clientConn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
return err
}
apiClient := pfs.NewApiClient(clientConn)
var shard int
var modulus int
createRepo := cobramainutil.Command{
Use: "create-repo repo-name",
Short: "Create a new repo.",
Long: "Create a new repo.",
NumArgs: 1,
Run: func(cmd *cobra.Command, args []string) error {
return pfsutil.CreateRepo(apiClient, args[0])
},
}.ToCobraCommand()
inspectRepo := cobramainutil.Command{
Use: "inspect-repo repo-name",
Short: "Return info about a repo.",
Long: "Return info about a repo.",
NumArgs: 1,
Run: func(cmd *cobra.Command, args []string) error {
repoInfo, err := pfsutil.InspectRepo(apiClient, args[0])
if err != nil {
return err
}
if repoInfo == nil {
return fmt.Errorf("repo %s not found", args[0])
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintRepoHeader(writer)
pretty.PrintRepoInfo(writer, repoInfo)
return writer.Flush()
},
}.ToCobraCommand()
listRepo := cobramainutil.Command{
Use: "list-repo",
Short: "Return all repos.",
Long: "Reutrn all repos.",
NumArgs: 0,
Run: func(cmd *cobra.Command, args []string) error {
repoInfos, err := pfsutil.ListRepo(apiClient)
if err != nil {
return err
}
writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
pretty.PrintRepoHeader(writer)
for _, repoInfo := range repoInfos {
pretty.PrintRepoInfo(writer, repoInfo)
}
return writer.Flush()
},
}.ToCobraCommand()
deleteRepo := cobramainutil.Command{
Use: "delete-repo repo-name",
Short: "Delete a repo.",
Long: "Delete a repo.",
NumArgs: 1,
Run: func(cmd *cobra.Command, args []string) error {
return pfsutil.DeleteRepo(apiClient, args[0])
},
}.ToCobraCommand()
startCommit := cobramainutil.Command{
Use: "start-commit repo-name parent-commit-id",
Short: "Start a new commit.",
Long: "Start a new commit with parent-commit-id as the parent.",
NumArgs: 2,
Run: func(cmd *cobra.Command, args []string) error {
commit, err := pfsutil.StartCommit(apiClient, args[0], args[1])
if err != nil {
return err
}
fmt.Println(commit.Id)
return nil
},
}.ToCobraCommand()
finishCommit := cobramainutil.Command{
Use: "finish-commit repo-name commit-id",
Short: "Finish a started commit.",
Long: "Finish a started commit. Commit-id must be a writeable commit.",
NumArgs: 2,
Run: func(cmd *cobra.Command, args []string) error {
return pfsutil.FinishCommit(apiClient, args[0], args[1])
},
//.........这里部分代码省略.........
开发者ID:sr,项目名称:pachyderm,代码行数:101,代码来源:main.go
注:本文中的github.com/pachyderm/pachyderm/src/pfs/pfsutil.FinishCommit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论