本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pkg/require.NoError函数的典型用法代码示例。如果您正苦于以下问题:Golang NoError函数的具体用法?Golang NoError怎么用?Golang NoError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NoError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: testBlock
func testBlock(t *testing.T, apiServer persist.APIServer) {
jobInfo, err := apiServer.CreateJobInfo(context.Background(), &persist.JobInfo{})
require.NoError(t, err)
jobID := jobInfo.JobId
go func() {
_, err := apiServer.CreateJobOutput(
context.Background(),
&persist.JobOutput{
JobId: jobID,
OutputCommit: pfsutil.NewCommit("foo", "bar"),
})
require.NoError(t, err)
_, err = apiServer.CreateJobState(
context.Background(),
&persist.JobState{
JobId: jobID,
State: pps.JobState_JOB_STATE_SUCCESS,
})
require.NoError(t, err)
}()
_, err = apiServer.InspectJob(
context.Background(),
&pps.InspectJobRequest{
Job: &pps.Job{Id: jobID},
BlockOutput: true,
BlockState: true,
},
)
require.NoError(t, err)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:30,代码来源:rethink_api_server_test.go
示例2: testFailures
func testFailures(t *testing.T, apiClient pfs.ApiClient, internalAPIClient pfs.InternalApiClient, cluster Cluster) {
repositoryName := TestRepositoryName()
err := pfsutil.InitRepository(apiClient, repositoryName)
require.NoError(t, err)
commit, err := pfsutil.Branch(apiClient, repositoryName, "scratch")
require.NoError(t, err)
require.NotNil(t, commit)
newCommitID := commit.Id
err = pfsutil.MakeDirectory(apiClient, repositoryName, newCommitID, "a/b")
require.NoError(t, err)
err = pfsutil.MakeDirectory(apiClient, repositoryName, newCommitID, "a/c")
require.NoError(t, err)
doWrites(t, apiClient, repositoryName, newCommitID)
err = pfsutil.Write(apiClient, repositoryName, newCommitID)
require.NoError(t, err)
checkWrites(t, apiClient, repositoryName, newCommitID)
for server := 0; server < testNumReplicas; server++ {
cluster.Kill(server)
}
cluster.WaitForAvailability()
checkWrites(t, apiClient, repositoryName, newCommitID)
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:30,代码来源:testing_test.go
示例3: 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
示例4: TestGetNameToNodeInfo
func TestGetNameToNodeInfo(t *testing.T) {
pipeline, err := parse.NewParser().ParsePipeline("../parse/testdata/basic")
require.NoError(t, err)
nodeInfos, err := getNameToNodeInfo(pipeline.NameToNode)
require.NoError(t, err)
require.Equal(t, []string{"bar-node"}, nodeInfos["baz-node-bar-in-bar-out-in"].Parents)
}
开发者ID:sr,项目名称:pachyderm,代码行数:7,代码来源:run_test.go
示例5: RunTestWithRethinkAPIServer
func RunTestWithRethinkAPIServer(t *testing.T, testFunc func(t *testing.T, persistAPIServer persist.APIServer)) {
apiServer, err := NewTestRethinkAPIServer()
require.NoError(t, err)
defer func() {
require.NoError(t, apiServer.Close())
}()
testFunc(t, apiServer)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:8,代码来源:testing.go
示例6: runTestRethink
func runTestRethink(t *testing.T, testFunc func(*testing.T, Client)) {
client, err := getRethinkSession()
require.NoError(t, err)
defer func() {
require.NoError(t, client.Close())
}()
testFunc(t, client)
}
开发者ID:sr,项目名称:pachyderm,代码行数:8,代码来源:store_test.go
示例7: 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
示例8: 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
示例9: handleEndJobStatusOutputStream
func handleEndJobStatusOutputStream(t *testing.T, jobAPIClient pps.JobAPIClient, jobInfo *pps.JobInfo, outputStream pps.OutputStream) {
jobAPIGetJobLogsClient, err := jobAPIClient.GetJobLogs(
context.Background(),
&pps.GetJobLogsRequest{
Job: jobInfo.Job,
OutputStream: outputStream,
},
)
require.NoError(t, err)
require.NoError(t, protostream.WriteFromStreamingBytesClient(jobAPIGetJobLogsClient, protolog.Writer()))
}
开发者ID:alexdebrie,项目名称:pachyderm,代码行数:11,代码来源: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: 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
示例12: testMountBig
func testMountBig(t *testing.T, apiClient pfs.ApiClient, internalAPIClient pfs.InternalApiClient, cluster Cluster) {
repositoryName := TestRepositoryName()
err := pfsutil.InitRepository(apiClient, repositoryName)
require.NoError(t, err)
directory := "/compile/testMount"
mounter := fuse.NewMounter(apiClient)
err = mounter.Mount(repositoryName, "", directory, 0, 1)
require.NoError(t, err)
_, err = os.Stat(filepath.Join(directory, "scratch"))
require.NoError(t, err)
commit, err := pfsutil.Branch(apiClient, repositoryName, "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, newCommitID, fmt.Sprintf("big%d", j)), bigValue, 0666)
require.NoError(t, err)
}(j)
}
wg.Wait()
err = pfsutil.Write(apiClient, repositoryName, 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, 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)
err = mounter.Wait(directory)
require.NoError(t, err)
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:55,代码来源:testing_test.go
示例13: 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
示例14: waitForJob
func waitForJob(t *testing.T, jobAPIClient pps.JobAPIClient, job *pps.Job, timeoutSec int, expectError bool) *pps.JobInfo {
for i := 0; i < timeoutSec; i++ {
time.Sleep(1 * time.Second)
jobInfo, err := jobAPIClient.InspectJob(
context.Background(),
&pps.InspectJobRequest{
Job: job,
},
)
require.NoError(t, err)
if len(jobInfo.JobStatus) == 0 {
continue
}
jobStatus := jobInfo.JobStatus[0]
protolog.Infof("status of job %s at %d seconds: %v", job.Id, i+1, jobInfo.JobStatus)
switch jobStatus.Type {
case pps.JobStatusType_JOB_STATUS_TYPE_ERROR:
handleEndJobStatus(t, jobAPIClient, jobInfo)
if !expectError {
t.Fatalf("job %s had error", job.Id)
}
return jobInfo
case pps.JobStatusType_JOB_STATUS_TYPE_SUCCESS:
handleEndJobStatus(t, jobAPIClient, jobInfo)
if expectError {
t.Fatalf("job %s did not have error", job.Id)
}
return jobInfo
}
}
t.Fatalf("job %s did not finish in %d seconds", job.Id, timeoutSec)
return nil
}
开发者ID:alexdebrie,项目名称:pachyderm,代码行数:33,代码来源:testing_test.go
示例15: RunTest
func RunTest(
t *testing.T,
f func(*testing.T, pfs.ApiClient, pfs.InternalApiClient, Cluster),
) {
discoveryClient, err := getEtcdClient()
require.NoError(t, err)
var cluster Cluster
prototest.RunT(
t,
testNumServers,
func(servers map[string]*grpc.Server) {
cluster = registerFunc(t, discoveryClient, servers)
},
func(t *testing.T, clientConns map[string]*grpc.ClientConn) {
var clientConn *grpc.ClientConn
for _, c := range clientConns {
clientConn = c
break
}
f(
t,
pfs.NewApiClient(
clientConn,
),
pfs.NewInternalApiClient(
clientConn,
),
cluster,
)
},
)
cluster.Shutdown()
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:33,代码来源:testing.go
示例16: checkPFSOutput
func checkPFSOutput(t *testing.T, pfsAPIClient pfs.APIClient, outputCommit *pfs.Commit, filePathToContent map[string][]byte) {
for filePath, content := range filePathToContent {
getContent, err := getPFSContent(pfsAPIClient, outputCommit, filePath)
require.NoError(t, err)
require.Equal(t, content, getContent)
}
}
开发者ID:alexdebrie,项目名称:pachyderm,代码行数:7,代码来源:testing_test.go
示例17: TestWorkload
func TestWorkload(t *testing.T) {
t.Parallel()
pfsClient := getPfsClient(t)
ppsClient := getPpsClient(t)
seed := time.Now().UnixNano()
require.NoError(t, workload.RunWorkload(pfsClient, ppsClient, rand.New(rand.NewSource(seed)), 100))
}
开发者ID:alamehor,项目名称:pachyderm,代码行数:7,代码来源:pachyderm_test.go
示例18: RunBench
func RunBench(
b *testing.B,
f func(*testing.B, pfs.ApiClient),
) {
discoveryClient, err := getEtcdClient()
require.NoError(b, err)
var cluster Cluster
prototest.RunB(
b,
testNumServers,
func(servers map[string]*grpc.Server) {
cluster = registerFunc(b, discoveryClient, servers)
},
func(b *testing.B, clientConns map[string]*grpc.ClientConn) {
var clientConn *grpc.ClientConn
for _, c := range clientConns {
clientConn = c
break
}
f(
b,
pfs.NewApiClient(
clientConn,
),
)
},
)
cluster.Shutdown()
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:29,代码来源:testing.go
示例19: RunBench
func RunBench(
b *testing.B,
f func(*testing.B, pfs.APIClient),
) {
discoveryClient, err := getEtcdClient()
require.NoError(b, err)
var cluster *cluster
prototest.RunB(
b,
testNumServers,
func(servers map[string]*grpc.Server) {
cluster = registerFunc(b, discoveryClient, servers)
},
func(b *testing.B, clientConns map[string]*grpc.ClientConn) {
var clientConn *grpc.ClientConn
for _, c := range clientConns {
clientConn = c
break
}
go func() {
require.Equal(b, cluster.realSharder.AssignRoles(cluster.cancel), shard.ErrCancelled)
}()
cluster.WaitForAvailability()
f(
b,
pfs.NewAPIClient(
clientConn,
),
)
},
)
cluster.Shutdown()
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:33,代码来源:testing.go
示例20: doWrites
func doWrites(tb testing.TB, apiClient pfs.APIClient, repoName string, commitID string) {
var wg sync.WaitGroup
defer wg.Wait()
for i := 0; i < testSize; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
_, iErr := pfsutil.PutFile(apiClient, repoName, commitID,
fmt.Sprintf("a/b/file%d", i), 0, strings.NewReader(fmt.Sprintf("hello%d", i)))
require.NoError(tb, iErr)
_, iErr = pfsutil.PutFile(apiClient, repoName, commitID,
fmt.Sprintf("a/c/file%d", i), 0, strings.NewReader(fmt.Sprintf("hello%d", i)))
require.NoError(tb, iErr)
}()
}
}
开发者ID:Antobiotics,项目名称:pachyderm,代码行数:17,代码来源:testing_test.go
注:本文中的github.com/pachyderm/pachyderm/src/pkg/require.NoError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论