vendor: add the ttrpc protos

add the ttrpc protocol files

Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
This commit is contained in:
fupan.lfp 2020-05-08 19:20:58 +08:00
parent 663c7e7921
commit 010b7a9fba
9 changed files with 17534 additions and 7052 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,16 +18,16 @@ import (
"strings" "strings"
"time" "time"
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
"github.com/hashicorp/yamux" "github.com/hashicorp/yamux"
"github.com/mdlayher/vsock" "github.com/mdlayher/vsock"
opentracing "github.com/opentracing/opentracing-go" // opentracing "github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"google.golang.org/grpc" // "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
grpcStatus "google.golang.org/grpc/status" grpcStatus "google.golang.org/grpc/status"
agentgrpc "github.com/kata-containers/agent/protocols/grpc" agentgrpc "github.com/kata-containers/agent/protocols/grpc"
"github.com/containerd/ttrpc"
) )
const ( const (
@ -51,9 +51,9 @@ var agentClientLog = logrus.WithFields(agentClientFields)
// AgentClient is an agent gRPC client connection wrapper for agentgrpc.AgentServiceClient // AgentClient is an agent gRPC client connection wrapper for agentgrpc.AgentServiceClient
type AgentClient struct { type AgentClient struct {
agentgrpc.AgentServiceClient AgentServiceClient agentgrpc.AgentServiceService
agentgrpc.HealthClient HealthClient agentgrpc.HealthService
conn *grpc.ClientConn conn *ttrpc.Client
} }
type yamuxSessionStream struct { type yamuxSessionStream struct {
@ -100,6 +100,15 @@ func NewAgentClient(ctx context.Context, sock string, enableYamux bool) (*AgentC
if err != nil { if err != nil {
return nil, err return nil, err
} }
var conn net.Conn
var d dialer
d = agentDialer(parsedAddr, enableYamux)
conn, err = d(grpcAddr, defaultDialTimeout)
if err != nil {
return nil, err
}
/*
dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()} dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()}
dialOpts = append(dialOpts, grpc.WithDialer(agentDialer(parsedAddr, enableYamux))) dialOpts = append(dialOpts, grpc.WithDialer(agentDialer(parsedAddr, enableYamux)))
@ -123,11 +132,13 @@ func NewAgentClient(ctx context.Context, sock string, enableYamux bool) (*AgentC
if err != nil { if err != nil {
return nil, err return nil, err
} }
*/
client := ttrpc.NewClient(conn)
return &AgentClient{ return &AgentClient{
AgentServiceClient: agentgrpc.NewAgentServiceClient(conn), AgentServiceClient: agentgrpc.NewAgentServiceClient(client),
HealthClient: agentgrpc.NewHealthClient(conn), HealthClient: agentgrpc.NewHealthClient(client),
conn: conn, conn: client,
}, nil }, nil
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ syntax = "proto3";
package grpc; package grpc;
import "oci.proto"; import "github.com/kata-containers/agent/protocols/grpc/oci.proto";
import "github.com/kata-containers/agent/pkg/types/types.proto"; import "github.com/kata-containers/agent/pkg/types/types.proto";
import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto";

View File

@ -1,23 +1,33 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: health.proto // source: github.com/kata-containers/agent/protocols/grpc/health.proto
package grpc package grpc
import proto "github.com/gogo/protobuf/proto" import (
import fmt "fmt" bytes "bytes"
import math "math" context "context"
import _ "github.com/gogo/protobuf/gogoproto" fmt "fmt"
github_com_containerd_ttrpc "github.com/containerd/ttrpc"
import context "golang.org/x/net/context" _ "github.com/gogo/protobuf/gogoproto"
import grpc1 "google.golang.org/grpc" proto "github.com/gogo/protobuf/proto"
io "io"
import io "io" math "math"
math_bits "math/bits"
reflect "reflect"
strings "strings"
)
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type HealthCheckResponse_ServingStatus int32 type HealthCheckResponse_ServingStatus int32
const ( const (
@ -31,6 +41,7 @@ var HealthCheckResponse_ServingStatus_name = map[int32]string{
1: "SERVING", 1: "SERVING",
2: "NOT_SERVING", 2: "NOT_SERVING",
} }
var HealthCheckResponse_ServingStatus_value = map[string]int32{ var HealthCheckResponse_ServingStatus_value = map[string]int32{
"UNKNOWN": 0, "UNKNOWN": 0,
"SERVING": 1, "SERVING": 1,
@ -40,72 +51,167 @@ var HealthCheckResponse_ServingStatus_value = map[string]int32{
func (x HealthCheckResponse_ServingStatus) String() string { func (x HealthCheckResponse_ServingStatus) String() string {
return proto.EnumName(HealthCheckResponse_ServingStatus_name, int32(x)) return proto.EnumName(HealthCheckResponse_ServingStatus_name, int32(x))
} }
func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) {
return fileDescriptorHealth, []int{1, 0} return fileDescriptor_24b9fe6b2d9b7b0c, []int{1, 0}
} }
type CheckRequest struct { type CheckRequest struct {
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *CheckRequest) Reset() { *m = CheckRequest{} } func (m *CheckRequest) Reset() { *m = CheckRequest{} }
func (m *CheckRequest) String() string { return proto.CompactTextString(m) } func (*CheckRequest) ProtoMessage() {}
func (*CheckRequest) ProtoMessage() {} func (*CheckRequest) Descriptor() ([]byte, []int) {
func (*CheckRequest) Descriptor() ([]byte, []int) { return fileDescriptorHealth, []int{0} } return fileDescriptor_24b9fe6b2d9b7b0c, []int{0}
}
func (m *CheckRequest) GetService() string { func (m *CheckRequest) XXX_Unmarshal(b []byte) error {
if m != nil { return m.Unmarshal(b)
return m.Service }
func (m *CheckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CheckRequest.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
} }
return ""
} }
func (m *CheckRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CheckRequest.Merge(m, src)
}
func (m *CheckRequest) XXX_Size() int {
return m.Size()
}
func (m *CheckRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CheckRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CheckRequest proto.InternalMessageInfo
type HealthCheckResponse struct { type HealthCheckResponse struct {
Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=grpc.HealthCheckResponse_ServingStatus" json:"status,omitempty"` Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=grpc.HealthCheckResponse_ServingStatus" json:"status,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} }
func (m *HealthCheckResponse) String() string { return proto.CompactTextString(m) } func (*HealthCheckResponse) ProtoMessage() {}
func (*HealthCheckResponse) ProtoMessage() {} func (*HealthCheckResponse) Descriptor() ([]byte, []int) {
func (*HealthCheckResponse) Descriptor() ([]byte, []int) { return fileDescriptorHealth, []int{1} } return fileDescriptor_24b9fe6b2d9b7b0c, []int{1}
}
func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { func (m *HealthCheckResponse) XXX_Unmarshal(b []byte) error {
if m != nil { return m.Unmarshal(b)
return m.Status }
func (m *HealthCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_HealthCheckResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
} }
return HealthCheckResponse_UNKNOWN
} }
func (m *HealthCheckResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_HealthCheckResponse.Merge(m, src)
}
func (m *HealthCheckResponse) XXX_Size() int {
return m.Size()
}
func (m *HealthCheckResponse) XXX_DiscardUnknown() {
xxx_messageInfo_HealthCheckResponse.DiscardUnknown(m)
}
var xxx_messageInfo_HealthCheckResponse proto.InternalMessageInfo
type VersionCheckResponse struct { type VersionCheckResponse struct {
GrpcVersion string `protobuf:"bytes,1,opt,name=grpc_version,json=grpcVersion,proto3" json:"grpc_version,omitempty"` GrpcVersion string `protobuf:"bytes,1,opt,name=grpc_version,json=grpcVersion,proto3" json:"grpc_version,omitempty"`
AgentVersion string `protobuf:"bytes,2,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"` AgentVersion string `protobuf:"bytes,2,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *VersionCheckResponse) Reset() { *m = VersionCheckResponse{} } func (m *VersionCheckResponse) Reset() { *m = VersionCheckResponse{} }
func (m *VersionCheckResponse) String() string { return proto.CompactTextString(m) } func (*VersionCheckResponse) ProtoMessage() {}
func (*VersionCheckResponse) ProtoMessage() {} func (*VersionCheckResponse) Descriptor() ([]byte, []int) {
func (*VersionCheckResponse) Descriptor() ([]byte, []int) { return fileDescriptorHealth, []int{2} } return fileDescriptor_24b9fe6b2d9b7b0c, []int{2}
}
func (m *VersionCheckResponse) GetGrpcVersion() string { func (m *VersionCheckResponse) XXX_Unmarshal(b []byte) error {
if m != nil { return m.Unmarshal(b)
return m.GrpcVersion }
func (m *VersionCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_VersionCheckResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
} }
return "" }
func (m *VersionCheckResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_VersionCheckResponse.Merge(m, src)
}
func (m *VersionCheckResponse) XXX_Size() int {
return m.Size()
}
func (m *VersionCheckResponse) XXX_DiscardUnknown() {
xxx_messageInfo_VersionCheckResponse.DiscardUnknown(m)
} }
func (m *VersionCheckResponse) GetAgentVersion() string { var xxx_messageInfo_VersionCheckResponse proto.InternalMessageInfo
if m != nil {
return m.AgentVersion
}
return ""
}
func init() { func init() {
proto.RegisterEnum("grpc.HealthCheckResponse_ServingStatus", HealthCheckResponse_ServingStatus_name, HealthCheckResponse_ServingStatus_value)
proto.RegisterType((*CheckRequest)(nil), "grpc.CheckRequest") proto.RegisterType((*CheckRequest)(nil), "grpc.CheckRequest")
proto.RegisterType((*HealthCheckResponse)(nil), "grpc.HealthCheckResponse") proto.RegisterType((*HealthCheckResponse)(nil), "grpc.HealthCheckResponse")
proto.RegisterType((*VersionCheckResponse)(nil), "grpc.VersionCheckResponse") proto.RegisterType((*VersionCheckResponse)(nil), "grpc.VersionCheckResponse")
proto.RegisterEnum("grpc.HealthCheckResponse_ServingStatus", HealthCheckResponse_ServingStatus_name, HealthCheckResponse_ServingStatus_value)
} }
func init() {
proto.RegisterFile("github.com/kata-containers/agent/protocols/grpc/health.proto", fileDescriptor_24b9fe6b2d9b7b0c)
}
var fileDescriptor_24b9fe6b2d9b7b0c = []byte{
// 365 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0x41, 0x4b, 0xf3, 0x40,
0x10, 0xed, 0x96, 0xef, 0x6b, 0x71, 0xda, 0x6a, 0x59, 0x3d, 0xd4, 0x1e, 0x16, 0x8d, 0x07, 0x7b,
0x69, 0x02, 0x15, 0x04, 0x45, 0x10, 0x14, 0x51, 0x11, 0x52, 0x48, 0xb5, 0xde, 0x2c, 0x69, 0x58,
0x93, 0xd0, 0x9a, 0xad, 0xd9, 0x4d, 0x2f, 0x5e, 0xfc, 0x0d, 0xfe, 0x0a, 0x7f, 0x82, 0x47, 0x8f,
0x3d, 0x7a, 0xf4, 0x68, 0xf7, 0x57, 0x78, 0x94, 0xec, 0xa6, 0xd2, 0x42, 0xbd, 0xed, 0x7b, 0xf3,
0xde, 0xcc, 0xbc, 0x59, 0x38, 0xf2, 0x43, 0x11, 0x24, 0x7d, 0xd3, 0x63, 0x0f, 0xd6, 0xc0, 0x15,
0x6e, 0xd3, 0x63, 0x91, 0x70, 0xc3, 0x88, 0xc6, 0xdc, 0x72, 0x7d, 0x1a, 0x09, 0x6b, 0x14, 0x33,
0xc1, 0x3c, 0x36, 0xe4, 0x96, 0x1f, 0x8f, 0x3c, 0x2b, 0xa0, 0xee, 0x50, 0x04, 0xa6, 0x62, 0xf1,
0xbf, 0x94, 0xaa, 0x37, 0xe7, 0x7a, 0xf8, 0xcc, 0x67, 0xda, 0xd2, 0x4f, 0xee, 0x15, 0x52, 0x40,
0xbd, 0xb4, 0xc9, 0x68, 0x40, 0xf9, 0x34, 0xa0, 0xde, 0xc0, 0xa1, 0x8f, 0x09, 0xe5, 0x02, 0xd7,
0xa0, 0xc8, 0x69, 0x3c, 0x0e, 0x3d, 0x5a, 0x43, 0x5b, 0xa8, 0xb1, 0xe2, 0xcc, 0xa0, 0xf1, 0x82,
0x60, 0xfd, 0x42, 0xcd, 0xcb, 0x0c, 0x7c, 0xc4, 0x22, 0x4e, 0xf1, 0x31, 0x14, 0xb8, 0x70, 0x45,
0xc2, 0x95, 0x61, 0xb5, 0xb5, 0x6b, 0xa6, 0x7b, 0x98, 0x4b, 0xa4, 0x66, 0x27, 0x6d, 0x15, 0xf9,
0x1d, 0x25, 0x77, 0x32, 0x9b, 0x71, 0x08, 0x95, 0x85, 0x02, 0x2e, 0x41, 0xf1, 0xc6, 0xbe, 0xb2,
0xdb, 0xb7, 0x76, 0x35, 0x97, 0x82, 0xce, 0x99, 0xd3, 0xbd, 0xb4, 0xcf, 0xab, 0x08, 0xaf, 0x41,
0xc9, 0x6e, 0x5f, 0xf7, 0x66, 0x44, 0xde, 0xb8, 0x83, 0x8d, 0x2e, 0x8d, 0x79, 0xc8, 0xa2, 0xc5,
0xa5, 0xb6, 0xa1, 0x9c, 0x6e, 0xd1, 0x1b, 0xeb, 0x62, 0x96, 0xa5, 0x94, 0x72, 0x99, 0x1e, 0xef,
0x40, 0x45, 0xdd, 0xf4, 0x57, 0x93, 0x57, 0x9a, 0xb2, 0x22, 0x33, 0x51, 0xeb, 0x09, 0x0a, 0x3a,
0x08, 0xde, 0x87, 0xff, 0x6a, 0x04, 0xc6, 0x3a, 0xdf, 0xfc, 0xd5, 0xea, 0x9b, 0x7f, 0x66, 0xc6,
0x07, 0x50, 0x9c, 0x4d, 0x5c, 0xe6, 0xac, 0x6b, 0x6e, 0x59, 0x88, 0x93, 0xc6, 0x64, 0x4a, 0x72,
0x9f, 0x53, 0x92, 0xfb, 0x9e, 0x12, 0xf4, 0x2c, 0x09, 0x7a, 0x95, 0x04, 0xbd, 0x49, 0x82, 0xde,
0x25, 0x41, 0x13, 0x49, 0xd0, 0x87, 0x24, 0xe8, 0x4b, 0x12, 0xd4, 0x2f, 0xa8, 0xcf, 0xdc, 0xfb,
0x09, 0x00, 0x00, 0xff, 0xff, 0x16, 0xa5, 0xaa, 0xfb, 0x41, 0x02, 0x00, 0x00,
}
func (this *CheckRequest) Equal(that interface{}) bool { func (this *CheckRequest) Equal(that interface{}) bool {
if that == nil { if that == nil {
return this == nil return this == nil
@ -128,6 +234,9 @@ func (this *CheckRequest) Equal(that interface{}) bool {
if this.Service != that1.Service { if this.Service != that1.Service {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *HealthCheckResponse) Equal(that interface{}) bool { func (this *HealthCheckResponse) Equal(that interface{}) bool {
@ -152,6 +261,9 @@ func (this *HealthCheckResponse) Equal(that interface{}) bool {
if this.Status != that1.Status { if this.Status != that1.Status {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
func (this *VersionCheckResponse) Equal(that interface{}) bool { func (this *VersionCheckResponse) Equal(that interface{}) bool {
@ -179,118 +291,15 @@ func (this *VersionCheckResponse) Equal(that interface{}) bool {
if this.AgentVersion != that1.AgentVersion { if this.AgentVersion != that1.AgentVersion {
return false return false
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true return true
} }
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc1.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc1.SupportPackageIsVersion4
// Client API for Health service
type HealthClient interface {
Check(ctx context.Context, in *CheckRequest, opts ...grpc1.CallOption) (*HealthCheckResponse, error)
Version(ctx context.Context, in *CheckRequest, opts ...grpc1.CallOption) (*VersionCheckResponse, error)
}
type healthClient struct {
cc *grpc1.ClientConn
}
func NewHealthClient(cc *grpc1.ClientConn) HealthClient {
return &healthClient{cc}
}
func (c *healthClient) Check(ctx context.Context, in *CheckRequest, opts ...grpc1.CallOption) (*HealthCheckResponse, error) {
out := new(HealthCheckResponse)
err := grpc1.Invoke(ctx, "/grpc.Health/Check", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *healthClient) Version(ctx context.Context, in *CheckRequest, opts ...grpc1.CallOption) (*VersionCheckResponse, error) {
out := new(VersionCheckResponse)
err := grpc1.Invoke(ctx, "/grpc.Health/Version", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Health service
type HealthServer interface {
Check(context.Context, *CheckRequest) (*HealthCheckResponse, error)
Version(context.Context, *CheckRequest) (*VersionCheckResponse, error)
}
func RegisterHealthServer(s *grpc1.Server, srv HealthServer) {
s.RegisterService(&_Health_serviceDesc, srv)
}
func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) {
in := new(CheckRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HealthServer).Check(ctx, in)
}
info := &grpc1.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Health/Check",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HealthServer).Check(ctx, req.(*CheckRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Health_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) {
in := new(CheckRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HealthServer).Version(ctx, in)
}
info := &grpc1.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Health/Version",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HealthServer).Version(ctx, req.(*CheckRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Health_serviceDesc = grpc1.ServiceDesc{
ServiceName: "grpc.Health",
HandlerType: (*HealthServer)(nil),
Methods: []grpc1.MethodDesc{
{
MethodName: "Check",
Handler: _Health_Check_Handler,
},
{
MethodName: "Version",
Handler: _Health_Version_Handler,
},
},
Streams: []grpc1.StreamDesc{},
Metadata: "health.proto",
}
func (m *CheckRequest) Marshal() (dAtA []byte, err error) { func (m *CheckRequest) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA) n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -298,23 +307,33 @@ func (m *CheckRequest) Marshal() (dAtA []byte, err error) {
} }
func (m *CheckRequest) MarshalTo(dAtA []byte) (int, error) { func (m *CheckRequest) MarshalTo(dAtA []byte) (int, error) {
var i int size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *CheckRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.Service) > 0 { if m.XXX_unrecognized != nil {
dAtA[i] = 0xa i -= len(m.XXX_unrecognized)
i++ copy(dAtA[i:], m.XXX_unrecognized)
i = encodeVarintHealth(dAtA, i, uint64(len(m.Service)))
i += copy(dAtA[i:], m.Service)
} }
return i, nil if len(m.Service) > 0 {
i -= len(m.Service)
copy(dAtA[i:], m.Service)
i = encodeVarintHealth(dAtA, i, uint64(len(m.Service)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
} }
func (m *HealthCheckResponse) Marshal() (dAtA []byte, err error) { func (m *HealthCheckResponse) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA) n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -322,22 +341,31 @@ func (m *HealthCheckResponse) Marshal() (dAtA []byte, err error) {
} }
func (m *HealthCheckResponse) MarshalTo(dAtA []byte) (int, error) { func (m *HealthCheckResponse) MarshalTo(dAtA []byte) (int, error) {
var i int size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *HealthCheckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i _ = i
var l int var l int
_ = l _ = l
if m.Status != 0 { if m.XXX_unrecognized != nil {
dAtA[i] = 0x8 i -= len(m.XXX_unrecognized)
i++ copy(dAtA[i:], m.XXX_unrecognized)
i = encodeVarintHealth(dAtA, i, uint64(m.Status))
} }
return i, nil if m.Status != 0 {
i = encodeVarintHealth(dAtA, i, uint64(m.Status))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
} }
func (m *VersionCheckResponse) Marshal() (dAtA []byte, err error) { func (m *VersionCheckResponse) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA) n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -345,38 +373,52 @@ func (m *VersionCheckResponse) Marshal() (dAtA []byte, err error) {
} }
func (m *VersionCheckResponse) MarshalTo(dAtA []byte) (int, error) { func (m *VersionCheckResponse) MarshalTo(dAtA []byte) (int, error) {
var i int size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *VersionCheckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.GrpcVersion) > 0 { if m.XXX_unrecognized != nil {
dAtA[i] = 0xa i -= len(m.XXX_unrecognized)
i++ copy(dAtA[i:], m.XXX_unrecognized)
i = encodeVarintHealth(dAtA, i, uint64(len(m.GrpcVersion)))
i += copy(dAtA[i:], m.GrpcVersion)
} }
if len(m.AgentVersion) > 0 { if len(m.AgentVersion) > 0 {
dAtA[i] = 0x12 i -= len(m.AgentVersion)
i++ copy(dAtA[i:], m.AgentVersion)
i = encodeVarintHealth(dAtA, i, uint64(len(m.AgentVersion))) i = encodeVarintHealth(dAtA, i, uint64(len(m.AgentVersion)))
i += copy(dAtA[i:], m.AgentVersion) i--
dAtA[i] = 0x12
} }
return i, nil if len(m.GrpcVersion) > 0 {
i -= len(m.GrpcVersion)
copy(dAtA[i:], m.GrpcVersion)
i = encodeVarintHealth(dAtA, i, uint64(len(m.GrpcVersion)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
} }
func encodeVarintHealth(dAtA []byte, offset int, v uint64) int { func encodeVarintHealth(dAtA []byte, offset int, v uint64) int {
offset -= sovHealth(v)
base := offset
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7 v >>= 7
offset++ offset++
} }
dAtA[offset] = uint8(v) dAtA[offset] = uint8(v)
return offset + 1 return base
} }
func NewPopulatedCheckRequest(r randyHealth, easy bool) *CheckRequest { func NewPopulatedCheckRequest(r randyHealth, easy bool) *CheckRequest {
this := &CheckRequest{} this := &CheckRequest{}
this.Service = string(randStringHealth(r)) this.Service = string(randStringHealth(r))
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedHealth(r, 2)
} }
return this return this
} }
@ -385,6 +427,7 @@ func NewPopulatedHealthCheckResponse(r randyHealth, easy bool) *HealthCheckRespo
this := &HealthCheckResponse{} this := &HealthCheckResponse{}
this.Status = HealthCheckResponse_ServingStatus([]int32{0, 1, 2}[r.Intn(3)]) this.Status = HealthCheckResponse_ServingStatus([]int32{0, 1, 2}[r.Intn(3)])
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedHealth(r, 2)
} }
return this return this
} }
@ -394,6 +437,7 @@ func NewPopulatedVersionCheckResponse(r randyHealth, easy bool) *VersionCheckRes
this.GrpcVersion = string(randStringHealth(r)) this.GrpcVersion = string(randStringHealth(r))
this.AgentVersion = string(randStringHealth(r)) this.AgentVersion = string(randStringHealth(r))
if !easy && r.Intn(10) != 0 { if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedHealth(r, 3)
} }
return this return this
} }
@ -471,25 +515,40 @@ func encodeVarintPopulateHealth(dAtA []byte, v uint64) []byte {
return dAtA return dAtA
} }
func (m *CheckRequest) Size() (n int) { func (m *CheckRequest) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.Service) l = len(m.Service)
if l > 0 { if l > 0 {
n += 1 + l + sovHealth(uint64(l)) n += 1 + l + sovHealth(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *HealthCheckResponse) Size() (n int) { func (m *HealthCheckResponse) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
if m.Status != 0 { if m.Status != 0 {
n += 1 + sovHealth(uint64(m.Status)) n += 1 + sovHealth(uint64(m.Status))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func (m *VersionCheckResponse) Size() (n int) { func (m *VersionCheckResponse) Size() (n int) {
if m == nil {
return 0
}
var l int var l int
_ = l _ = l
l = len(m.GrpcVersion) l = len(m.GrpcVersion)
@ -500,22 +559,110 @@ func (m *VersionCheckResponse) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovHealth(uint64(l)) n += 1 + l + sovHealth(uint64(l))
} }
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n return n
} }
func sovHealth(x uint64) (n int) { func sovHealth(x uint64) (n int) {
for { return (math_bits.Len64(x|1) + 6) / 7
n++
x >>= 7
if x == 0 {
break
}
}
return n
} }
func sozHealth(x uint64) (n int) { func sozHealth(x uint64) (n int) {
return sovHealth(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return sovHealth(uint64((x << 1) ^ uint64((int64(x) >> 63))))
} }
func (this *CheckRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&CheckRequest{`,
`Service:` + fmt.Sprintf("%v", this.Service) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *HealthCheckResponse) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&HealthCheckResponse{`,
`Status:` + fmt.Sprintf("%v", this.Status) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *VersionCheckResponse) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&VersionCheckResponse{`,
`GrpcVersion:` + fmt.Sprintf("%v", this.GrpcVersion) + `,`,
`AgentVersion:` + fmt.Sprintf("%v", this.AgentVersion) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringHealth(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
type HealthService interface {
Check(ctx context.Context, req *CheckRequest) (*HealthCheckResponse, error)
Version(ctx context.Context, req *CheckRequest) (*VersionCheckResponse, error)
}
func RegisterHealthService(srv *github_com_containerd_ttrpc.Server, svc HealthService) {
srv.Register("grpc.Health", map[string]github_com_containerd_ttrpc.Method{
"Check": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req CheckRequest
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Check(ctx, &req)
},
"Version": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req CheckRequest
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Version(ctx, &req)
},
})
}
type healthClient struct {
client *github_com_containerd_ttrpc.Client
}
func NewHealthClient(client *github_com_containerd_ttrpc.Client) HealthService {
return &healthClient{
client: client,
}
}
func (c *healthClient) Check(ctx context.Context, req *CheckRequest) (*HealthCheckResponse, error) {
var resp HealthCheckResponse
if err := c.client.Call(ctx, "grpc.Health", "Check", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (c *healthClient) Version(ctx context.Context, req *CheckRequest) (*VersionCheckResponse, error) {
var resp VersionCheckResponse
if err := c.client.Call(ctx, "grpc.Health", "Version", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (m *CheckRequest) Unmarshal(dAtA []byte) error { func (m *CheckRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0
@ -531,7 +678,7 @@ func (m *CheckRequest) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= (uint64(b) & 0x7F) << shift wire |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -559,7 +706,7 @@ func (m *CheckRequest) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift stringLen |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -569,6 +716,9 @@ func (m *CheckRequest) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthHealth
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@ -583,9 +733,13 @@ func (m *CheckRequest) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthHealth
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@ -610,7 +764,7 @@ func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= (uint64(b) & 0x7F) << shift wire |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -638,7 +792,7 @@ func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
m.Status |= (HealthCheckResponse_ServingStatus(b) & 0x7F) << shift m.Status |= HealthCheckResponse_ServingStatus(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -652,9 +806,13 @@ func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthHealth
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@ -679,7 +837,7 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
wire |= (uint64(b) & 0x7F) << shift wire |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -707,7 +865,7 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift stringLen |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -717,6 +875,9 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthHealth
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@ -736,7 +897,7 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift stringLen |= uint64(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
@ -746,6 +907,9 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthHealth
}
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
@ -760,9 +924,13 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
if skippy < 0 { if skippy < 0 {
return ErrInvalidLengthHealth return ErrInvalidLengthHealth
} }
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthHealth
}
if (iNdEx + skippy) > l { if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy iNdEx += skippy
} }
} }
@ -775,6 +943,7 @@ func (m *VersionCheckResponse) Unmarshal(dAtA []byte) error {
func skipHealth(dAtA []byte) (n int, err error) { func skipHealth(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0
depth := 0
for iNdEx < l { for iNdEx < l {
var wire uint64 var wire uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -806,10 +975,8 @@ func skipHealth(dAtA []byte) (n int, err error) {
break break
} }
} }
return iNdEx, nil
case 1: case 1:
iNdEx += 8 iNdEx += 8
return iNdEx, nil
case 2: case 2:
var length int var length int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -826,80 +993,34 @@ func skipHealth(dAtA []byte) (n int, err error) {
break break
} }
} }
iNdEx += length
if length < 0 { if length < 0 {
return 0, ErrInvalidLengthHealth return 0, ErrInvalidLengthHealth
} }
return iNdEx, nil iNdEx += length
case 3: case 3:
for { depth++
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowHealth
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipHealth(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4: case 4:
return iNdEx, nil if depth == 0 {
return 0, ErrUnexpectedEndOfGroupHealth
}
depth--
case 5: case 5:
iNdEx += 4 iNdEx += 4
return iNdEx, nil
default: default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType) return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
} }
if iNdEx < 0 {
return 0, ErrInvalidLengthHealth
}
if depth == 0 {
return iNdEx, nil
}
} }
panic("unreachable") return 0, io.ErrUnexpectedEOF
} }
var ( var (
ErrInvalidLengthHealth = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthHealth = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowHealth = fmt.Errorf("proto: integer overflow") ErrIntOverflowHealth = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupHealth = fmt.Errorf("proto: unexpected end of group")
) )
func init() { proto.RegisterFile("health.proto", fileDescriptorHealth) }
var fileDescriptorHealth = []byte{
// 323 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xc9, 0x48, 0x4d, 0xcc,
0x29, 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x49, 0x2f, 0x2a, 0x48, 0x96, 0xd2,
0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7,
0x07, 0x4b, 0x26, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, 0x05, 0xd1, 0xa4, 0xa4, 0xc1, 0xc5,
0xe3, 0x9c, 0x91, 0x9a, 0x9c, 0x1d, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x24, 0xc1, 0xc5,
0x5e, 0x9c, 0x5a, 0x54, 0x96, 0x99, 0x9c, 0x2a, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe3,
0x2a, 0x4d, 0x62, 0xe4, 0x12, 0xf6, 0x00, 0xdb, 0x07, 0xd5, 0x50, 0x5c, 0x90, 0x9f, 0x57, 0x9c,
0x2a, 0x64, 0xcf, 0xc5, 0x56, 0x5c, 0x92, 0x58, 0x52, 0x5a, 0x0c, 0xd6, 0xc0, 0x67, 0xa4, 0xae,
0x07, 0x72, 0x87, 0x1e, 0x16, 0xa5, 0x7a, 0xc1, 0x20, 0xa3, 0xf2, 0xd2, 0x83, 0xc1, 0xca, 0x83,
0xa0, 0xda, 0x94, 0xac, 0xb8, 0x78, 0x51, 0x24, 0x84, 0xb8, 0xb9, 0xd8, 0x43, 0xfd, 0xbc, 0xfd,
0xfc, 0xc3, 0xfd, 0x04, 0x18, 0x40, 0x9c, 0x60, 0xd7, 0xa0, 0x30, 0x4f, 0x3f, 0x77, 0x01, 0x46,
0x21, 0x7e, 0x2e, 0x6e, 0x3f, 0xff, 0x90, 0x78, 0x98, 0x00, 0x93, 0x52, 0x1c, 0x97, 0x48, 0x58,
0x6a, 0x51, 0x71, 0x66, 0x7e, 0x1e, 0xaa, 0xa3, 0x14, 0xb9, 0x78, 0x40, 0xae, 0x88, 0x2f, 0x83,
0x48, 0x42, 0xfd, 0xc2, 0x0d, 0x12, 0x83, 0xaa, 0x17, 0x52, 0xe6, 0xe2, 0x4d, 0x4c, 0x4f, 0xcd,
0x2b, 0x81, 0xab, 0x61, 0x02, 0xab, 0xe1, 0x01, 0x0b, 0x42, 0x15, 0x19, 0x55, 0x73, 0xb1, 0x41,
0x3c, 0x22, 0x64, 0xc6, 0xc5, 0x0a, 0xb6, 0x42, 0x48, 0x08, 0xe2, 0x3f, 0xe4, 0x50, 0x93, 0x92,
0xc4, 0xe9, 0x67, 0x21, 0x4b, 0x2e, 0x76, 0x98, 0x8d, 0xd8, 0x74, 0x4a, 0x41, 0xc4, 0xb0, 0x79,
0xc2, 0x49, 0xe6, 0xc7, 0x43, 0x39, 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x77, 0x3c, 0x92, 0x63, 0x3c,
0xf0, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63,
0x4c, 0x62, 0x03, 0x47, 0xa0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb7, 0xf6, 0x84, 0x13, 0x05,
0x02, 0x00, 0x00,
}

View File

@ -0,0 +1,585 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/kata-containers/agent/protocols/grpc/health.proto
package grpc
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
proto "github.com/gogo/protobuf/proto"
math "math"
math_rand "math/rand"
testing "testing"
time "time"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func TestCheckRequestProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, false)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CheckRequest{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
littlefuzz := make([]byte, len(dAtA))
copy(littlefuzz, dAtA)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
if len(littlefuzz) > 0 {
fuzzamount := 100
for i := 0; i < fuzzamount; i++ {
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
}
// shouldn't panic
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCheckRequestMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CheckRequest{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func BenchmarkCheckRequestProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*CheckRequest, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCheckRequest(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkCheckRequestProtoUnmarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedCheckRequest(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &CheckRequest{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestHealthCheckResponseProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, false)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &HealthCheckResponse{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
littlefuzz := make([]byte, len(dAtA))
copy(littlefuzz, dAtA)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
if len(littlefuzz) > 0 {
fuzzamount := 100
for i := 0; i < fuzzamount; i++ {
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
}
// shouldn't panic
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestHealthCheckResponseMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &HealthCheckResponse{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func BenchmarkHealthCheckResponseProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*HealthCheckResponse, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedHealthCheckResponse(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkHealthCheckResponseProtoUnmarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedHealthCheckResponse(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &HealthCheckResponse{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestVersionCheckResponseProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, false)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &VersionCheckResponse{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
littlefuzz := make([]byte, len(dAtA))
copy(littlefuzz, dAtA)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
if len(littlefuzz) > 0 {
fuzzamount := 100
for i := 0; i < fuzzamount; i++ {
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
}
// shouldn't panic
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestVersionCheckResponseMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &VersionCheckResponse{}
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func BenchmarkVersionCheckResponseProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*VersionCheckResponse, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedVersionCheckResponse(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkVersionCheckResponseProtoUnmarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedVersionCheckResponse(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &VersionCheckResponse{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestCheckRequestJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CheckRequest{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
func TestHealthCheckResponseJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &HealthCheckResponse{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
func TestVersionCheckResponseJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &VersionCheckResponse{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
}
func TestCheckRequestProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, true)
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &CheckRequest{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestCheckRequestProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, true)
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &CheckRequest{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestHealthCheckResponseProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, true)
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &HealthCheckResponse{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestHealthCheckResponseProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, true)
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &HealthCheckResponse{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestVersionCheckResponseProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, true)
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &VersionCheckResponse{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestVersionCheckResponseProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, true)
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &VersionCheckResponse{}
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
}
}
func TestCheckRequestSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCheckRequest(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
size := p.Size()
if len(dAtA) != size {
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
}
if size2 != size {
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
}
size3 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCheckRequestSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*CheckRequest, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCheckRequest(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestHealthCheckResponseSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedHealthCheckResponse(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
size := p.Size()
if len(dAtA) != size {
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
}
if size2 != size {
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
}
size3 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkHealthCheckResponseSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*HealthCheckResponse, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedHealthCheckResponse(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestVersionCheckResponseSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedVersionCheckResponse(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
size := p.Size()
if len(dAtA) != size {
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
}
if size2 != size {
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
}
size3 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkVersionCheckResponseSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*VersionCheckResponse, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedVersionCheckResponse(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCheckRequestStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCheckRequest(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestHealthCheckResponseStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedHealthCheckResponse(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestVersionCheckResponseStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedVersionCheckResponse(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
//
// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package grpc
import (
"encoding/json"
"io/ioutil"
"reflect"
"testing"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
)
const ociConfigFile = "config.json"
func assertProcessIsEqual(t *testing.T, ociProcess *specs.Process, grpcProcess *Process) {
assert := assert.New(t)
// Process checks: User
assert.Equal(grpcProcess.User.UID, ociProcess.User.UID)
assert.Equal(grpcProcess.User.GID, ociProcess.User.GID)
// Process checks: Capabilities
assert.Equal(grpcProcess.Capabilities.Bounding, ociProcess.Capabilities.Bounding)
assert.Equal(grpcProcess.Capabilities.Effective, ociProcess.Capabilities.Effective)
assert.Equal(grpcProcess.Capabilities.Inheritable, ociProcess.Capabilities.Inheritable)
assert.Equal(grpcProcess.Capabilities.Permitted, ociProcess.Capabilities.Permitted)
assert.Equal(grpcProcess.Capabilities.Ambient, ociProcess.Capabilities.Ambient)
}
func assertIsEqual(t *testing.T, ociSpec *specs.Spec, grpcSpec *Spec) {
assert := assert.New(t)
// Version check
assert.Equal(grpcSpec.Version, ociSpec.Version)
// Process checks:
assertProcessIsEqual(t, ociSpec.Process, grpcSpec.Process)
// Annotations checks: Annotations
assert.Equal(len(grpcSpec.Annotations), len(ociSpec.Annotations))
for k := range grpcSpec.Annotations {
assert.Equal(grpcSpec.Annotations[k], ociSpec.Annotations[k])
}
// Linux checks: Devices
assert.Equal(len(grpcSpec.Linux.Resources.Devices), len(ociSpec.Linux.Resources.Devices))
assert.Equal(len(grpcSpec.Linux.Resources.Devices), 1)
assert.Equal(grpcSpec.Linux.Resources.Devices[0].Access, "rwm")
// Linux checks: Block IO, for checking embedded structures copy
assert.NotNil(ociSpec.Linux.Resources.BlockIO.LeafWeight)
assert.NotNil(ociSpec.Linux.Resources.BlockIO.Weight)
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.Weight, *ociSpec.Linux.Resources.BlockIO.Weight)
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.LeafWeight, *ociSpec.Linux.Resources.BlockIO.LeafWeight)
assert.NotEqual(len(grpcSpec.Linux.Resources.BlockIO.WeightDevice), 0)
assert.Equal(len(grpcSpec.Linux.Resources.BlockIO.WeightDevice), len(grpcSpec.Linux.Resources.BlockIO.WeightDevice))
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.WeightDevice[0].Major, ociSpec.Linux.Resources.BlockIO.WeightDevice[0].Major)
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.WeightDevice[0].Minor, ociSpec.Linux.Resources.BlockIO.WeightDevice[0].Minor)
assert.NotNil(ociSpec.Linux.Resources.BlockIO.WeightDevice[0].LeafWeight)
assert.NotNil(ociSpec.Linux.Resources.BlockIO.WeightDevice[0].Weight)
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.WeightDevice[0].Weight, *ociSpec.Linux.Resources.BlockIO.WeightDevice[0].Weight)
assert.EqualValues(grpcSpec.Linux.Resources.BlockIO.WeightDevice[0].LeafWeight, *ociSpec.Linux.Resources.BlockIO.WeightDevice[0].LeafWeight)
// Linux checks: Namespaces
assert.Equal(len(grpcSpec.Linux.Namespaces), len(ociSpec.Linux.Namespaces))
assert.Equal(len(grpcSpec.Linux.Namespaces), 5)
for i := range grpcSpec.Linux.Namespaces {
assert.Equal(grpcSpec.Linux.Namespaces[i].Type, (string)(ociSpec.Linux.Namespaces[i].Type)) //nolint:unconvert
assert.Equal(grpcSpec.Linux.Namespaces[i].Path, (string)(ociSpec.Linux.Namespaces[i].Path)) //nolint:unconvert
}
}
func TestOCItoGRPC(t *testing.T) {
assert := assert.New(t)
var ociSpec specs.Spec
configJSONBytes, err := ioutil.ReadFile(ociConfigFile)
assert.NoError(err, "Could not open OCI config file")
err = json.Unmarshal(configJSONBytes, &ociSpec)
assert.NoError(err, "Could not unmarshall OCI config file")
spec, err := OCItoGRPC(&ociSpec)
assert.NoError(err, "Could not convert OCI config file")
assertIsEqual(t, &ociSpec, spec)
}
func TestGRPCtoOCI(t *testing.T) {
assert := assert.New(t)
var ociSpec specs.Spec
configJSONBytes, err := ioutil.ReadFile(ociConfigFile)
assert.NoError(err, "Could not open OCI config file")
err = json.Unmarshal(configJSONBytes, &ociSpec)
assert.NoError(err, "Could not unmarshall OCI config file")
grpcSpec, err := OCItoGRPC(&ociSpec)
assert.NoError(err, "Could not convert OCI config file")
newOciSpec, err := GRPCtoOCI(grpcSpec)
assert.NoError(err, "Could not convert gRPC structure")
assertIsEqual(t, newOciSpec, grpcSpec)
}
func TestProcessOCItoGRPC(t *testing.T) {
assert := assert.New(t)
var ociSpec specs.Spec
configJSONBytes, err := ioutil.ReadFile(ociConfigFile)
assert.NoError(err, "Could not open OCI config file")
err = json.Unmarshal(configJSONBytes, &ociSpec)
assert.NoError(err, "Could not unmarshall OCI config file")
process, err := ProcessOCItoGRPC(ociSpec.Process)
assert.NoError(err, "Could not convert OCI config file")
assertProcessIsEqual(t, ociSpec.Process, process)
}
func TestProcessGRPCtoOCI(t *testing.T) {
assert := assert.New(t)
var ociSpec specs.Spec
configJSONBytes, err := ioutil.ReadFile(ociConfigFile)
assert.NoError(err, "Could not open OCI config file")
err = json.Unmarshal(configJSONBytes, &ociSpec)
assert.NoError(err, "Could not unmarshall OCI config file")
grpcProcess, err := ProcessOCItoGRPC(ociSpec.Process)
assert.NoError(err, "Could not convert OCI config file")
newOciProcess, err := ProcessGRPCtoOCI(grpcProcess)
assert.NoError(err, "Could not convert gRPC structure")
assertProcessIsEqual(t, newOciProcess, grpcProcess)
}
func testCopyValue(t *testing.T, to, from interface{}) {
assert := assert.New(t)
err := copyValue(reflect.ValueOf(to).Elem(), reflect.ValueOf(from))
assert.NoError(err, "Could not copy to %v", reflect.ValueOf(from).Kind())
assert.Equal(reflect.ValueOf(to).Elem().Interface(), reflect.ValueOf(from).Interface())
}
func TestCopyValueString(t *testing.T) {
from := "foobar"
to := new(string)
testCopyValue(t, to, from)
}
func TestCopyValueSlice(t *testing.T) {
from := []string{"foobar", "barfoo"}
to := new([]string)
testCopyValue(t, to, from)
}
func TestCopyValueStruc(t *testing.T) {
type dummyStruct struct {
S string
I int
}
from := dummyStruct{
S: "foobar",
I: 18,
}
to := new(dummyStruct)
testCopyValue(t, to, from)
}
func TestCopyValueMap(t *testing.T) {
from := map[string]string{
"key1": "value1",
"key2": "value2",
}
to := new(map[string]string)
testCopyValue(t, to, from)
}