autotest / autotest-docker

Autotest client test containing functional & integration subtests for the Docker project
Other
25 stars 30 forks source link

Do we need to wait long time to generate a ramdom container name? #113

Closed xhe123 closed 10 years ago

xhe123 commented 10 years ago

I tried to generate a ramdom container name with method of DockerContainers.get_unique_name(). However the speed of generating is such slow. After check, I found the default variant of get_size = True, if True, the executing statements in def _get_container_list(self) will go to "else", therefore the get_unique_name() takes so long time to generate.

In fact, It doesn't need the "--size" in the process of generating container name. It would be better if set get_size = False. After all, the default value of get_size should be belong to the situation in most of the time. In addition, from class DockerContainersBase, I got the comment of "Gathering layer-size data is potentially very slow, skip by default", I am not clear what is mean of "skip by default" ?

I called this function like this : def initialize(self): ... docker_containers = DockerContainers(self) docker_containers.get_size = False generated_name = docker_containers.get_unique_name('docker', 'test', 4) ... However how I reset docker_containers.get_size = False in my test case (except reset it in the definition). the docker_containers.get_size equals still True in the end.

cevich commented 10 years ago

Oh wow, I make one little typo, and everybody noticed :grinning: (I just looked at two other PR's to fix this same boo-boo), sorry :cry: Hehehe, anyway, it's taken care of here: https://github.com/autotest/autotest-docker/pull/88/files#diff-2a10c9899d0a32c558f190481332f8a7L133

Re:

I reset docker_containers.get_size = False in my test case (except reset it in the definition). the docker_containers.get_size equals still True in the end.

Now that's an unsolved problem right there, are you sure you didn't re-instantiate the class accidentally?

cevich commented 10 years ago

Okay, nevermind, I figured out why this is happening. it is a bug in dockertest.images.DockerImages. Since there is no __setattr__() to pass-through to the interface class, it just sets the attribute on the DockerImages instance. Okay, this is fixed now with https://github.com/cevich/autotest-docker/commit/5e1723bd601f7b44c465bcbf3b957c023143114e and merged into https://github.com/autotest/autotest-docker/pull/88