Skip to content

Commit

Permalink
remove: flyway
Browse files Browse the repository at this point in the history
  • Loading branch information
geneaky committed Oct 5, 2024
1 parent da65796 commit e89bed8
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 100 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ dependencies {
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.8.1'
implementation 'org.flywaydb:flyway-core'
runtimeOnly 'mysql:mysql-connector-java'

implementation 'org.springframework.boot:spring-boot-starter-security'
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/toy/bookchat/bookchat/localtest/LocalTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.flywaydb.core.Flyway;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import toy.bookchat.bookchat.domain.user.ROLE;
import toy.bookchat.bookchat.domain.user.ReadingTaste;
import toy.bookchat.bookchat.db_module.user.UserEntity;
import toy.bookchat.bookchat.db_module.user.repository.UserRepository;
import toy.bookchat.bookchat.domain.user.ROLE;
import toy.bookchat.bookchat.domain.user.ReadingTaste;
import toy.bookchat.bookchat.security.oauth.OAuth2Provider;
import toy.bookchat.bookchat.security.token.jwt.JwtTokenManager;
import toy.bookchat.bookchat.security.user.TokenPayload;
Expand All @@ -23,18 +21,14 @@
public class LocalTestConfig implements JwtTokenManager {

private final UserRepository userRepository;
private final Flyway flyway;
private UserEntity userEntity;

public LocalTestConfig(UserRepository userRepository, Flyway flyway) {
public LocalTestConfig(UserRepository userRepository) {
this.userRepository = userRepository;
this.flyway = flyway;
}

@PostConstruct
public void init() {
flyway.clean();
flyway.migrate();
userEntity = UserEntity.builder()
.name("google123")
.nickname("geneaky")
Expand All @@ -49,11 +43,6 @@ public void init() {
userRepository.save(userEntity);
}

@PreDestroy
public void finalize() {
userRepository.deleteAll();
}

@Override
public String extractTokenFromAuthorizationHeader(String header) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
### 서재에 책 등록
POST localhost:8080/v1/api/bookshelves
Authorization: {{jwt_token}}
#Authorization: {{jwt_token}}
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb29rQ2hhdCIsImRlZmF1bHRQcm9maWxlSW1hZ2VUeXBlIjoxLCJwcm92aWRlciI6Imdvb2dsZSIsInVzZXJOaWNrbmFtZSI6Iu2VnOudvOu0iTIyIiwidXNlck5hbWUiOiIxMDE3MzM1MTIzNDA3MjA5ODU1OTRnb29nbGUiLCJ1c2VyUHJvZmlsZUltYWdlVXJpIjoiaHR0cHM6Ly9ib29rY2hhdC1vcmlnaW5hbC5zMy5hcC1ub3J0aGVhc3QtMi5hbWF6b25hd3MuY29tL3VzZXJfcHJvZmlsZV9pbWFnZS8zMi05MC00MjAyN2Q1MzJjNDAtZTliNi00M2FiLTljYTMtNzViMDQ1OWE2YzBjLndlYnAiLCJ1c2VyUm9sZSI6IlJPTEVfVVNFUiIsImV4cCI6MTcyODEzNzUzNCwidXNlcklkIjoiMSIsImVtYWlsIjpudWxsfQ.2HpnEuxn2IqiOnCUJATGe2sY62KgFdHDEUZ6H0wf5Qc
Content-Type: application/json

{
"bookRequest": {
"isbn": "1162240035 9791162240038",
"title": "Effective C#(이펙티브5)",
"isbn": "1156640199 9791156640196",
"title": "디자인 시스템 실무 with 피그마",
"authors": [
"빌 와그너"
"이영주"
],
"publisher": "한빛미디어",
"bookCoverImageUrl": "https://search1.kakaocdn.net/thumb/R120x174.q85/?fname=http%3A%2F%2Ft1.daumcdn.net%2Flbook%2Fimage%2F1611826%3Ftimestamp%3D20221107221559",
"publishAt": "2017-11-06"
"publisher": "한빛아카데미",
"publishAt": "2024-02-09",
"bookCoverImageUrl": "https://search1.kakaocdn.net/thumb/R120x174.q85/?fname=http%3A%2F%2Ft1.daumcdn.net%2Flbook%2Fimage%2F6558820%3Ftimestamp%3D20241001160358"
},
"readingStatus": "READING",
"star": null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
drop schema if exists test;
create schema test;
use test;

create table user
(
id bigint auto_increment primary key,
name varchar(255) null,
provider varchar(255) null,
email varchar(255) null,
nickname varchar(255) null,
nickname varchar(20) null,
default_profile_image_type int null,
profile_image_url varchar(255) null,
role int null,
Expand All @@ -14,7 +18,7 @@ create table user
constraint uk_user_nickname unique (nickname)
);

create table refresh_token
create table if not exists refresh_token
(
id bigint auto_increment primary key,
user_id bigint null,
Expand All @@ -24,14 +28,14 @@ create table refresh_token
constraint uk_refresh_token_user_id unique (user_id)
);

create table user_reading_tastes
create table if not exists user_reading_tastes
(
user_id bigint not null,
reading_tastes int null,
constraint fk_user_reading_tastes_user_id foreign key (user_id) references user (id)
);

create table book
create table if not exists book
(
id bigint auto_increment primary key,
isbn varchar(255) not null,
Expand All @@ -44,13 +48,13 @@ create table book
constraint uq_book_isbn_publish_at unique (isbn, publish_at)
);

create table book_authors (
book_id bigint not null,
authors varchar(255),
constraint fk_book_authors_book_id foreign key (book_id) references book (id)
create table if not exists book_authors (
book_id bigint not null,
authors varchar(255),
constraint fk_book_authors_book_id foreign key (book_id) references book (id)
);

create table book_shelf
create table if not exists book_shelf
(
id bigint auto_increment primary key,
book_id bigint not null,
Expand All @@ -63,33 +67,32 @@ create table book_shelf
constraint uq_book_shelf_user_id_book_id unique (user_id, book_id)
);

create table agony
create table if not exists agony
(
id bigint auto_increment primary key,
book_shelf_id bigint not null,
title varchar(255) null,
title varchar(500) null,
hex_color_code varchar(255) null,
created_at datetime(6) null,
updated_at datetime(6) null
);

create table agony_record
create table if not exists agony_record
(
id bigint auto_increment primary key,
agony_id bigint not null,
title varchar(255) null,
content varchar(255) null,
title varchar(500) null,
content text null,
created_at datetime(6) null,
updated_at datetime(6) null
);

create table chat_room
create table if not exists chat_room
(
id bigint auto_increment primary key,
book_id bigint not null,
host_id bigint not null,
room_sid varchar(255) null,
room_name varchar(255) null,
room_name varchar(30) null,
room_size int not null,
default_room_image_type int not null,
room_image_uri varchar(255) null,
Expand All @@ -98,18 +101,18 @@ create table chat_room
constraint uk_chat_room_room_sid unique (room_sid)
);

create table hash_tag
create table if not exists hash_tag
(
id bigint auto_increment
primary key,
created_at datetime(6) null,
updated_at datetime(6) null,
tag_name varchar(255) null,
tag_name varchar(50) null,
constraint uk_hash_tag_tag_name
unique (tag_name)
);

create table chat_room_hash_tag
create table if not exists chat_room_hash_tag
(
id bigint auto_increment primary key,
chat_room_id bigint not null,
Expand All @@ -119,15 +122,15 @@ create table chat_room_hash_tag
constraint uk_chat_room_hash_tag_chat_room_id_hash_tag_id unique (chat_room_id, hash_tag_id)
);

create table chat_room_blocked_user
create table if not exists chat_room_blocked_user
(
id bigint auto_increment primary key,
chat_room_id bigint not null,
user_id bigint not null,
constraint uk_chat_room_blocked_user_user_id_chat_room_id unique (user_id, chat_room_id)
);

create table chat
create table if not exists chat
(
id bigint auto_increment primary key,
chat_room_id bigint not null,
Expand All @@ -137,7 +140,7 @@ create table chat
updated_at datetime(6) null
);

create table participant
create table if not exists participant
(
id bigint auto_increment primary key,
chat_room_id bigint not null,
Expand All @@ -147,17 +150,17 @@ create table participant
constraint uk_participant_user_id_chat_room_id unique (user_id, chat_room_id)
);

create table book_report
create table if not exists book_report
(
id bigint auto_increment primary key,
book_shelf_id bigint not null,
title varchar(255) null,
content longtext null,
title varchar(500) null,
content text null,
created_at datetime(6) null,
updated_at datetime(6) null
);

create table device
create table if not exists device
(
id bigint auto_increment primary key,
user_id bigint not null,
Expand All @@ -167,7 +170,7 @@ create table device
updated_at datetime(6) null
);

create table scrap
create table if not exists scrap
(
id bigint auto_increment primary key,
book_shelf_id bigint not null,
Expand Down
15 changes: 0 additions & 15 deletions src/main/resources/db/migration/V2_1__column_size.sql

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package toy.bookchat.bookchat.domain.chat.service;

import static org.assertj.core.api.Assertions.assertThat;
import static toy.bookchat.bookchat.support.Status.ACTIVE;
import static toy.bookchat.bookchat.domain.participant.ParticipantStatus.HOST;
import static toy.bookchat.bookchat.support.Status.ACTIVE;

import java.time.LocalDate;
import java.util.ArrayList;
Expand All @@ -11,6 +11,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -47,11 +48,20 @@ class ChatServiceConcurrentTest {
@MockBean
private MessagePublisher messagePublisher;

@BeforeEach
public void tearDown() {
userRepository.deleteAll();
bookRepository.deleteAllInBatch();
chatRoomRepository.deleteAllInBatch();
chatRepository.deleteAllInBatch();
participantRepository.deleteAllInBatch();
}

@Test
@DisplayName("제한된 인원수 채팅방 입장 동시성 테스트 성공")
void enterChatRoom() throws Exception {
int roomSize = 5;
int count = 10;
int roomSize = 3;
int count = 5;

BookEntity bookEntity = BookEntity.builder()
.isbn("4640485366")
Expand Down Expand Up @@ -99,7 +109,7 @@ void enterChatRoom() throws Exception {
userRepository.saveAll(userEntityList);

CountDownLatch countDownLatch = new CountDownLatch(count);
ExecutorService executorService = Executors.newFixedThreadPool(10);
ExecutorService executorService = Executors.newFixedThreadPool(count);
AtomicInteger result = new AtomicInteger(0);
for (UserEntity userEntity : userEntityList) {
executorService.execute(() -> {
Expand All @@ -115,12 +125,6 @@ void enterChatRoom() throws Exception {
countDownLatch.await();

assertThat(result.get()).isEqualTo(roomSize - 1);

userRepository.deleteAll();
bookRepository.deleteAllInBatch();
chatRoomRepository.deleteAllInBatch();
chatRepository.deleteAllInBatch();
participantRepository.deleteAllInBatch();
}

}
Loading

0 comments on commit e89bed8

Please sign in to comment.