コード例 #1
0
func initializeTransformer(
	logger lager.Logger,
	cachePath, workDir string,
	maxCacheSizeInBytes uint64,
	maxConcurrentDownloads, maxConcurrentUploads uint,
	skipSSLVerification bool,
	exportNetworkEnvVars bool,
	clock clock.Clock,
) *transformer.Transformer {
	cache := cacheddownloader.New(cachePath, workDir, int64(maxCacheSizeInBytes), 10*time.Minute, int(math.MaxInt8), skipSSLVerification)
	uploader := uploader.New(10*time.Minute, skipSSLVerification, logger)
	extractor := extractor.NewDetectable()
	compressor := compressor.NewTgz()

	return transformer.NewTransformer(
		cache,
		uploader,
		extractor,
		compressor,
		make(chan struct{}, maxConcurrentDownloads),
		make(chan struct{}, maxConcurrentUploads),
		workDir,
		exportNetworkEnvVars,
		clock,
	)
}
コード例 #2
0
		uploadAction = &models.UploadAction{
			To:   uploadTarget.URL,
			From: "./expected-src.txt",
			User: "******",
		}

		tempDir, err = ioutil.TempDir("", "upload-step-tmpdir")
		Expect(err).NotTo(HaveOccurred())

		gardenClient = fakes.NewGardenClient()

		logger = lagertest.NewTestLogger("test")

		compressor = Compressor.NewTgz()
		uploader = Uploader.New(5*time.Second, false, logger)

		fakeStreamer = newFakeStreamer()

		currentUser, err = user.Current()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		os.RemoveAll(tempDir)
		uploadTarget.Close()
	})

	handle := "some-container-handle"

	JustBeforeEach(func() {
コード例 #3
0
ファイル: uploader_test.go プロジェクト: snowsnail/executor
)

var _ = Describe("Uploader", func() {
	var upldr uploader.Uploader
	var testServer *httptest.Server
	var serverRequests []*http.Request
	var serverRequestBody []string
	var logger *lagertest.TestLogger

	BeforeEach(func() {
		testServer = nil
		serverRequestBody = []string{}
		serverRequests = []*http.Request{}
		logger = lagertest.NewTestLogger("test")

		upldr = uploader.New(100*time.Millisecond, false, logger)
	})

	Describe("Upload", func() {
		var url *url.URL
		var file *os.File
		var expectedBytes int
		var expectedMD5 string

		BeforeEach(func() {
			file, _ = ioutil.TempFile("", "foo")
			contentString := "content that we can check later"
			expectedBytes, _ = file.WriteString(contentString)
			rawMD5 := md5.Sum([]byte(contentString))
			expectedMD5 = base64.StdEncoding.EncodeToString(rawMD5[:])
			file.Close()