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

Proof of concept integration tests cli client commands #32

Merged
merged 6 commits into from
Jan 18, 2018

Conversation

AdamSaleh
Copy link
Contributor

Describe what this PR does and why we need it:

As described in https://issues.jboss.org/browse/AEROGEAR-1860, we need to have integration tests.

Changes proposed in this pull request

  • the https://raw.githubusercontent.com/aerogear/mobile-cli/master/artifacts/mobileclient_crd.yaml would be setup on our jenkins-wendy.ci, to allow to run this on PR.
  • the tests themselves are in go, using exec.Command to perform simple cli integration tests
  • for result verification we would be using -o json and json.Unmarshal
  • tests are using flags, to allow for parametrization, currently supporting -namespace and -name, it might be better if name was randomly generated
  • the tests should be reasonably stand-alone, allowing us to run them without setup

To discuss

  • because we are testing eventually consistent system, we probably need to allow for certain ammount of leeway when executing the tests, and include some ammount of timeout-based retries. We should agree on this.

Does this PR depend on another PR (Use this to track when PRs should be merged)

  • Might collide with @witmicko integration testing.

Which issue this PR fixes (This will close that issue when PR gets merged)
fixes AEROGEAR-1860

@@ -0,0 +1,95 @@
package main
Copy link
Contributor

Choose a reason for hiding this comment

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

package integration

@AdamSaleh AdamSaleh force-pushed the IntegrationTests branch 2 times, most recently from 3286bee to 77b238a Compare January 17, 2018 15:34
@AdamSaleh
Copy link
Contributor Author

You should be able to run the new tests in a $NAMESPACE

go test -run ClientJson -v ./integration/ -args -namespace=$NAMESPACE -prefix=test -executable=/home/asaleh/go/src/github.com/aerogear/mobile-cli/mobile

I think the old tests should still work fine, but I so far changed them to require explicit executable path.

go test -run GetServices -v ./integration/ -args -namespace=$NAMESPACE -prefix=test -executable=/home/asaleh/go/src/github.com/aerogear/mobile-cli/mobile

I think that could be done better.
I think I should create a cleanup-step as well.

func ValidMobileClientJson(name string, clientType string) func(output []byte, err error) (bool, []string) {
return func(output []byte, err error) (bool, []string) {
var parsed MobileClientJson
errJson := json.Unmarshal([]byte(output), &parsed)
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be shortened to if err := json.Unmarshal(); err != nil{ }

return false, []string{fmt.Sprintf("%s", err)}
}
if parsed.Spec.ClientType != clientType {
return false, []string{fmt.Sprintf("Expected the ClientType to be %s, but got %s", clientType, parsed.Spec.ClientType)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think what we want here is a custom error type

 type ClientJsonErr struct{
message string
clientType string
}
func (ce ClientJsonErr)Error()string{
   return ce.message
}
func (ce ClientJsonErr)ClientType()string{
  return ce.clientType
}

}

type CmdDesc struct {
executable string
Copy link
Contributor

@vchepeli vchepeli Jan 18, 2018

Choose a reason for hiding this comment

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

Exec string

@maleck13
Copy link
Contributor

@AdamSaleh I am ok with this for now. I wouldn't call it idiomatic go, but there doesn't look to be anything particularly wrong with it. We may find we want to change and adjust things as time goes on and experience in Go grows, but for now it looks fine. I haven't verified it yet as I think @vchepeli was doing that.

@AdamSaleh
Copy link
Contributor Author

Yay, if you are in oc project on your dev-setuped openshift, just running

make integration

now works :)

@AdamSaleh AdamSaleh changed the title DO NOT MERGE YET: Proof of concept integration tests cli client commands Proof of concept integration tests cli client commands Jan 18, 2018
Makefile Outdated
integration: build
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why release is removed?

Copy link
Contributor

@witmicko witmicko left a comment

Choose a reason for hiding this comment

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

one comment, lgtm otherwise

@AdamSaleh AdamSaleh merged commit fca5897 into aerogear-attic:master Jan 18, 2018
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.

4 participants