Skip to content

Commit

Permalink
Merge pull request #734 from mesg-foundation/fix/consistent-sid
Browse files Browse the repository at this point in the history
Use service id
  • Loading branch information
antho1404 authored Jan 27, 2019
2 parents fc4e57b + c14ecbc commit 938c878
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (e *taskExecutor) checkServiceStatus(s *service.Service) error {
return err
}
if status != service.RUNNING {
return &NotRunningServiceError{ServiceID: s.Hash}
return &NotRunningServiceError{ServiceID: s.Sid}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion commands/provider/service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (p *ServiceProvider) ServiceDeleteAll(deleteData bool) error {
errs.Append(err)
}
wg.Done()
}(s.Hash)
}(s.Sid)
}
wg.Wait()
return errs.ErrorOrNil()
Expand Down
2 changes: 1 addition & 1 deletion commands/service_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c *serviceDeployCmd) runE(cmd *cobra.Command, args []string) error {
errors.New("to get more information, run: mesg-core service validate"),
}
}
fmt.Printf("%s Service deployed with hash: %v\n", pretty.SuccessSign, pretty.Success(id))
fmt.Printf("%s Service deployed with id: %v\n", pretty.SuccessSign, pretty.Success(id))
fmt.Printf("To start it, run the command:\n\tmesg-core service start %s\n", id)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion commands/service_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestServiceDeploy(t *testing.T) {

require.Equal(t, "✔ 5", string(readLine(t, r)))
require.Equal(t, "⨯ 6", string(readLine(t, r)))
require.Equal(t, "✔ Service deployed with hash: 2", string(readLine(t, r)))
require.Equal(t, "✔ Service deployed with id: 2", string(readLine(t, r)))
require.Equal(t, "To start it, run the command:", string(readLine(t, r)))
require.Equal(t, " mesg-core service start 2", string(readLine(t, r)))

Expand Down
2 changes: 1 addition & 1 deletion interface/grpc/core/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *Server) DeployService(stream coreapi.Core_DeployServiceServer) error {

return stream.Send(&coreapi.DeployServiceReply{
Value: &coreapi.DeployServiceReply_ServiceID{
ServiceID: service.Hash,
ServiceID: service.Sid,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion interface/grpc/core/deploy_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestIntegrationDeployService(t *testing.T) {
require.Nil(t, server.DeployService(stream))
defer server.api.DeleteService(stream.serviceID, false)

require.Len(t, stream.serviceID, 40)
require.Len(t, stream.serviceID, 7)
require.Contains(t, stream.statuses, api.DeployStatus{
Message: "Image built with success",
Type: api.DonePositive,
Expand Down
2 changes: 1 addition & 1 deletion interface/grpc/core/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestDeployService(t *testing.T) {

stream := newTestDeployStream(url)
require.Nil(t, server.DeployService(stream))
require.Len(t, stream.serviceID, 40)
require.Len(t, stream.serviceID, 7)

require.Contains(t, stream.statuses, api.DeployStatus{
Message: "Image built with success",
Expand Down
12 changes: 6 additions & 6 deletions interface/grpc/core/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestExecute(t *testing.T) {
defer server.api.StopService(s.Hash)

reply, err := server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash,
ServiceID: s.Sid,
TaskKey: taskKey,
InputData: data,
})
Expand All @@ -45,7 +45,7 @@ func TestExecuteWithInvalidJSON(t *testing.T) {
defer server.api.DeleteService(s.Hash, false)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash,
ServiceID: s.Sid,
TaskKey: "test",
InputData: "",
})
Expand All @@ -69,7 +69,7 @@ func TestExecuteWithInvalidTask(t *testing.T) {
defer server.api.StopService(s.Hash)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash,
ServiceID: s.Sid,
TaskKey: taskKey,
InputData: "{}",
})
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestExecuteWithInvalidTaskInput(t *testing.T) {
defer server.api.StopService(s.Hash)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash,
ServiceID: s.Sid,
TaskKey: taskKey,
InputData: data,
})
Expand All @@ -118,11 +118,11 @@ func TestExecuteWithNonRunningService(t *testing.T) {
defer server.api.DeleteService(s.Hash, false)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash,
ServiceID: s.Sid,
TaskKey: "test",
InputData: "{}",
})
require.Equal(t, &api.NotRunningServiceError{ServiceID: s.Hash}, err)
require.Equal(t, &api.NotRunningServiceError{ServiceID: s.Sid}, err)
}

func TestExecuteWithNonExistingService(t *testing.T) {
Expand Down

0 comments on commit 938c878

Please sign in to comment.