Skip to content

Commit

Permalink
Merge pull request #696 from aureamunoz/fix-667-race-condition
Browse files Browse the repository at this point in the history
Use .withTimeout method for k8s client to block until endpoint deletion
  • Loading branch information
aureamunoz authored Oct 24, 2023
2 parents aef8c69 + c6055b7 commit c3c2586
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import io.vertx.core.impl.ConcurrentHashSet;
import jakarta.inject.Inject;

import org.hamcrest.Matchers;
Expand Down Expand Up @@ -56,6 +55,7 @@
import io.smallrye.stork.api.ServiceInstance;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProviderBean;
import io.vertx.core.impl.ConcurrentHashSet;

@DisabledOnOs(OS.WINDOWS)
@ExtendWith(WeldJunit5Extension.class)
Expand Down Expand Up @@ -597,7 +597,7 @@ void shouldFetchInstancesFromTheClusterWhenCacheIsInvalidated() throws Interrupt
assertThat(instances.get().stream().map(ServiceInstance::getHost)).containsExactlyInAnyOrder("10.96.96.231",
"10.96.96.232", "10.96.96.233");

client.endpoints().inNamespace(defaultNamespace).withName(serviceName).delete();
client.endpoints().inNamespace(defaultNamespace).withName(serviceName).withTimeout(100, TimeUnit.MILLISECONDS).delete();

service.getServiceDiscovery().getServiceInstances()
.onFailure().invoke(th -> fail("Failed to get service instances from Kubernetes", th))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import io.vertx.core.impl.ConcurrentHashSet;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -52,6 +49,7 @@
import io.smallrye.stork.api.ServiceInstance;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProvider;
import io.vertx.core.impl.ConcurrentHashSet;

@DisabledOnOs(OS.WINDOWS)
@EnableKubernetesMockClient(crud = true)
Expand Down Expand Up @@ -585,7 +583,7 @@ void shouldFetchInstancesFromTheClusterWhenCacheIsInvalidated() throws Interrupt
assertThat(instances.get().stream().map(ServiceInstance::getHost)).containsExactlyInAnyOrder("10.96.96.231",
"10.96.96.232", "10.96.96.233");

client.endpoints().inNamespace(defaultNamespace).withName(serviceName).delete();
client.endpoints().inNamespace(defaultNamespace).withName(serviceName).withTimeout(100, TimeUnit.MILLISECONDS).delete();

service.getServiceDiscovery().getServiceInstances()
.onFailure().invoke(th -> fail("Failed to get service instances from Kubernetes", th))
Expand Down

0 comments on commit c3c2586

Please sign in to comment.