Repository: grpc/grpc-go
File: internal/xds/xdsclient/xdsresource/unmarshal_eds_test.go (Go)

Code before:
			wantErr: true,
		},
		{
			name: "missing locality weight",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				endpoints1 := []endpointOpts{{addrWithPort: "addr1:314"}}
				locOption1 := &addLocalityOptions{Health: []v3corepb.HealthStatus{v3corepb.HealthStatus_HEALTHY}}
				clab0.addLocality("locality-1", 0, 1, endpoints1, locOption1)
				endpoints2 := []endpointOpts{{addrWithPort: "addr2:159"}}
				locOption2 := &addLocalityOptions{Health: []v3corepb.HealthStatus{v3corepb.HealthStatus_HEALTHY}}
				clab0.addLocality("locality-2", 0, 0, endpoints2, locOption2)
				return clab0.Build()
			}(),
			want: EndpointsUpdate{},
		},
		{
			name: "max sum of endpoint weights within a locality exceeded",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				endpoints := []endpointOpts{
					{addrWithPort: "addr1:314"},
					{addrWithPort: "addr2:159"},
				}
				locOption := &addLocalityOptions{
					Weight: []uint32{4294967295, 1},
				}
				clab0.addLocality("locality-1", 1, 0, endpoints, locOption)
				return clab0.Build()
			}(),
			want:    EndpointsUpdate{},
			wantErr: true,
		},
		{
			name: "max sum of weights at the same priority exceeded",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				clab0.addLocality("locality-1", 1, 0, []endpointOpts{{addrWithPort: "addr1:314"}}, nil)
				clab0.addLocality("locality-2", 4294967295, 1, []endpointOpts{{addrWithPort: "addr2:159"}}, nil)
				clab0.addLocality("locality-3", 1, 1, []endpointOpts{{addrWithPort: "addr2:88"}}, nil)
				return clab0.Build()
			}(),
			want:    EndpointsUpdate{},
			wantErr: true,
		},
		{
			name: "duplicate endpoint address",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				clab0.addLocality("locality-1", 1, 1, []endpointOpts{{addrWithPort: "addr:997"}}, nil)
				clab0.addLocality("locality-2", 1, 0, []endpointOpts{{addrWithPort: "addr:997"}}, nil)

Review comment (suggestion):
Can you please change it `math.MaxUnit32` instead of the actual value , I think it might be better for anyone to understand reading the test.

Code after:
			want:    EndpointsUpdate{},
			wantErr: true,
		},
		{
			name: "missing locality weight",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				endpoints1 := []endpointOpts{{addrWithPort: "addr1:314"}}
				locOption1 := &addLocalityOptions{Health: []v3corepb.HealthStatus{v3corepb.HealthStatus_HEALTHY}}
				clab0.addLocality("locality-1", 0, 1, endpoints1, locOption1)
				endpoints2 := []endpointOpts{{addrWithPort: "addr2:159"}}
				locOption2 := &addLocalityOptions{Health: []v3corepb.HealthStatus{v3corepb.HealthStatus_HEALTHY}}
				clab0.addLocality("locality-2", 0, 0, endpoints2, locOption2)
				return clab0.Build()
			}(),
			want: EndpointsUpdate{},
		},
		{
			name: "max sum of endpoint weights within a locality exceeded",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				endpoints := []endpointOpts{
					{addrWithPort: "addr1:314"},
					{addrWithPort: "addr2:159"},
				}
				locOption := &addLocalityOptions{
					Weight: []uint32{math.MaxUint32, 1},
				}
				clab0.addLocality("locality-1", 1, 0, endpoints, locOption)
				return clab0.Build()
			}(),
			want:    EndpointsUpdate{},
			wantErr: true,
		},
		{
			name: "max sum of weights at the same priority exceeded",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				clab0.addLocality("locality-1", 1, 0, []endpointOpts{{addrWithPort: "addr1:314"}}, nil)
				clab0.addLocality("locality-2", 4294967295, 1, []endpointOpts{{addrWithPort: "addr2:159"}}, nil)
				clab0.addLocality("locality-3", 1, 1, []endpointOpts{{addrWithPort: "addr2:88"}}, nil)
				return clab0.Build()
			}(),
			want:    EndpointsUpdate{},
			wantErr: true,
		},
		{
			name: "duplicate endpoint address",
			m: func() *v3endpointpb.ClusterLoadAssignment {
				clab0 := newClaBuilder("test", nil)
				clab0.addLocality("locality-1", 1, 1, []endpointOpts{{addrWithPort: "addr:997"}}, nil)