Skip to content

Commit

Permalink
fix compilation errors in ring_http_test.go and partition_instance_ri…
Browse files Browse the repository at this point in the history
…ng_test.go; pass all mentioned tests with race check
  • Loading branch information
francoposa committed Jan 14, 2025
1 parent 7667afc commit 2c62aad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions ring/partition_instance_ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
}{
"should return error on empty partitions ring": {
partitionsRing: PartitionRingDesc{},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-1": {Id: "instance-1", State: InstanceState_ACTIVE, Timestamp: now.Unix()},
"instance-2": {Id: "instance-2", State: InstanceState_ACTIVE, Timestamp: now.Unix()},
}},
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
"instance-zone-b-2": {OwnedPartition: 2},
},
},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-zone-a-1": {Id: "instance-zone-a-1", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
"instance-zone-a-2": {Id: "instance-zone-a-2", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
"instance-zone-b-2": {Id: "instance-zone-b-2", State: InstanceState_ACTIVE, Zone: "b", Timestamp: now.Unix()},
Expand All @@ -82,7 +82,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
"instance-zone-b-2": {OwnedPartition: 2},
},
},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-zone-a-1": {Id: "instance-zone-a-1", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
"instance-zone-a-2": {Id: "instance-zone-a-2", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Add(-2 * time.Minute).Unix()}, // Unhealthy.
}},
Expand All @@ -101,7 +101,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
"instance-zone-b-2": {OwnedPartition: 2},
},
},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-zone-a-1": {Id: "instance-zone-a-1", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
"instance-zone-b-1": {Id: "instance-zone-a-1", State: InstanceState_LEAVING, Zone: "a", Timestamp: now.Unix()}, // Unhealthy because of the state.
"instance-zone-a-2": {Id: "instance-zone-a-2", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
Expand All @@ -125,7 +125,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
"instance-zone-b-2": {OwnedPartition: 2},
},
},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-zone-a-1": {Id: "instance-zone-a-1", State: InstanceState_ACTIVE, Zone: "a", Timestamp: now.Unix()},
"instance-zone-b-2": {Id: "instance-zone-b-2", State: InstanceState_ACTIVE, Zone: "b", Timestamp: now.Unix()},
}},
Expand All @@ -147,7 +147,7 @@ func TestPartitionInstanceRing_GetReplicationSetsForOperation(t *testing.T) {
"instance-zone-b-2": {OwnedPartition: 2},
},
},
instancesRing: &Desc{Ingesters: map[string]InstanceDesc{
instancesRing: &Desc{Ingesters: map[string]*InstanceDesc{
"instance-zone-a-1": {Id: "instance-zone-a-1", State: InstanceState_ACTIVE, Zone: "fixed", Timestamp: now.Unix()},
"instance-zone-b-1": {Id: "instance-zone-b-1", State: InstanceState_ACTIVE, Zone: "fixed", Timestamp: now.Unix()},
"instance-zone-a-2": {Id: "instance-zone-a-2", State: InstanceState_ACTIVE, Zone: "fixed", Timestamp: now.Unix()},
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestPartitionInstanceRing_ShuffleShard(t *testing.T) {
partitionsRing.AddOrUpdateOwner("instance-2", OwnerActive, 2, now.Add(-30*time.Minute))
partitionsRing.AddOrUpdateOwner("instance-3", OwnerActive, 3, now.Add(-30*time.Minute))

instancesRing := &Desc{Ingesters: map[string]InstanceDesc{
instancesRing := &Desc{Ingesters: map[string]*InstanceDesc{
"instance-1": {Id: "instance-1", State: InstanceState_ACTIVE, Timestamp: time.Now().Unix()},
"instance-2": {Id: "instance-2", State: InstanceState_ACTIVE, Timestamp: time.Now().Unix()},
"instance-3": {Id: "instance-3", State: InstanceState_ACTIVE, Timestamp: time.Now().Unix()},
Expand Down
6 changes: 3 additions & 3 deletions ring/ring_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestRingPageHandler_handle(t *testing.T) {
now := time.Now()
ring := fakeRingAccess{
desc: &Desc{
Ingesters: map[string]InstanceDesc{
Ingesters: map[string]*InstanceDesc{
"1": {
Zone: "zone-a",
State: InstanceState_ACTIVE,
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestRingPageHandler_handle(t *testing.T) {
assert.Regexp(t, regexp.MustCompile(fmt.Sprintf("(?m)%s", strings.Join([]string{
"<td>", "1", "</td>",
"<td>", "zone-a", "</td>",
"<td>", "InstanceState_ACTIVE", "</td>",
"<td>", "ACTIVE", "</td>",
"<td>", "addr-a", "</td>",
}, `\s*`))), recorder.Body.String())

Expand All @@ -59,7 +59,7 @@ func TestRingPageHandler_handle(t *testing.T) {
assert.Regexp(t, regexp.MustCompile(fmt.Sprintf("(?m)%s", strings.Join([]string{
"<td>", "2", "</td>",
"<td>", "zone-b", "</td>",
"<td>", "InstanceState_ACTIVE", "</td>",
"<td>", "ACTIVE", "</td>",
"<td>", "addr-b", "</td>",
}, `\s*`))), recorder.Body.String())

Expand Down

0 comments on commit 2c62aad

Please sign in to comment.