e2e icon indicating copy to clipboard operation
e2e copied to clipboard

Getting Dir & InternalDir mixed up - is there a better way?

Open bill3tt opened this issue 3 years ago • 1 comments
trafficstars

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?

bill3tt avatar May 11 '22 13:05 bill3tt

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:

  1. I start e2e scenario under /home/bwplotka/Repos/test so my Dir() (and removing InternalDir() for container 1 will be /home/bwplotka/Repos/test/<scenario1>/data/<container-name>.
  2. 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

bwplotka avatar May 11 '22 13:05 bwplotka