Add image pull waiting.

Signed-off-by: Random-Liu <lantaol@google.com>
This commit is contained in:
Random-Liu
2017-05-22 17:21:17 -07:00
committed by Lantao Liu
parent bc7dfa2650
commit c3ac5f7533
3 changed files with 116 additions and 11 deletions

View File

@@ -17,6 +17,8 @@ limitations under the License.
package server
import (
"fmt"
"sync"
"testing"
"github.com/stretchr/testify/assert"
@@ -72,3 +74,22 @@ func TestUpdateImageMetadata(t *testing.T) {
assert.Equal(t, test.expectedRepoDigests, m.RepoDigests)
}
}
func TestResources(t *testing.T) {
const threads = 10
var wg sync.WaitGroup
r := newResourceSet()
for i := 0; i < threads; i++ {
wg.Add(1)
go func(ref string) {
r.add(ref)
wg.Done()
}(fmt.Sprintf("sha256:%d", i))
}
wg.Wait()
refs := r.all()
for i := 0; i < threads; i++ {
_, ok := refs[fmt.Sprintf("sha256:%d", i)]
assert.True(t, ok)
}
}