Skip to content

Conversation

@tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Jul 20, 2022

Previously, the ignite binary was supposed to be present in the path,
which can be error prone if the binary is not up to date with the
integration version.

The change builds the binary before the integration are run, using a
init() function. This is not very adequate since the binary is not
removed at the end of the test. To be able to remove it at the end of
the tests we could:

  1. add a TestMain in each integration sub-package: not super fan of this
    because it involves to repeat the same code for each package
  2. move all tests in the same package: preferable but delete the
    separation between the tests.

If someone could give me a hint on this, it would be nice!

Fix #2635

Previously, the ignite binary was supposed to be present in the path,
which can be error prone if the binary is not up to date with the
integration version.

The change builds the binary before the integration are run, using a
init() function. This is not very adequate since the binary is not
removed at the end of the test. To be able to remove it at the end of
the tests we could:

1) add a TestMain in each integration sub-package: not super fan of this
   because it involves to repeat the same code for each package
2) move all tests in the same package: preferable but delete the
   separation between the tests.
@tbruyelle tbruyelle marked this pull request as draft July 20, 2022 15:00
@aljo242
Copy link
Contributor

aljo242 commented Jul 27, 2022

I think moving the tests to the same package is fine. We will still retain the separation of the modules themselves - the new test module might just be very large.

@tbruyelle
Copy link
Contributor Author

We will still retain the separation of the modules themselves - the new test module might just be very large.

I don't get that point. How this would retain the separation of the modules ?

@aljo242
Copy link
Contributor

aljo242 commented Jul 28, 2022

We will still retain the separation of the modules themselves - the new test module might just be very large.

I don't get that point. How this would retain the separation of the modules ?

I just mean that if we include tests in a separate packages ("pkg_test") we can still separate the logic of the modules themselves. This _test package can just import them.

Maybe I'm misunderstanding something though lol

@ilgooz
Copy link
Member

ilgooz commented Jul 28, 2022

This makes a lot of sense!

It fell into oblivion because we usually let the CI run integration tests since they are way slow to run a user machine -can drive one crazy Haha

IgniteApp string
)

func init() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid using init, maybe not that important for this case but I usually find it causing side effects.

I propose we:

  • Create a package level func that does the installation, named as InstallBinary() with ...Optionss if necessary.
  • Store a sync.Once in a global variable: var installBinaryOnce sync.Once
  • And add logic into New to call installBinaryOnce with InstallBinary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here e8dcbdb

panic(err)
}
IgniteApp = path.Join(tmp, "ignite")
command := exec.Command("go", "build",
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point e8dcbdb

}
IgniteApp = path.Join(tmp, "ignite")
command := exec.Command("go", "build",
"-o", IgniteApp, appPath+"/ignite/cmd/ignite")
Copy link
Member

Choose a reason for hiding this comment

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

Can we define this path in a const defined in the beginning of the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure e8dcbdb

Also:
- use sync.Once rather than init() func
- use gocmd rather than exec.Command directly
@tbruyelle tbruyelle force-pushed the test/integration-build-binary branch from d391ed4 to e8dcbdb Compare August 29, 2022 16:19
@tbruyelle
Copy link
Contributor Author

I finally changed my mind, I was focused on cleaning the compiled binary at the end of tests, but as I said it requires to centralize all the integration tests in the same package. This can be annoying because those tests are long to run and it's actually nice to run a subset of tests by passing a specific sub-package to the go test command.

So the binary will be always located at /tmp/ignite-tests/ignite, and we don't clean it. I think that's acceptable.

@tbruyelle tbruyelle changed the title test: integration build the ignite binary (WIP) test: integration build the ignite binary Aug 29, 2022
@tbruyelle tbruyelle marked this pull request as ready for review August 29, 2022 16:24
@tbruyelle tbruyelle requested a review from aljo242 as a code owner August 29, 2022 16:24
aljo242
aljo242 previously approved these changes Oct 3, 2022
@aljo242
Copy link
Contributor

aljo242 commented Oct 3, 2022

conflicts

@tbruyelle
Copy link
Contributor Author

conflicts

@aljo242 fixed thx!

@aljo242 aljo242 removed the request for review from ivanovpetr October 3, 2022 16:26
@aljo242 aljo242 requested a review from ilgooz October 3, 2022 16:26
@ilgooz ilgooz merged commit cf7fb91 into develop Oct 4, 2022
@ilgooz ilgooz deleted the test/integration-build-binary branch October 4, 2022 11:48
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* test: integration build the ignite binary (WIP)

Previously, the ignite binary was supposed to be present in the path,
which can be error prone if the binary is not up to date with the
integration version.

The change builds the binary before the integration are run, using a
init() function. This is not very adequate since the binary is not
removed at the end of the test. To be able to remove it at the end of
the tests we could:

1) add a TestMain in each integration sub-package: not super fan of this
   because it involves to repeat the same code for each package
2) move all tests in the same package: preferable but delete the
   separation between the tests.

* test: constant ignite binary location

Also:
- use sync.Once rather than init() func
- use gocmd rather than exec.Command directly

* chore: no longer need to build the binary in gh action

* change cl section

Co-authored-by: Alex Johnson <alex@shmeeload.xyz>
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.

integration: the CLI binary should match the version of the tests

5 participants