Why does Codeception suddenly ignore my code? - laravel

My app is created with the Laravel framework and is tested with Codeception.
Without changing the codeception.yml or the .ymls in any test suite, the coverage of codeception suddenly ignores part of my code. As if the lines are suddenly not recognised as code at all. How can this happen?
My codeception.yml
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
include:
- app\Http\Controllers\*
- app\Http\Traits\*
- public\js\*
My acceptance.suite.yml
actor: AcceptanceTester
extensions:
enabled:
- Codeception\Extension\RunProcess:
0: java -Dwebdriver.chrome.driver=./chromedriver -jar selenium-server-standalone-3.12.0.jar
sleep: 5
modules:
enabled:
- WebDriver:
url: http://localhost:8000
browser: chrome
- Db:
dsn: 'mysql:host=localhost;dbname=string_translations'
user: 'root'
password:
dump: tests/_data/empty.sql
populate: true # load dump before all tests
My functional.suite.yml
actor: FunctionalTester
modules:
enabled:
- Laravel5:
environment_file: .env.testing
cleanup: true
- \Helper\Functional
- Db:
dsn: 'mysql:host=localhost;dbname=string_translations_test'
user: 'root'
password:
dump: tests/_data/test_dump.sql
cleanup: true # reload dump between tests
populate: true # load dump before all tests

Related

Witnessing strange surge in RDS aurora mysql RDS

