Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix spring autoconfigure test" #41046

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions sdk/spring/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,3 @@ extends:
skipPublishDocGithubIo: true
skipPublishDocMs: true
releaseInBatch: ${{ parameters.release_springcloudazurestarterappconfigurationconfig }}
PreBuildSteps:
# AzureRedisAutoConfigurationTestContainerTest pulls in `ryuk` image because of testcontainers dependency.
# `ryuk` does not exist in mcr.microsoft.com image repository. Do not pull image.
- bash: |
echo "##vso[task.setvariable variable=TESTCONTAINERS_RYUK_DISABLED;]true"
displayName: 'Disable testcontainers ryuk'
5 changes: 0 additions & 5 deletions sdk/spring/pipeline/compatibility-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
- script: |
python -m pip install termcolor
displayName: 'Python module install'
# AzureRedisAutoConfigurationTestContainerTest pulls in `ryuk` image because of testcontainers dependency.
# `ryuk` does not exist in mcr.microsoft.com image repository. Do not pull image.
- bash: |
echo "##vso[task.setvariable variable=TESTCONTAINERS_RYUK_DISABLED;]true"
displayName: 'Disable testcontainers ryuk'
- bash: |
echo "##vso[task.setVariable variable=SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION]$(python ./sdk/spring/scripts/compatibility_get_spring_cloud_version.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION))"
displayName: 'Set env'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@

import com.azure.identity.extensions.implementation.template.AzureAuthenticationTemplate;
import com.azure.spring.cloud.autoconfigure.redis.AzureJedisPasswordlessAutoConfiguration;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -24,6 +21,7 @@
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;

Expand All @@ -35,7 +33,7 @@

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@Testcontainers
@DisabledOnOs({OS.WINDOWS, OS.MAC})
@Disabled("Disable for Container startup failed")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class AzureRedisAutoConfigurationTestContainerTest {

Expand All @@ -44,34 +42,17 @@ public class AzureRedisAutoConfigurationTestContainerTest {

private static final String REDIS_PASSWORD = "fake-testcontainer-password";

/**
* Pulling Docker registry name from testcontainers.properties file as prefix.
*/
private static final GenericContainer<?> REDIS;
@Container
private static GenericContainer<?> redis =
new GenericContainer<>(DockerImageName.parse("redis:5.0.3-alpine"))
.withCommand("--requirepass", REDIS_PASSWORD)
.withExposedPorts(6379);

static {
System.out.println("TESTCONTAINERS_RYUK_DISABLED value: [" + System.getenv("TESTCONTAINERS_RYUK_DISABLED") + "]");

REDIS =
new GenericContainer<>(DockerImageName.parse("redis:6"))
.withCommand("--requirepass", REDIS_PASSWORD)
.withExposedPorts(6379);
}

@BeforeAll
public static void beforeAll() {
REDIS.start();
}

@AfterAll
public static void afterAll() {
REDIS.stop();
}

@DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.host", REDIS::getHost);
registry.add("spring.redis.port", REDIS::getFirstMappedPort);
registry.add("spring.redis.host", redis::getHost);
registry.add("spring.redis.port", redis::getFirstMappedPort);
registry.add("spring.redis.ssl", () -> false);
registry.add("spring.redis.azure.passwordless-enabled", () -> true);
}
Expand All @@ -91,11 +72,12 @@ void testSetAndGet() {

@Test
@Order(2)
void testGetValueAfterSet() {
void testGetVauleAfterSet() {
String value = (String) redisTemplate.opsForValue().get("valueMap3");
Assertions.assertEquals("map3", value);
}


@Configuration
@Import({AzureJedisPasswordlessAutoConfiguration.class, RedisAutoConfiguration.class})
static class AzureRedisPasswordlessTestConfig {
Expand Down

This file was deleted.

7 changes: 1 addition & 6 deletions sdk/spring/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ extends:
stages:
- template: /eng/pipelines/templates/stages/archetype-sdk-tests-isolated.yml
parameters:
EnvVars:
TESTCONTAINERS_RYUK_DISABLED: true
UseFederatedAuth: true
SupportedClouds: "Public,UsGov,China"
Clouds: "Public"
Expand Down Expand Up @@ -45,8 +43,6 @@ extends:
TestOptions: "-DskipSpringITs=false"
- template: /eng/pipelines/templates/stages/archetype-sdk-tests-isolated.yml
parameters:
EnvVars:
TESTCONTAINERS_RYUK_DISABLED: true
UseFederatedAuth: true
SupportedClouds: 'Public,UsGov,China'
Clouds: 'Public'
Expand Down Expand Up @@ -74,8 +70,6 @@ extends:
TestGoals: 'verify'
- template: /eng/pipelines/templates/stages/archetype-sdk-tests-isolated.yml
parameters:
EnvVars:
TESTCONTAINERS_RYUK_DISABLED: true
UseFederatedAuth: true
SupportedClouds: 'Public,UsGov'
Clouds: 'Public'
Expand Down Expand Up @@ -106,3 +100,4 @@ extends:
TestName: 'Spring_Data_Cosmos_Integration'
TestGoals: 'clean verify'
TestOptions: '$(ProfileFlag)'