e2e
e2e copied to clipboard
Getting Dir & InternalDir mixed up - is there a better way?
Knowing when to use Dir & InternalDir is confusing and getting them mixed up can lead to file permission issues when your containers start up.
For example, when trying to create a dir called test in the container:
if err := os.MkdirAll(filepath.Join(demo.InternalDir(), "test"), os.ModePerm); err != nil {
return e2e.NewErrInstrumentedRunnable(name, errors.Wrap(err, "create test dir failed"))
}
leads to the following when run
unexpected error: create logs dir failed: mkdir /shared: permission denied
You receive that error message when the test is running & the containers have started up, so naturally you think that the error is coming from within the container, when in actual fact it is failing because the process can't create the /shared directory on your local machine.
Is there a better way of doing this? or preventing this kind of confusing error message from the caller's?
Yes, I think there is a way to improve API, by ONLY specifying Dir() and creating a fake path in the container that DOES not start with /shared but starts with your real host path. 🎉
For example:
- I start e2e scenario under
/home/bwplotka/Repos/testso myDir()(and removingInternalDir()for container 1 will be/home/bwplotka/Repos/test/<scenario1>/data/<container-name>. - In new logic, we can create literally fake container path
/home/bwplotka/Repos/test/<scenario1>/data/<container-name>and share volume like- v=/home/bwplotka/Repos/test/<scenario1>:/home/bwplotka/Repos/test/<scenario1>:z