Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mockgcp: improve ComputeServiceAttachment fidelity / testing #3247

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mockgcp/mockcompute/networksv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (s *NetworksV1) Insert(ctx context.Context, req *pb.InsertNetworkRequest) (
obj.SelfLinkWithId = PtrTo(buildComputeSelfLink(ctx, fmt.Sprintf("projects/%s/global/networks/%d", name.Project.ID, id)))
obj.Kind = PtrTo("compute#network")

if obj.NetworkFirewallPolicyEnforcementOrder == nil {
obj.NetworkFirewallPolicyEnforcementOrder = PtrTo("AFTER_CLASSIC_FIREWALL")
}

if err := s.storage.Create(ctx, fqn, obj); err != nil {
return nil, err
}
Expand Down
10 changes: 8 additions & 2 deletions mockgcp/mockcompute/regionalbackendservicev1.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ func (s *RegionalBackendServicesV1) Insert(ctx context.Context, req *pb.InsertRe
return nil, err
}

return s.newLRO(ctx, name.Project.ID)
op := &pb.Operation{}
return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) {
return obj, nil
})
}

func (s *RegionalBackendServicesV1) Update(ctx context.Context, req *pb.UpdateRegionBackendServiceRequest) (*pb.Operation, error) {
Expand Down Expand Up @@ -108,7 +111,10 @@ func (s *RegionalBackendServicesV1) Delete(ctx context.Context, req *pb.DeleteRe
return nil, err
}

return s.newLRO(ctx, name.Project.ID)
op := &pb.Operation{}
return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) {
return deleted, nil
})
}

type regionalBackendServiceName struct {
Expand Down
9 changes: 6 additions & 3 deletions mockgcp/mockcompute/regionalserviceattachmentv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func (s *RegionalServiceAttachmentV1) Get(ctx context.Context, req *pb.GetServic

obj := &pb.ServiceAttachment{}
if err := s.storage.Get(ctx, fqn, obj); err != nil {
if status.Code(err) == codes.NotFound {
return nil, status.Errorf(codes.NotFound, "The resource '%s' was not found", fqn)
}
return nil, err
}

Expand Down Expand Up @@ -79,7 +82,7 @@ func (s *RegionalServiceAttachmentV1) Insert(ctx context.Context, req *pb.Insert
op := &pb.Operation{
TargetId: obj.Id,
TargetLink: obj.SelfLink,
OperationType: PtrTo("insert"),
OperationType: PtrTo("compute.serviceAttachments.insert"),
User: PtrTo("[email protected]"),
}
return s.startRegionalLRO(ctx, name.Project.ID, name.Region, op, func() (proto.Message, error) {
Expand Down Expand Up @@ -115,7 +118,7 @@ func (s *RegionalServiceAttachmentV1) Patch(ctx context.Context, req *pb.PatchSe
op := &pb.Operation{
TargetId: obj.Id,
TargetLink: obj.SelfLink,
OperationType: PtrTo("patch"),
OperationType: PtrTo("compute.serviceAttachments.patch"),
User: PtrTo("[email protected]"),
}

Expand All @@ -141,7 +144,7 @@ func (s *RegionalServiceAttachmentV1) Delete(ctx context.Context, req *pb.Delete
op := &pb.Operation{
TargetId: deleted.Id,
TargetLink: deleted.SelfLink,
OperationType: PtrTo("delete"),
OperationType: PtrTo("compute.serviceAttachments.delete"),
User: PtrTo("[email protected]"),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ status:
fingerprint: abcdef0123A=
id: 1111111111111111
observedGeneration: 3
selfLink: https://www.googleapis.com/compute/beta/projects/example-project-01/regions/us-west1/serviceAttachments/computeserviceattachment-${uniqueId}
selfLink: https://www.googleapis.com/compute/beta/projects/kccdep-${uniqueId}/regions/us-west1/serviceAttachments/computeserviceattachment-${uniqueId}
Loading
Loading