I have a springboot based microservice application.
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "com.palantir.docker" version "0.26.0"
id "com.palantir.docker-run" version "0.26.0"
id 'pl.allegro.tech.build.axion-release' version '1.13.2'
Database is mysql5.7 aurora rds
'mysql', name: 'mysql-connector-java', version: '8.0.28'
hikaricp - 4.0.3
I am witnessing one strange surge in cpu utilisation stats on RDS performance insight dashboard is that even when there are no requests on my app server, mysql still shows high cpu utilization.
Here are the screen shots:
we can observe from the logs that there are no requests on server but when the connection passes its max life, surge in cpu utilization on RDS aurora mysql:
"connection has passed maxLifetime" -> and the top sql shows set autocommit = 0 is the highest number of queries being fired.
Here are my configurations:
application.yml
spring:
application:
name: catalogue
profiles:
# The commented value for `active` can be replaced with valid Spring profiles to load.
# Otherwise, it will be filled in by gradle when building the JAR file
# Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
active: dev
group:
dev:
- dev
- api-docs
# Uncomment to activate TLS for the dev profile
#- tls
prod:
- prod
- api-docs
# Uncomment to activate TLS for the dev profile
#- tls
stage:
- stage
jmx:
enabled: false
data:
web:
pageable:
default-page-size: 20
max-page-size: 20
jpa:
repositories:
bootstrap-mode: deferred
jpa:
open-in-view: false
properties:
hibernate.jdbc.time_zone: UTC
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true #https://vladmihalcea.com/why-you-should-always-use-hibernate-connection-provider_disables_autocommit-for-resource-local-jpa-transactions/
hibernate.cache.use_second_level_cache: true
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory
hibernate.cache.use_query_cache: false
hibernate.javax.cache.missing_cache_strategy: create
# modify batch size as necessary
hibernate.jdbc.batch_size: 20
hibernate.order_inserts: true
hibernate.order_updates: true
hibernate.batch_versioned_data: true
hibernate.query.fail_on_pagination_over_collection_fetch: true
hibernate.query.in_clause_parameter_padding: true
hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect
javax.persistent.sharedCache.mode: ENABLE_SELECTIVE
hibernate:
ddl-auto: none
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
messages:
basename: i18n/messages
main:
allow-bean-definition-overriding: true
task:
execution:
thread-name-prefix: catalogue-task-
pool:
core-size: 2
max-size: 50
queue-capacity: 10000
scheduling:
thread-name-prefix: catalogue-scheduling-
pool:
size: 2
thymeleaf:
mode: HTML
output:
ansi:
console-available: true
server:
servlet:
session:
cookie:
http-only: true
tomcat:
mbeanregistry:
enabled: true
threads:
max: 100
compression:
enabled: true
mime-types: "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json"
min-response-size: 1024
port: 8080
# Properties to be exposed on the /info management endpoint
info:
# Comma separated list of profiles that will trigger the ribbon to show
display-ribbon-on-profiles: 'dev'
management:
endpoints:
web:
exposure:
include: "health,info,metrics,prometheus"
endpoint:
health:
probes:
enabled: true
show-details: always
show-components: always
application-prod.yml
logging:
level:
ROOT: ERROR
org.hibernate.SQL: ERROR
com.pitstop.catalogue: ERROR
com.zaxxer.hikari: ERROR
config: classpath:logback-prod.xml
spring:
devtools:
restart:
enabled: true
additional-exclude: static/**
jackson:
serialization:
indent-output: true
datasource:
auto-commit: false
type: com.zaxxer.hikari.HikariDataSource
url: ${SPRING_DATASOURCE_URL}
username: ${SPRING_DATASOURCE_USERNAME}
password: ${SPRING_DATASOURCE_PASSWORD}
hikari:
poolName: CatalogJPAHikariCP
minimumIdle: 10
maximumPoolSize: 120
connectionTimeout: 30000
idleTimeout: 300000
maxLifetime: 600000
auto-commit: false
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
useLocalSessionState: true
rewriteBatchedStatements: true
cacheResultSetMetadata: true
cacheServerConfiguration: true
maintainTimeStats: true
servlet:
multipart:
location: /data/tmp
jpa:
hibernate:
ddl-auto: none
properties:
spring.jpa.show-sql: true
hibernate.generate_statistics: true
liquibase:
contexts: prod
messages:
cache-duration: PT1S # 1 second, see the ISO 8601 standard
thymeleaf:
cache: false
sleuth:
sampler:
probability: 1 # report 100% of traces

Codeception: DB is not rolling back in API testing

I am testing some certain parts of my API and have noticed that a specific table the DB is not rolling back when my test fail.
Here is my api.suite.yml file:
class_name: ApiTester
modules:
enabled:
- REST:
depends: Laravel5
- \Helper\Api
- Db
And this is my code in codeception.yml:
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: 'mysql:host=127.0.0.1;dbname=test_records'
user: 'root'
password: ''
dump: 'tests/_data/dump.sql'
populate: true
cleanup: true
reconnect: true
Any pointers would be highly appreciated.

jHipster H2 console not working

I am working on monolithic application in which there are some custom entities . When I access the H2 Console via Administration tab . It causes the app to restart when I click the connect button . I am not able to understand why this is happening . Can anyone help me to figure it out .
In logs :
DEBUG 971 --- [ Thread-51] com.mydomain.mytable1 : close successful.
DEBUG 971 --- [ Thread-51] com.mydomain.mytable2 : close successful.
DEBUG 971 --- [ Thread-51] com.mydomain.mytable3 : close successful.
.
.
This is causing an issue to access the database via console although , there is no issue while accessing API . Executing queries also result in localhost refused to connect . I am new to jHipster and H2.
Configuration :
spring:
profiles:
active: dev
include: swagger
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
jackson:
serialization.indent_output: true
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:h2:file:./target/h2db/db/mydatabase;DB_CLOSE_DELAY=-1
username: frothers
password:
h2:
console:
enabled: false
jpa:
database-platform: io.github.jhipster.domain.util.FixedH2Dialect
database: H2
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory
Why disabling the h2 console if you want to access it?
h2:
console:
enabled: false
Just turn enabled to true.

JHipster test: NoCacheRegionFactoryAvailableException when second level cache is disabled

When I use jhipster generate an app, I disabled the second level cache. However, when I run either "gradle test" or "run as junit test" to test the app, it is failed because the "NoCacheRegionFactoryAvailableException". I have checked the application.yml in directory "src/test/resources/config", and be sure that the second cache is disabled. I do not know why the app is still looking for second-cache. Is there any clue how this happen? or how to disable second level cache completely?
Except the test failure, everything else works well, the app can run successfully.
application.yml in src/test/resources/config
spring:
application:
name: EMS
datasource:
url: jdbc:h2:mem:EMS;DB_CLOSE_DELAY=-1
name:
username:
password:
jpa:
database-platform: com.espion.ems.domain.util.FixedH2Dialect
database: H2
open-in-view: false
show_sql: true
hibernate:
ddl-auto: none
naming-strategy: org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy
properties:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.hbm2ddl.auto: validate
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
mail:
host: localhost
mvc:
favicon:
enabled: false
thymeleaf:
mode: XHTML
liquibase:
contexts: test
security:
basic:
enabled: false
server:
port: 10344
address: localhost
jhipster:
async:
corePoolSize: 2
maxPoolSize: 50
queueCapacity: 10000
security:
rememberMe:
# security key (this key should be unique for your application, and kept secret)
key: jhfasdhflasdhfasdkfhasdjkf
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
jmx.enabled: true
swagger:
title: EMS API
description: EMS API documentation
version: 0.0.1
termsOfServiceUrl:
contactName:
contactUrl:
contactEmail:
license:
licenseUrl:
enabled: false
Move src/test/resources/config/application.yml to src/test/resources directory.
You can find that solution from https://github.com/jhipster/generator-jhipster/issues/3730

PhantomJS + Vagrant + Codeception

I was wondering is anyone had the chance to have all of this (plus laravel and wordpress) working in the same envirioment(every page is working and I have no problems with laravel or wordpress).
My question is about is anyone has a configuration working in the right way.
here is my copy of each
functional.suite.yml
class_name: FunctionalTester
modules:
enabled:
# add framework module here
- Laravel5
- Db
- Dbh
- Asserts
- WebDriver:
url: 'http://vagrant.test.com/'
host: '127.0.0.1'
#host: '192.168.56.102'
browser: phantomjs
window_size: 1024x768
port: 4444
window_size: 'maximize'
clear_cookies: 1
restart: 1
- \Helper\Acceptance
config:
Db:
dsn: 'mysql:host=192.168.56.102;dbname=wordpress'
user: 'wordpress_user'
password: 'wordpress_password'
dump: 'tests/_data/dump.sql'
populate: false
cleanup: false
reconnect: true
env:
phantom:
modules:
config:
WebDriver:
browser: 'phantomjs'
chrome:
modules:
config:
WebDriver:
browser: 'chrome'
acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
# add framework module here
- Laravel5
- Asserts
- WebDriver:
- \Helper\Acceptance
config:
Laravel5:
cleanup: false
environment: test
WebDriver:
browser: phantomjs
window_size: 1024x768
url: 'http://vagrant.test.com/'
Db:
dsn: 'mysql:host=localhost;dbname=wordpress'
user: 'wordpress_user'
password: 'wordpress_password'
dump: tests/_data/test-dump.sql
populate: true
cleanup: false
env:
phantom:
modules:
config:
WebDriver:
browser: 'phantomjs'
chrome:
modules:
config:
WebDriver:
browser: 'chrome'
codeception.yml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
#ramdomise test order
random: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
whitelist:
include:
- app/*
remote: true
modules:
enabled:
- Laravel5
- WebDriver
- Db
config:
Db:
dsn: 'mysql:host=vagrant.test.com;dbname=wordpress'
user: 'wordpress_user'
password: 'wordpress_password'
dump: 'tests/_data/myDump.sql'
populate: true
cleanup: true
///////////////////////////////////////////////////
my phantomjs starting code
phantomjs --webdriver=4444
and this is my error
[Codeception\Exception\ModuleException]
Db: SQLSTATE[HY000] [2002] Operation timed out while creating PDO connection

Resources