(2 of 3) Rename to execution service

See Cq-Depend for rationale

BUG=None
TEST=generate

Cq-Depend: chromium:2903340
Change-Id: Ib523cf641dfc18120857e9dc7f6a80b5d80ba16c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2904099
Tested-by: C Shapiro <shapiroc@chromium.org>
Reviewed-by: Seewai Fu <seewaifu@google.com>
Reviewed-by: Derek Beckett <dbeckett@chromium.org>
diff --git a/lib/src/chromiumos/lro/manager_test.go b/lib/src/chromiumos/lro/manager_test.go
index 8be1bcc..aa9125d 100644
--- a/lib/src/chromiumos/lro/manager_test.go
+++ b/lib/src/chromiumos/lro/manager_test.go
@@ -13,7 +13,7 @@
 )
 
 type exampleServer struct {
-	api.UnimplementedTestServiceServer
+	api.UnimplementedExecutionServiceServer
 	*lro.Manager
 }
 
@@ -21,21 +21,17 @@
 	s.Manager = lro.New()
 	defer s.Manager.Close()
 	server := grpc.NewServer()
-	api.RegisterTestServiceServer(server, s)
+	api.RegisterExecutionServiceServer(server, s)
 	longrunning.RegisterOperationsServer(server, s.Manager)
 	return server.Serve(l)
 }
 
 func (s *exampleServer) RunTests(ctx context.Context, req *api.RunTestsRequest) (*longrunning.Operation, error) {
 	op := s.Manager.NewOperation()
-	go s.provision(ctx, req, op.Name)
+	go s.RunTests(ctx, req)
 	return op, nil
 }
 
