Skip to content

Hw15: Тестирование микросервисов#24

Open
ezhk wants to merge 2 commits intomasterfrom
hw12_13_14_15_calendar
Open

Hw15: Тестирование микросервисов#24
ezhk wants to merge 2 commits intomasterfrom
hw12_13_14_15_calendar

Conversation

@ezhk
Copy link
Copy Markdown
Owner

@ezhk ezhk commented Nov 2, 2020

Домашнее задание №15 «Докеризация и интеграционное тестирование Календаря»

Критерии оценки

  • Проект полностью запускается и останавливается с помощью make up / make down - 3 балла
  • Интеграционные тесты запускаются с помощью make bdd. Команда возвращает верный код ответа - 1 балл

Интеграционные тесты покрывают бизнес сценарии:

  • добавление события и обработка бизнес ошибок - 2 балла
  • получение листинга событий на день/неделю/месяц - 2 балла
  • отправка уведомлений - 2 балла

Зачёт от 7 баллов

Copy link
Copy Markdown
Collaborator

@Antonboom Antonboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://otus.ru/teacher-lk/homework/23752/7013/

Здравствуйте!
По тестам ок, по их запуску - не ок

Хочется:

  1. чтобы они проходили
  2. чтобы не оставляли за собой работающие контейнеры
  3. посмотрите на скрипты из вебинара, или отсюда, например
    https://github.com/OtusGolang/webinars_practical_part/blob/master/31-integration-testing/Makefile

Предварительно
6 / 10

docker-compose -f docker/docker-compose.yaml down

bdd:
docker-compose -f docker/docker-compose.yaml run --rm bdd-tests
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при ошибке получаем работающий compose

например, у меня был занят 8080 порт, тесты оставили после себя мусорные запущенные контейнеры

ERROR: for server  Cannot start service server: driver failed programming external connectivity on endpoint calendar-server (45b63f6aeefb1a0fadb61cf577e9391f451a1d4c3cc95e34544a01daa10921f1): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
make: *** [bdd] Error 1

кстати, чтобы такого не происходило, в ports стоит указывать хост тоже. чтобы сервить на localhost, а не 0.0.0.0

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделал бинд на localhost.

down:
docker-compose -f docker/docker-compose.yaml down

bdd:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не прошли + оставили после себя мусор

▶ make bdd
docker-compose -f docker/docker-compose.yaml run --rm bdd-tests
Creating network "docker_postgres" with driver "bridge"
Creating network "docker_rabbit" with driver "bridge"
Creating network "docker_default" with the default driver
Creating network "docker_server" with driver "bridge"
Creating docker_postgres-golang-learning_1 ... done
Creating docker_calendar-base-image_1      ... done
Creating docker_rabbitmq-golang-learning_1 ... done
Creating calendar-sender                   ... done
Creating calendar-server                   ... done
Creating calendar-scheduler                ... done
Creating docker_bdd-tests_run              ... done
....F.......................................... 47


--- Failed steps:

  Scenario: Check upcoming event # features/events_notify.feature:4
    Then received true status # features/events_notify.feature:9
      Error: no notified messages


11 scenarios (10 passed, 1 failed)
47 steps (46 passed, 1 failed)
10.580727s
make: *** [bdd] Error 1

логов явно не хватает

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Речь именно про сохранение вывода в файл?
Progress output, на первый взгляд, весьма удобная и читаемая штука.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тесты также поправил (на самом деле нужны были healthcheck).

Copy link
Copy Markdown
Collaborator

@Antonboom Antonboom Nov 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я имел в виду стектрейс до места, где именно упали тесты

ENV GOOS=linux

VOLUME /app/godogs
RUN go get -u github.com/cucumber/godog/cmd/godog
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если есть vendor, то можно из него собирать, чтобы быстрее было

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для godog не нашел чего-то свежего и звездного в docker hub :(

s.Step(`^update event with global ID and title "([^"]*)"$`, updateEventWithGlobalIDAndTitle)
}

// var opts = godog.Options{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мертвый код убираем

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрал :)

* fix make bdd: use chealthcheck in modules
* move docker files into deplyments
* make bdd call build and up
* clean comments
@ezhk ezhk requested a review from Antonboom November 7, 2020 18:42
Copy link
Copy Markdown
Collaborator

@Antonboom Antonboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Огонь!

8 / 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants