Closed romach closed 8 years ago
Нашел баг в тестах:
gradle
При первом запуске тестов возникают две ошибки:
org.itevents.service.CityServiceTest > testAddCity FAILED org.springframework.dao.DuplicateKeyException at CityServiceTest.java:55 Caused by: org.postgresql.util.PSQLException at CityServiceTest.java:55 org.itevents.service.CityServiceTest > testRemoveCitySuccess FAILED org.springframework.dao.DuplicateKeyException at CityServiceTest.java:77 Caused by: org.postgresql.util.PSQLException at CityServiceTest.java:77
При последующих запусках ошибки не возникают;
changeset-010-insert_data_to_city.xml
id
org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(1) already exists. ### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?)) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(1) already exists. ; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(1) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(1) already exists.
org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(2) already exists. ### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?)) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(2) already exists. ; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(2) already exists.
org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(3) already exists. ### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?)) ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(3) already exists. ; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(3) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey" Подробности: Key (id)=(3) already exists.
При последующих запусках тестов исключений нет, так как сиквенс обновлен.
Если явно не указывать id, бага не будет
Замечательный отчет, Рома как всегда на высоте. Но данный баг легко исправился при рефакторинге тестов, так что issue 75 больше не актуальна.
Нашел баг в тестах:
Порядок воспроизведения
gradle
(при этом запускается liquiBase, создаются таблицы и заполняются данные)При первом запуске тестов возникают две ошибки:
При последующих запусках ошибки не возникают;
Анализ бага
changeset-010-insert_data_to_city.xml
явно указываемid
. При этом у нас не обновляется сиквенс первичного ключа (http://stackoverflow.com/questions/9108833/postgres-autoincrement-not-updated-on-explicit-id-inserts). То-есть он равен 0.При последующих запусках тестов исключений нет, так как сиквенс обновлен.
Вывод
Если явно не указывать
id
, бага не будет