Skip to content
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

Create end-to-end tests for openAPI #643

Closed
drasko opened this issue Mar 7, 2019 · 27 comments · Fixed by #2175
Closed

Create end-to-end tests for openAPI #643

drasko opened this issue Mar 7, 2019 · 27 comments · Fixed by #2175
Assignees
Labels
Milestone

Comments

@drasko
Copy link
Contributor

drasko commented Mar 7, 2019

A set of e2e tests should be created to check the sanity of the system before merging new PRs.

Test should:

  • Act as user - use SDK to register and login user
  • Use SDK to provision things and channels
  • Act as a Mainflux thing (device or app) - use SDK to send messages that will be written via Writters to various DBs (C*, InfluxDB, MongoDB)
  • Use SDK to read messages from various Readers
  • Compare and validate read messages

This way whole Mainflux system will be treated as a blck box, and tests will proven API sanity and that main functionalities are preserved.

@drasko drasko added this to the 0.9.0 milestone Mar 7, 2019
@alwindoss
Copy link
Contributor

e2e tests are usually run on a deployed software. Are you hinting towards a deployment on docker to run the e2e tests and then the developer can raise a PR?

@nmarcetic nmarcetic self-assigned this Mar 25, 2019
@mandric
Copy link
Contributor

mandric commented Apr 15, 2019

Is this something a newbie could work on? I have experience with e2e testing tools in the NodeJS world and little Golang experience but am motivated to learn.

@drasko
Copy link
Contributor Author

drasko commented Apr 15, 2019

@mandric yes, definitely you can give it a try. I think it should start by selecting a correct technology. @chombium and @anovakovic01 mentioned Pact before, and there is a Go version: https://github.com/pact-foundation/pact-go

I am not sure at this point what thecnology would be best to do this, some research on technology choices is needed.

@mandric
Copy link
Contributor

mandric commented Apr 15, 2019

Pact looks interesting, I am not a Ruby person either, I have Python experience though. But if you give me the set of tools I can play around with it and see how far I get.

@mandric
Copy link
Contributor

mandric commented Apr 15, 2019

There appears to be python version, not sure if that's interesting. https://github.com/pact-foundation/pact-python

@mandric
Copy link
Contributor

mandric commented Apr 15, 2019

Oh sorry, it would obviously be written in Go! That could be a fun way to learn!

@mandric
Copy link
Contributor

mandric commented May 14, 2019

Well I looked a little at pact-go and the APIs seemed a little complicated, so I just wrote something up that was quickest for me using bash and bats. I thought I would post here to get some initial feedback. I figured it would be useful even if not as a long term solution but maybe as a way to quickly get some coverage and maybe help think about the problem. I would be happy to go back to pact-go but it would take more time to get something up and running.

https://github.com/mandric/mainflux-e2e-bats

The next steps if you wanted to continue on the bats path would probably be 1) obviously adding more coverage 2) hooking up to CI.

@nmarcetic nmarcetic modified the milestones: 0.9.0, 0.9.5 Jul 10, 2019
@mandric
Copy link
Contributor

mandric commented Sep 16, 2019

This might be a better option that has more automation using swagger, postman and newman: e.g. https://github.com/gothinkster/realworld/tree/master/api

I haven't researched yet but I imagine GoLang has equivalent toolset.

@chombium
Copy link
Collaborator

@mandric this looks really interesting. I guess we'll have to add some glue code which will go through all of our swagger files and generate the whole api spec + some test data, before testing the api itself

@drasko
Copy link
Contributor Author

drasko commented Sep 17, 2019

Yes, this is interesting. I researched already go-swagger before.

In any case, fining an equivalent to this would be interesting: https://github.com/postmanlabs/newman

@nmarcetic
Copy link
Collaborator

Check out Kubernetes methodology overview Also Ginkgo Looks great.

@nmarcetic nmarcetic modified the milestones: 0.10.0, 1.0.0 Dec 18, 2019
@nmarcetic
Copy link
Collaborator

nmarcetic commented Jan 23, 2020

@mainflux/maintainers I took this issue to do research.

@drasko drasko modified the milestones: 1.0.0, 0.11.0 Apr 20, 2020
@drasko drasko modified the milestones: 0.11.0, 0.12.0 Apr 20, 2020
@drasko drasko assigned manuio and unassigned nmarcetic May 24, 2020
@drasko
Copy link
Contributor Author

drasko commented Sep 5, 2020

@drasko
Copy link
Contributor Author

drasko commented Sep 5, 2020

TBH, having all this in mind, I am leaning mostly to something like this:

As I mentioned before, I really like Property-Based Testing approach - as referenced in https://github.com/mainflux/mainflux/issues/643#issuecomment-687667599

Nice articles about Schematesis' PBT approach:

Probably this nice Haskell tool is also worth exploring: https://github.com/rodrigosetti/swagger-test

Having in mind Mainflux lightweight mindset, I would not be surprised that this Haskell tool would be the best fit :). Just that it supports OpenAPI-only, and we'll need AsyncAPI as well (for MQTT purposes) - read more about it here.

@Stranger6667
Copy link

Hello, all!
The Schemathesis author here. Happy to see that you are considering Schemathesis :) Let me know if I can provide any support from my side, e.g., missing features or something not working as expected :)

@drasko
Copy link
Contributor Author

drasko commented Sep 7, 2020

@Stranger6667 thanks for your work on Schemathesis, I think it is ideated in the right directions, alongside the idea of PBT and QuickREST article.

One thing I see now missing for our purpose would be AsyncAPI, bacause in IoT MQTT is a predominant protocol, and in general lot of PUB/SUB paradigm is used.

Is there any plans to add this support from your side, and how hard would be to add it?

@Stranger6667
Copy link

Thank you!

Is there any plans to add this support from your side, and how hard would be to add it?

AsyncAPI is new to me. As far as I see, this spec is very close to Open API, and it should be relatively easy to adjust the existing Open API code to generate messages or other structures since they follow the JSON Schema spec (as far as I see).

However, to support a complete testing flow we need wider transport support. Schemathesis is centered around HTTP, and building other transports might require some more investigation and time. I will take a deeper look there, but from my side, AsyncAPI is definitely something I'd like to support in Schemathesis :)

At the moment I am working on making Schemathesis more spec-agnostic tool and available as a service - not sure about the bandwidth I can allocate now, but I think that supporting AsyncAPI would be a logical next step for Schemathesis after I am done with refactoring :) I expect that I'll have time to bring some proof of concept prototype during October

@manuio manuio added the tests label Oct 27, 2020
@drasko drasko modified the milestones: 0.12.0, 0.13.0 Jan 9, 2021
@manuio manuio modified the milestones: 0.13.0, 1.0.0 Jan 11, 2022
@drasko drasko assigned arvindh123 and unassigned darkodraskovic Aug 5, 2022
@drasko
Copy link
Contributor Author

drasko commented Nov 9, 2022

Adding John Hughes talk (on QuickCheck) for the reference: https://www.youtube.com/watch?v=zi0rHwfiX1Q

And another one: https://www.youtube.com/watch?v=hXnS_Xjwk2Y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

10 participants