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

Institute - Cache institute api data into Redis Cluster instead of standalone #336

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 6 additions & 12 deletions api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@
public class RedisConfig {
@Autowired
private EducGradTraxApiConstants constants;

@Bean
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setHostName(constants.getRedisUrl());
redisStandaloneConfiguration.setPort(Integer.parseInt(constants.getRedisPort()));
redisStandaloneConfiguration.setPassword(constants.getRedisSecret());

//Cluster Configuration
RedisClusterConfiguration redisClusterConfiguration = new RedisClusterConfiguration();
RedisNode node0 = new RedisNode(constants.getRedisUrl(), Integer.parseInt(constants.getRedisPort()));
redisClusterConfiguration.addClusterNode(node0);

RedisClusterNode rcn = new RedisClusterNode(constants.getRedisUrl(), Integer.parseInt(constants.getRedisPort()));

return new JedisConnectionFactory(redisStandaloneConfiguration);
redisClusterConfiguration.addClusterNode(new RedisClusterNode(
constants.getRedisUrl(),
Integer.parseInt(constants.getRedisPort())));
redisClusterConfiguration.setPassword(constants.getRedisSecret());
return new JedisConnectionFactory(redisClusterConfiguration);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
Expand Down Expand Up @@ -42,6 +43,8 @@ public abstract class BaseReplicationServiceTest {
public OAuth2AuthorizedClientRepository oAuth2AuthorizedClientRepository;
@MockBean
public OAuth2AuthorizedClientService oAuth2AuthorizedClientService;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@Before
public void resetState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -53,6 +54,9 @@ public class ChoreographedEventPersistenceServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;


@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class CodeServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -51,6 +52,8 @@ public class DistrictServiceTest {
@Mock WebClient.RequestBodySpec requestBodyMock;
@Mock WebClient.RequestBodyUriSpec requestBodyUriMock;
@Mock WebClient.ResponseSpec responseMock;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@MockBean
@Qualifier("default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -51,6 +52,8 @@ public class EdwServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;


@TestConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -47,6 +48,8 @@ public class GradStudentGraduatedServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -47,6 +48,8 @@ public class GradStudentUndoCompletionServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -47,6 +48,8 @@ public class GradStudentUpdatedServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -64,6 +65,8 @@ public class PsiServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -76,6 +77,8 @@ class SchoolServiceTest {

@MockBean
private CommonSchoolCache commonSchoolCache;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.*;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class TraxCommonServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
Expand Down Expand Up @@ -79,6 +80,8 @@ public class TraxUpdateServiceTest {

@MockBean
private Subscriber subscriber;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@TestConfiguration
static class TestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -69,6 +70,8 @@ public class InstituteCodeServiceTest {
private GradCountryRepository gradCountryRepository;
@MockBean
private GradProvinceRepository gradProvinceRepository;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@MockBean
@Qualifier("default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class InstituteDistrictServiceTest {
private DistrictService districtService;
@MockBean
private DistrictRedisRepository districtRedisRepository;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;

@MockBean
@Qualifier("default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
Expand Down Expand Up @@ -61,6 +62,8 @@ public class InstituteSchoolServiceTest {
@MockBean
private SchoolRedisRepository schoolRedisRepository;
@MockBean
private JedisConnectionFactory jedisConnectionFactory;
@MockBean
@Qualifier("default")
WebClient webClientMock;
@Mock
Expand Down
Loading