我有一个带代码接收插件的CakePHP应用程序,可以进行测试。” 我在本地在ddev docker环境中运行它,并且一切正常。
尝试使用gitlab-ci运行自动化测试会给我以下错误:
Running with gitlab-runner 11.1.0 (081978aa)
on shared runner 601c0f11
Using Docker executor with image kevinliteon/cakephp:php7 ...
Starting service mysql:latest ...
Pulling docker image mysql:latest ...
Using docker image sha256:6a834f03bd02bb88cdbe0e289b9cd6056f1d42fa94792c524b4fddc474dab628 for mysql:latest ...
Waiting for services to be up and running...
*** WARNING: Service runner-601c0f11-project-94-concurrent-0-mysql-0 probably didn't start properly.
Health check error:
service "runner-601c0f11-project-94-concurrent-0-mysql-0-wait-for-service" timeout
Health check container logs:
Service container logs:
2018-10-04T12:12:18.904025613Z Initializing database
2018-10-04T12:12:18.925096235Z 2018-10-04T12:12:18.919745Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-10-04T12:12:18.925195518Z 2018-10-04T12:12:18.919970Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.12) initializing of server in progress as process 30
2018-10-04T12:12:50.330736417Z 2018-10-04T12:12:50.330487Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
*********
Pulling docker image kevinliteon/cakephp:php7 ...
Using docker image sha256:bd4a83b02647ad93a356b343d2ce5ae3a9a1177aea2cd76c61b009abc7df8990 for kevinliteon/cakephp:php7 ...
Running on runner-601c0f11-project-94-concurrent-0 via d7f4a5e71b47...
Fetching changes...
Removing vendor/
HEAD is now at 92cb022 test
Checking out 92cb0223 as deployment...
Skipping Git submodules setup
Checking cache for default...
Successfully extracted cache
$ vendor/bin/codecept run Unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
In Db.php line 308:
Db: SQLSTATE[HY000] [2002] Connection refused while creating PDO connection
我的gitlab-ci.yml(部分):
services:
- mysql:latest
variables:
MYSQL_ROOT_PASSWORD: mysql123456789
MYSQL_DATABASE: test_db
MYSQL_USER: db
MYSQL_PASSWORD: db
build:
...
codecept:Unit:
stage: test
script:
- vendor/bin/codecept run Unit
在我的codeception.yml中,我配置了Db模块:
modules:
config:
Db:
dsn: 'mysql:host=mysql;dbname=test_db'
user: 'db'
password: 'db'
cleanup: true # reload dump between tests
populate: true # load dump before all tests
reconnect: true
我还尝试使用root用户-失败。
问题是,无论出于什么原因我都无法连接到数据库...也许初始化服务容器时的警告与此有关,但是我不知道如何解决它们,或者这是问题。
我真的尝试了很多事情,但都没有成功!基本上,我的代码取决于gitlab-ci和codeception的文档,因此它应该可以工作。
有人成功实现了此方案,还是知道我做错了什么? 感谢您的帮助!
答案 0 :(得分:0)
我想回答我如何解决它: 首先,我必须像这样添加env-varibale“ db_dsn”:
library(tm)
library(wordcloud)
# sample data
filePath <- "http://www.sthda.com/sthda/RDoc/example-files/martin-luther-king-i-have-a-dream-speech.txt"
speech <- readLines(filePath)
speech1 = Corpus(VectorSource(speech))
myDTM = TermDocumentMatrix(speech1, control = list(minWordLength = 1))
myDTM_mat <- as.matrix(myDTM)
myDTM_mat_sorted <- sort(rowSums(myDTM_mat),decreasing = TRUE)
myDTM_df <- data.frame(word = names(myDTM_mat_sorted), freq = myDTM_mat_sorted)
wordcloud(myDTM_df$word,
myDTM_df$freq,
max.words=100,
random.order = F)
然后,我仍然收到健康检查错误。我发现成功设置的唯一方法是对db-service使用另一个docker映像。我选择“ mariadb:latest”-然后它对我有用。