func do() error { runtime.GOMAXPROCS(runtime.NumCPU()) appEnv := &appEnv{} if err := env.Populate(appEnv, env.PopulateOptions{}); err != nil { return err } if appEnv.NumShards == 0 { appEnv.NumShards = defaultNumShards } var btrfsAPI btrfs.API switch appEnv.BtrfsDriverType { case "exec": btrfsAPI = btrfs.NewExecAPI() case "ffi": fallthrough default: btrfsAPI = btrfs.NewFFIAPI() } address := fmt.Sprintf("0.0.0.0:%d", appEnv.APIPort) combinedAPIServer := server.NewCombinedAPIServer( route.NewSharder( appEnv.NumShards, ), route.NewRouter( route.NewSingleAddresser( address, appEnv.NumShards, ), route.NewDialer(), address, ), drive.NewBtrfsDriver( appEnv.BtrfsRoot, btrfsAPI, ), ) server := grpc.NewServer(grpc.MaxConcurrentStreams(math.MaxUint32)) pfs.RegisterApiServer(server, combinedAPIServer) pfs.RegisterInternalApiServer(server, combinedAPIServer) listener, err := net.Listen("tcp", fmt.Sprintf(":%d", appEnv.APIPort)) if err != nil { return err } errC := make(chan error) go func() { errC <- server.Serve(listener) }() go func() { errC <- http.ListenAndServe(":8080", nil) }() if appEnv.TracePort != 0 { go func() { errC <- http.ListenAndServe(fmt.Sprintf(":%d", appEnv.TracePort), nil) }() } return <-errC }
func TestBtrfsExec(t *testing.T) { t.Parallel() driver := drive.NewBtrfsDriver(getBtrfsRootDir(t), btrfs.NewExecAPI()) runTest(t, driver, testSimple) }