Skip to content

Commit

Permalink
More error context in controller and identity sanity tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avorima committed Apr 14, 2021
1 parent df74ae0 commit bb5ec31
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.Aborted))
Expect(serverError.Code()).To(Equal(codes.Aborted), "unexpected error: %s", serverError.Message())
})

It("check the presence of new volumes and absence of deleted ones in the volume list", func() {
Expand Down Expand Up @@ -384,7 +384,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume capabilities are provided", func() {
Expand All @@ -401,7 +401,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

// TODO: whether CreateVolume request with no capacity should fail or not depends on driver implementation
Expand Down Expand Up @@ -538,7 +538,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.AlreadyExists))
Expect(serverError.Code()).To(Equal(codes.AlreadyExists), "unexpected error: %s", serverError.Message())
})

It("should not fail when creating volume with maximum-length name", func() {
Expand Down Expand Up @@ -610,7 +610,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

It("should create volume from an existing source volume", func() {
Expand Down Expand Up @@ -656,7 +656,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})
})

Expand All @@ -679,7 +679,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should succeed when an invalid volume id is used", func() {
Expand Down Expand Up @@ -741,7 +741,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume capabilities are provided", func() {
Expand Down Expand Up @@ -776,7 +776,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should return appropriate values (no optional values added)", func() {
Expand Down Expand Up @@ -837,7 +837,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})
})

Expand All @@ -860,7 +860,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no node id is provided", func() {
Expand All @@ -876,7 +876,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume capability is provided", func() {
Expand All @@ -893,7 +893,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when publishing more volumes than the node max attach limit", func() {
Expand Down Expand Up @@ -955,7 +955,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

It("should fail when the node does not exist", func() {
Expand Down Expand Up @@ -994,7 +994,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

It("should fail when the volume is already published but is incompatible", func() {
Expand Down Expand Up @@ -1048,7 +1048,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.AlreadyExists))
Expect(serverError.Code()).To(Equal(codes.AlreadyExists), "unexpected error: %s", serverError.Message())
})
})

Expand Down Expand Up @@ -1087,7 +1087,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})
})
})
Expand Down Expand Up @@ -1337,7 +1337,7 @@ var _ = DescribeSanity("DeleteSnapshot [Controller Server]", func(sc *TestContex

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should succeed when an invalid snapshot id is used", func() {
Expand Down Expand Up @@ -1394,7 +1394,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *TestContex
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no source volume id is provided", func() {
Expand All @@ -1411,7 +1411,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *TestContex
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should succeed when requesting to create a snapshot with already existing name and same source volume ID", func() {
Expand Down Expand Up @@ -1444,7 +1444,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *TestContex
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.AlreadyExists))
Expect(serverError.Code()).To(Equal(codes.AlreadyExists), "unexpected error: %s", serverError.Message())
})

It("should succeed when creating snapshot with maximum-length name", func() {
Expand Down Expand Up @@ -1500,7 +1500,7 @@ var _ = DescribeSanity("ExpandVolume [Controller Server]", func(sc *TestContext)

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail if no capacity range is given", func() {
Expand All @@ -1514,7 +1514,7 @@ var _ = DescribeSanity("ExpandVolume [Controller Server]", func(sc *TestContext)

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should work", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sanity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = DescribeSanity("Identity Service", func(sc *TestContext) {
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code() == codes.FailedPrecondition ||
serverError.Code() == codes.OK).To(BeTrue())
serverError.Code() == codes.OK).To(BeTrue(), "unexpected error: %s", serverError.Message())

if res.GetReady() != nil {
Expect(res.GetReady().GetValue() == true ||
Expand Down

0 comments on commit bb5ec31

Please sign in to comment.