本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pkg/require.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的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: 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
示例3: run
func (s *serverGroup) run(t *testing.T) {
var wg sync.WaitGroup
defer wg.Wait()
for i, server := range s.servers {
wg.Add(1)
i := i
server := server
go func() {
defer wg.Done()
require.Equal(
t,
shard.ErrCancelled,
s.sharder.Register(s.cancel, fmt.Sprintf("address-%d", i+s.offset), server),
)
}()
}
for i, frontend := range s.frontends {
wg.Add(1)
i := i
frontend := frontend
go func() {
defer wg.Done()
require.Equal(
t,
shard.ErrCancelled,
s.sharder.RegisterFrontend(s.cancel, fmt.Sprintf("address-%d", i+s.offset), frontend),
)
}()
}
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:30,代码来源:route_test.go
示例4: testRun
func testRun(t *testing.T, imageName string, commands []string, expectedStdout string, expectedStderr string) {
client, err := newTestDockerClient()
require.NoError(t, err)
err = client.Pull(imageName, PullOptions{})
require.NoError(t, err)
containers, err := client.Create(
imageName,
CreateOptions{
HasCommand: commands != nil,
},
)
require.NoError(t, err)
require.Equal(t, 1, len(containers))
container := containers[0]
err = client.Start(
container,
StartOptions{
Commands: commands,
},
)
require.NoError(t, err)
err = client.Wait(container, WaitOptions{})
require.NoError(t, err)
stdout := bytes.NewBuffer(nil)
stderr := bytes.NewBuffer(nil)
err = client.Logs(container, LogsOptions{Stdout: stdout, Stderr: stderr})
require.NoError(t, err)
require.Equal(t, expectedStdout, stdout.String())
require.Equal(t, expectedStderr, stderr.String())
err = client.Remove(container, RemoveOptions{})
require.NoError(t, err)
}
开发者ID:sr,项目名称:pachyderm,代码行数:32,代码来源:docker_client_test.go
示例5: runWatchTest
func runWatchTest(t *testing.T, client Client) {
cancel := make(chan bool)
err := client.Watch(
"watch/foo",
cancel,
func(value string) error {
if value == "" {
return client.Set("watch/foo", "bar", 0)
}
require.Equal(t, "bar", value)
close(cancel)
return nil
},
)
require.Equal(t, ErrCancelled, err)
cancel = make(chan bool)
err = client.WatchAll(
"watchAll/foo",
cancel,
func(value map[string]string) error {
if value == nil {
return client.Set("watchAll/foo/bar", "quux", 0)
}
require.Equal(t, map[string]string{"watchAll/foo/bar": "quux"}, value)
close(cancel)
return nil
},
)
require.Equal(t, ErrCancelled, err)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:31,代码来源:discovery_test.go
示例6: newCluster
func newCluster(tb testing.TB, discoveryClient discovery.Client, servers map[string]*grpc.Server) *cluster {
realSharder := shard.NewTestSharder(
discoveryClient,
testShardsPerServer*testNumServers,
testNumReplicas,
testNamespace(),
)
sharder := route.NewSharder(
testShardsPerServer*testNumServers,
testNumReplicas,
)
cluster := cluster{
servers: make(map[string]server.APIServer),
internalServers: make(map[string]server.InternalAPIServer),
cancels: make(map[string]chan bool),
internalCancels: make(map[string]chan bool),
cancel: make(chan bool),
realSharder: realSharder,
sharder: sharder,
tb: tb,
}
for address, s := range servers {
cluster.addresses = append(cluster.addresses, address)
router := route.NewRouter(
cluster.realSharder,
grpcutil.NewDialer(
grpc.WithInsecure(),
),
address,
)
apiServer := server.NewAPIServer(
cluster.sharder,
router,
)
cluster.servers[address] = apiServer
cluster.cancels[address] = make(chan bool)
go func(address string) {
require.Equal(tb, cluster.realSharder.RegisterFrontend(cluster.cancels[address], address, cluster.servers[address]), shard.ErrCancelled)
}(address)
pfs.RegisterAPIServer(s, apiServer)
internalAPIServer := server.NewInternalAPIServer(
cluster.sharder,
router,
getDriver(tb, address),
)
pfs.RegisterInternalAPIServer(s, internalAPIServer)
cluster.internalServers[address] = internalAPIServer
cluster.internalCancels[address] = make(chan bool)
go func(address string) {
require.Equal(tb, cluster.realSharder.Register(cluster.internalCancels[address], address, cluster.internalServers[address]), shard.ErrCancelled)
}(address)
}
return &cluster
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:54,代码来源:testing.go
示例7: 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
示例8: Restart
func (c *cluster) Restart(server int) {
address := c.addresses[server]
c.cancels[address] = make(chan bool)
go func() {
require.Equal(c.tb, c.addresser.Register(c.cancels[address], address, address, c.internalServers[address]), route.ErrCancelled)
}()
}
开发者ID:sr,项目名称:pachyderm,代码行数:7,代码来源:testing.go
示例9: 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
示例10: 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
示例11: 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
示例12: newCluster
func newCluster(tb testing.TB, discoveryClient discovery.Client, servers map[string]*grpc.Server) Cluster {
cluster := cluster{
rolers: make(map[string]role.Roler),
servers: make(map[string]server.CombinedAPIServer),
addresser: route.NewDiscoveryAddresser(
discoveryClient,
testNamespace(),
),
sharder: route.NewSharder(
testShardsPerServer * testNumServers,
),
tb: tb,
}
for address, s := range servers {
combinedAPIServer := server.NewCombinedAPIServer(
cluster.sharder,
route.NewRouter(
cluster.addresser,
grpcutil.NewDialer(
grpc.WithInsecure(),
),
address,
),
getDriver(tb, address),
)
pfs.RegisterApiServer(s, combinedAPIServer)
pfs.RegisterInternalApiServer(s, combinedAPIServer)
roler := role.NewRoler(cluster.addresser, cluster.sharder, combinedAPIServer, address, testNumReplicas)
go func() { require.Equal(tb, roler.Run(), discovery.ErrCancelled) }()
cluster.addresses = append(cluster.addresses, address)
cluster.rolers[address] = roler
cluster.servers[address] = combinedAPIServer
}
return &cluster
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:35,代码来源:testing.go
示例13: 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
示例14: 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
示例15: 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
示例16: testBasicRethink
func testBasicRethink(t *testing.T, apiServer persist.APIServer) {
jobInfo, err := apiServer.CreateJobInfo(
context.Background(),
&persist.JobInfo{
Spec: &persist.JobInfo_PipelineName{
PipelineName: "foo",
},
},
)
require.NoError(t, err)
getJobInfo, err := apiServer.GetJobInfo(
context.Background(),
&pps.Job{
Id: jobInfo.JobId,
},
)
require.NoError(t, err)
require.Equal(t, jobInfo.JobId, getJobInfo.JobId)
require.Equal(t, "foo", getJobInfo.GetPipelineName())
}
开发者ID:klucar,项目名称:pachyderm,代码行数:20,代码来源:rethink_api_server_test.go
示例17: run
func (s *serverGroup) run(t *testing.T) {
var wg sync.WaitGroup
defer wg.Wait()
for _, roler := range s.rolers {
wg.Add(1)
go func(roler Roler) {
defer wg.Done()
require.Equal(t, discovery.ErrCancelled, roler.Run())
}(roler)
}
}
开发者ID:kunthar,项目名称:pachyderm,代码行数:11,代码来源:roler_test.go
示例18: runTest
func runTest(t *testing.T, client Client) {
err := client.Set("foo", "one", 0)
require.NoError(t, err)
value, err := client.Get("foo")
require.NoError(t, err)
require.Equal(t, "one", value)
//values, err := client.GetAll("foo")
//require.NoError(t, err)
//require.Equal(t, map[string]string{"foo": "one"}, values)
err = client.Set("a/b/foo", "one", 0)
require.NoError(t, err)
err = client.Set("a/b/bar", "two", 0)
require.NoError(t, err)
values, err := client.GetAll("a/b")
require.NoError(t, err)
require.Equal(t, map[string]string{"a/b/foo": "one", "a/b/bar": "two"}, values)
require.NoError(t, client.Close())
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:20,代码来源:discovery_test.go
示例19: TestSimple
func TestSimple(t *testing.T) {
driver, err := NewDriver(getBtrfsRootDir(t), "drive.TestSimple")
require.NoError(t, err)
shards := make(map[uint64]bool)
shards[0] = true
repo := &pfs.Repo{Name: "drive.TestSimple"}
require.NoError(t, driver.CreateRepo(repo))
commit1 := &pfs.Commit{
Repo: repo,
Id: "commit1",
}
require.NoError(t, driver.StartCommit(nil, commit1, shards))
file1 := &pfs.File{
Commit: commit1,
Path: "foo",
}
require.NoError(t, driver.PutFile(file1, 0, 0, strings.NewReader("foo")))
require.NoError(t, driver.FinishCommit(commit1, shards))
reader, err := driver.GetFile(file1, 0)
require.NoError(t, err)
contents, err := ioutil.ReadAll(reader)
require.NoError(t, err)
require.Equal(t, string(contents), "foo")
commit2 := &pfs.Commit{
Repo: repo,
Id: "commit2",
}
require.NoError(t, driver.StartCommit(commit1, commit2, shards))
file2 := &pfs.File{
Commit: commit2,
Path: "bar",
}
require.NoError(t, driver.PutFile(file2, 0, 0, strings.NewReader("bar")))
require.NoError(t, driver.FinishCommit(commit2, shards))
changes, err := driver.ListChange(file2, commit1, 0)
require.NoError(t, err)
require.Equal(t, len(changes), 1)
require.Equal(t, changes[0].File, file2)
require.Equal(t, changes[0].OffsetBytes, uint64(0))
require.Equal(t, changes[0].SizeBytes, uint64(3))
}
开发者ID:sr,项目名称:pachyderm,代码行数:41,代码来源:btrfs_test.go
示例20: getJobForPipeline
func getJobForPipeline(t *testing.T, jobAPIClient pps.JobAPIClient, pipeline *pps.Pipeline) *pps.Job {
jobInfos, err := jobAPIClient.ListJob(
context.Background(),
&pps.ListJobRequest{
Pipeline: pipeline,
},
)
require.NoError(t, err)
require.NotNil(t, jobInfos)
require.Equal(t, 1, len(jobInfos.JobInfo))
return jobInfos.JobInfo[0].Job
}
开发者ID:alexdebrie,项目名称:pachyderm,代码行数:12,代码来源:testing_test.go
注:本文中的github.com/pachyderm/pachyderm/src/pkg/require.Equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论