Exemplo n.º 1
0
func runTest(
	t *testing.T,
	f func(t *testing.T, apiClient pps.ApiClient),
) {
	storeClient, err := getRethinkClient()
	require.NoError(t, err)
	pfstesting.RunTest(
		t,
		func(t *testing.T, apiClient pfs.ApiClient, internalApiClient pfs.InternalApiClient) {
			grpctest.Run(
				t,
				testNumServers,
				func(servers map[string]*grpc.Server) {
					for _, server := range servers {
						pps.RegisterApiServer(server, newAPIServer(apiClient, storeClient, timing.NewSystemTimer()))
					}
				},
				func(t *testing.T, clientConns map[string]*grpc.ClientConn) {
					var clientConn *grpc.ClientConn
					for _, c := range clientConns {
						clientConn = c
						break
					}
					f(
						t,
						pps.NewApiClient(
							clientConn,
						),
					)
				},
			)
		},
	)
}
Exemplo n.º 2
0
func newInMemoryClient() *inMemoryClient {
	return &inMemoryClient{
		make(map[string]*pps.PipelineRun),
		make(map[string][]*pps.PipelineRunStatus),
		make(map[string][]*pps.PipelineRunContainer),
		make(map[string][]*pps.PipelineRunLog),
		make(map[string][]*pps.PfsCommitMapping),
		timing.NewSystemTimer(),
		&sync.RWMutex{},
		&sync.RWMutex{},
		&sync.RWMutex{},
		&sync.RWMutex{},
		&sync.RWMutex{},
	}
}
Exemplo n.º 3
0
func newRethinkClient(address string, databaseName string) (*rethinkClient, error) {
	session, err := gorethink.Connect(gorethink.ConnectOpts{Address: address})
	if err != nil {
		return nil, err
	}
	return &rethinkClient{
		session,
		databaseName,
		timing.NewSystemTimer(),
		gorethink.DB(databaseName).Table(runTable),
		gorethink.DB(databaseName).Table(statusTable),
		gorethink.DB(databaseName).Table(containerTable),
		gorethink.DB(databaseName).Table(logTable),
		gorethink.DB(databaseName).Table(pfsCommitMappingTable),
	}, nil
}
Exemplo n.º 4
0
func newRethinkClient(address string, databaseName string) (*rethinkClient, error) {
	session, err := gorethink.Connect(gorethink.ConnectOpts{Address: address})
	if err != nil {
		return nil, err
	}
	return &rethinkClient{
		session,
		databaseName,
		timing.NewSystemTimer(),
		gorethink.DB(databaseName).Table(pfsCommitMappingsTable),
		gorethink.DB(databaseName).Table(pipelinesTable),
		gorethink.DB(databaseName).Table(pipelineContainersTable),
		gorethink.DB(databaseName).Table(pipelineLogsTable),
		gorethink.DB(databaseName).Table(pipelineRunsTable),
		gorethink.DB(databaseName).Table(pipelineRunStatusesTable),
		gorethink.DB(databaseName).Table(pipelineSourcesTable),
	}, nil
}
Exemplo n.º 5
0
func do(appEnvObj interface{}) error {
	appEnv := appEnvObj.(*appEnv)
	rethinkClient, err := getRethinkClient(appEnv.DatabaseAddress, appEnv.DatabaseName)
	if err != nil {
		return err
	}
	apiClient, err := getPfsAPIClient(appEnv.PfsAddress)
	if err != nil {
		return err
	}
	return grpcutil.GrpcDo(
		appEnv.APIPort,
		appEnv.TracePort,
		pachyderm.Version,
		func(s *grpc.Server) {
			pps.RegisterApiServer(s, server.NewAPIServer(apiClient, rethinkClient, timing.NewSystemTimer()))
		},
	)
}
Exemplo n.º 6
0
Arquivo: main.go Projeto: sr/pachyderm
func do(appEnvObj interface{}) error {
	appEnv := appEnvObj.(*appEnv)
	logrus.Register()
	containerClient, err := getContainerClient(appEnv.DockerHost)
	if err != nil {
		return err
	}
	rethinkClient, err := getRethinkClient(appEnv.DatabaseAddress, appEnv.DatabaseName)
	if err != nil {
		return err
	}
	pfsAddress := appEnv.PachydermPfsd1Port
	if pfsAddress == "" {
		pfsAddress = appEnv.PfsAddress
	} else {
		pfsAddress = strings.Replace(pfsAddress, "tcp://", "", -1)
	}
	clientConn, err := grpc.Dial(pfsAddress, grpc.WithInsecure())
	if err != nil {
		return err
	}
	// TODO(pedge): no!
	trace.AuthRequest = func(_ *http.Request) (bool, bool) {
		return true, true
	}
	return protoserver.Serve(
		uint16(appEnv.Port),
		func(s *grpc.Server) {
			pps.RegisterApiServer(s, server.NewAPIServer(pfs.NewApiClient(clientConn), containerClient, rethinkClient, timing.NewSystemTimer()))
		},
		protoserver.ServeOptions{
			DebugPort: uint16(appEnv.DebugPort),
			Version:   pachyderm.Version,
		},
	)
}