New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test environment for mssql #4282

Merged
merged 43 commits into from Dec 12, 2018

Conversation

@kolaente
Copy link
Member

kolaente commented Jun 20, 2018

This pr adds a test step in drone to run tests with mssql db.

Even if you dont like Microsoft (like me), IMHO we should at least have tests for mssql dbs or not support it at all.

kolaente added some commits Jun 20, 2018

.drone.yml Outdated
@@ -360,7 +360,7 @@ services:
image: microsoft/mssql-server-linux:latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=M$wantsaSecurePassword
- SA_PASSWORD=M$wantsaSecurePassword1

This comment has been minimized.

@lafriks

lafriks Jun 20, 2018

Member

I think you need to escape $ character otherwise it tries to connect with password MwantsaSecurePassword1

This comment has been minimized.

@lafriks

lafriks Jun 20, 2018

Member

but maybe not it this file but in app.ini

This comment has been minimized.

@kolaente

kolaente Jun 20, 2018

Member

Thanks for pointing that out, I thinks thats the issue.

@bkcsoft bkcsoft added the lgtm/need 2 label Jun 20, 2018

kolaente added some commits Jun 20, 2018

@lafriks

This comment has been minimized.

Copy link
Member

lafriks commented Jun 20, 2018

Database is not created so gitea is not able to connect:
error: mssql: Cannot open database "testgitea" that was requested by the login. Using the user default database "master" instead.

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Jun 20, 2018

@lafriks oh ok. Drone shows a different error message though... But I'll try with your recommondation.

kolaente added some commits Jun 20, 2018

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Jun 20, 2018

Now I get that weired error:

Failed to initialize ORM engine: sync database struct error: Unknown colType SYSNAME for MSreplication_options - optname

Is that an issue with xorm, the test I added, or Gitea?

\cc @lunny looks like a xorm issue.

@lafriks

This comment has been minimized.

Copy link
Member

lafriks commented Jun 20, 2018

@kolaente Gitea does not create database so docker service needs to do it.

@lunny

This comment has been minimized.

Copy link
Member

lunny commented Jun 21, 2018

@kolaente I will investigate it. And as @lafriks said, you have to create database manually.

@lunny lunny added this to the 1.6.0 milestone Jul 4, 2018

@lunny lunny referenced this pull request Jul 4, 2018

Open

Error on startup 1.5 #4360

2 of 7 tasks complete
@lunny

This comment has been minimized.

Copy link
Member

lunny commented Jul 4, 2018

@kolaente you have to add some SQL to create the database at first.

@@ -172,6 +172,20 @@ pipeline:
when:
event: [ push, tag, pull_request ]

test-mssql:

This comment has been minimized.

@techknowlogick

techknowlogick Jul 5, 2018

Member

Edit: I was being lazy, pay attention to @JonasFranzDEV as his solution is better than mine.
before the test steps (look at group test) you could have a step that creates the DB like:

mssql-create-db:
   image: microsoft/mssql-tools
   commands:
    - sqlcmd -S mssql -U sa -P MwantsaSecurePassword1 -Q "CREATE DATABASE master"
   when:
      event: [ push, tag, pull_request ]

I haven't tested the above (or indentation) but something like it should work

This comment has been minimized.

@jonasfranz

jonasfranz Jul 5, 2018

Member

The better option might be to create the database in code like we do for pgsql and mysql:
https://github.com/go-gitea/gitea/blob/master/integrations/integration_test.go#L110

This comment has been minimized.

@jonasfranz

jonasfranz Jul 5, 2018

Member

I've implemented it and the test works now

jonasfranz added some commits Jul 5, 2018

Create master database for mssql integration tests
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Create database only if master do not exist
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Fix mssql integration tests by using custom database "gitea"
Signed-off-by: Jonas Franz <info@jonasfranz.software>
@jonasfranz
Copy link
Member

jonasfranz left a comment

The test environment works but the test fails for other reasons.

@bkcsoft bkcsoft added lgtm/need 1 and removed lgtm/need 2 labels Jul 5, 2018

@chdxD1

This comment has been minimized.

Copy link
Contributor

chdxD1 commented Dec 11, 2018

@lunny Thanks for the pull request (this is also an issue but not the underlying one) go-xorm/xorm#1173
Tested this locally and all tests seem to be OK.

@lunny

This comment has been minimized.

Copy link
Member

lunny commented Dec 11, 2018

@chdxD1 thanks, merged xorm's PR. But we still need a PR to update xorm, maybe this PR? @kolaente

@lunny lunny reopened this Dec 11, 2018

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

@lunny I'll update it

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

Now the build fails, does anyone know if xorm changed significant amounts of code so our code is invalid?

@chdxD1

This comment has been minimized.

Copy link
Contributor

chdxD1 commented Dec 11, 2018

@kolaente Could you please run a dep ensure locally and remove the string from the interface https://github.com/kolaente/gitea/blob/master/models/models.go#L39

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

@chdxD1 Still fails, but because apparantly models/repo_watch.go:34 still uses exec
@lunny Is there a reason this used e.Exec instead of x.Exec? x is available in that context.

Show resolved Hide resolved models/models.go
@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

Build should work now!

@chdxD1

This comment has been minimized.

Copy link
Contributor

chdxD1 commented Dec 11, 2018

@kolaente Despite repo_watch using e.Exec: This is the relevant change from xorm (for reviewers): go-xorm/xorm@4ce90f9
The first parameter is beeing checked for type string (so all calls to the Exec function will still work)

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

@chdxD1 makes sense, I just thought it had beed removed in favour of x.SQL.

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Dec 11, 2018

Codecov Report

Merging #4282 into master will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4282      +/-   ##
==========================================
- Coverage   37.62%   37.59%   -0.04%     
==========================================
  Files         319      319              
  Lines       46949    46949              
==========================================
- Hits        17666    17651      -15     
- Misses      26769    26791      +22     
+ Partials     2514     2507       -7
Impacted Files Coverage Δ
models/models.go 54.54% <0%> (ø) ⬆️
modules/log/file.go 42.73% <0%> (-24.79%) ⬇️
routers/repo/view.go 46.01% <0%> (+1.22%) ⬆️
models/repo_list.go 64.55% <0%> (+1.26%) ⬆️
models/repo_indexer.go 47.88% <0%> (+3.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1f3685...96f7f86. Read the comment docs.

@kolaente

This comment has been minimized.

Copy link
Member

kolaente commented Dec 11, 2018

CI passes! 🎉 🎉 🎉 🎉 🎉 🎉

@lafriks

This comment has been minimized.

Copy link
Member

lafriks commented Dec 11, 2018

@lunny need your approval

@sapk

sapk approved these changes Dec 11, 2018

@lunny

lunny approved these changes Dec 12, 2018

@lunny lunny merged commit 6db7dbd into go-gitea:master Dec 12, 2018

2 checks passed

approvals/lgtm this commit looks good
continuous-integration/drone/pr the build was successful
Details
@lunny

This comment has been minimized.

Copy link
Member

lunny commented Dec 12, 2018

Thanks all of you!!!

@kolaente kolaente deleted the kolaente:mssql-test branch Dec 12, 2018

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