-func (s *exampleServer) provision(ctx context.Context, req *api.RunTestsRequest, op string) {
-	s.Manager.SetResult(op, &api.RunTestsResponse{})
-}
-
 func RunServer() {
 	l, err := net.Listen("tcp", ":0")
 	if err != nil {
diff --git a/test/src/chromiumos/execution/cmd/executionserver/executionserver.go b/test/src/chromiumos/execution/cmd/executionserver/executionserver.go
new file mode 100644
index 0000000..523c215
--- /dev/null
+++ b/test/src/chromiumos/execution/cmd/executionserver/executionserver.go
@@ -0,0 +1,46 @@
+// Copyright 2021 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Package main implements the executionservice server
+package main
+
+import (
+	"context"
+	"log"
+	"net"
+
+	"chromiumos/lro"
+
+	"go.chromium.org/chromiumos/config/go/longrunning"
+	"go.chromium.org/chromiumos/config/go/test/api"
+	"google.golang.org/grpc"
+)
+
+// ExecutionServer implement a server that will run tests
+type ExecutionServer struct {
+	Manager *lro.Manager
+	logger  *log.Logger
+}
+
+// newExecutionServer creates a new test service server to listen to test requests.
+func newExecutionServer(l net.Listener, logger *log.Logger) (*grpc.Server, error) {
+	s := &ExecutionServer{
+		Manager: lro.New(),
+		logger:  logger,
+	}
+	defer s.Manager.Close()
+	server := grpc.NewServer()
+	api.RegisterExecutionServiceServer(server, s)
+	longrunning.RegisterOperationsServer(server, s.Manager)
+	logger.Println("executionservice listen to request at ", l.Addr().String())
+	return server, nil
+}
+
+// RunTests runs the requested tests.
+func (s *ExecutionServer) RunTests(ctx context.Context, req *api.RunTestsRequest) (*longrunning.Operation, error) {
+	s.logger.Println("Received api.RunTestsRequest: ", *req)
+	op := s.Manager.NewOperation()
+	s.Manager.SetResult(op.Name, &api.RunTestsResponse{})
+	return op, nil
+}
diff --git a/test/src/chromiumos/testservice/cmd/testservice/testserviceserver_test.go b/test/src/chromiumos/execution/cmd/executionserver/executionserver_test.go
similarity index 75%
rename from test/src/chromiumos/testservice/cmd/testservice/testserviceserver_test.go
rename to test/src/chromiumos/execution/cmd/executionserver/executionserver_test.go
index fd5806a..61450c8 100644
--- a/test/src/chromiumos/testservice/cmd/testservice/testserviceserver_test.go
+++ b/test/src/chromiumos/execution/cmd/executionserver/executionserver_test.go
@@ -15,8 +15,8 @@
 	"google.golang.org/grpc"
 )
 
-// TestTestServiceServer_Empty tests if TestServiceServer can handle emtpy requst without problem.
-func TestTestServiceServer_Empty(t *testing.T) {
+// TestExecutionServer_Empty tests if ExecutionServer can handle emtpy requst without problem.
+func TestExecutionServer_Empty(t *testing.T) {
 	var logBuf bytes.Buffer
 	l, err := net.Listen("tcp", ":0")
 	if err != nil {
@@ -24,7 +24,7 @@
 	}
 
 	ctx := context.Background()
-	srv, err := newTestServiceServer(l, log.New(&logBuf, "", log.LstdFlags|log.LUTC))
+	srv, err := newExecutionServer(l, log.New(&logBuf, "", log.LstdFlags|log.LUTC))
 	if err != nil {
 		t.Fatalf("Failed to start TestService server: %v", err)
 	}
@@ -37,7 +37,7 @@
 	}
 	defer conn.Close()
 
-	cl := api.NewTestServiceClient(conn)
+	cl := api.NewExecutionServiceClient(conn)
 	if _, err := cl.RunTests(ctx, &api.RunTestsRequest{}); err != nil {
 		t.Fatalf("Failed at api.RunTests: %v", err)
 	}
diff --git a/test/src/chromiumos/testservice/cmd/testservice/main.go b/test/src/chromiumos/execution/cmd/executionserver/main.go
similarity index 81%
rename from test/src/chromiumos/testservice/cmd/testservice/main.go
rename to test/src/chromiumos/execution/cmd/executionserver/main.go
index 083122e..a0c0948 100644
--- a/test/src/chromiumos/testservice/cmd/testservice/main.go
+++ b/test/src/chromiumos/execution/cmd/executionserver/main.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Package main implements the testservice used to run tests in RTD.
+// Package main implements the executionservice for running tests.
 package main
 
 import (
@@ -22,7 +22,7 @@
 // createLogFile creates a file and its parent directory for logging purpose.
 func createLogFile() (*os.File, error) {
 	t := time.Now()
-	fullPath := filepath.Join("/tmp/testservice/", t.Format("20060102-150405"))
+	fullPath := filepath.Join("/tmp/executionserver/", t.Format("20060102-150405"))
 	if err := os.MkdirAll(fullPath, 0755); err != nil {
 		return nil, fmt.Errorf("failed to create directory %v: %v", fullPath, err)
 	}
@@ -49,7 +49,7 @@
 		flag.Parse()
 
 		if *version {
-			fmt.Println("testservice version ", Version)
+			fmt.Println("executionservice version ", Version)
 			return 0
 		}
 
@@ -60,15 +60,15 @@
 		defer logFile.Close()
 
 		logger := newLogger(logFile)
-		logger.Println("Starting testservice version ", Version)
+		logger.Println("Starting executionservice version ", Version)
 		l, err := net.Listen("tcp", ":0")
 		if err != nil {
 			logger.Fatalln("Failed to create a net listener: ", err)
 			return 2
 		}
-		server, err := newTestServiceServer(l, logger)
+		server, err := newExecutionServer(l, logger)
 		if err != nil {
-			logger.Fatalln("Failed to start testservice server: ", err)
+			logger.Fatalln("Failed to start executionserver: ", err)
 		}
 
 		server.Serve(l)
diff --git a/test/src/chromiumos/testservice/cmd/testservice/testserviceserver.go b/test/src/chromiumos/testservice/cmd/testservice/testserviceserver.go
deleted file mode 100644
index 5aa3340..0000000
--- a/test/src/chromiumos/testservice/cmd/testservice/testserviceserver.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2021 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Package main implements the testservice server to listen to test and provision requests.
-package main
-
-import (
-	"context"
-	"log"
-	"net"
-
-	"chromiumos/lro"
-
-	"go.chromium.org/chromiumos/config/go/longrunning"
-	"go.chromium.org/chromiumos/config/go/test/api"
-	"google.golang.org/grpc"
-)
-
-// TestServiceServer implement a server that will listen to test and provision requests.
-type TestServiceServer struct {
-	Manager *lro.Manager
-	logger  *log.Logger
-}
-
-// newTestServiceServer creates a new test service server to listen to test requests.
-func newTestServiceServer(l net.Listener, logger *log.Logger) (*grpc.Server, error) {
-	s := &TestServiceServer{
-		Manager: lro.New(),
-		logger:  logger,
-	}
-	defer s.Manager.Close()
-	server := grpc.NewServer()
-	api.RegisterTestServiceServer(server, s)
-	longrunning.RegisterOperationsServer(server, s.Manager)
-	logger.Println("testservice listen to request at ", l.Addr().String())
-	return server, nil
-}
-
-// RunTests runs the requested tests.
-func (s *TestServiceServer) RunTests(ctx context.Context, req *api.RunTestsRequest) (*longrunning.Operation, error) {
-	s.logger.Println("Received api.RunTestsRequest: ", *req)
-	op := s.Manager.NewOperation()
-	s.Manager.SetResult(op.Name, &api.RunTestsResponse{})
-	return op, nil
-}