Exemple #1
0
func (f *factory) loadTarballProvider() bitarball.Provider {
	if f.tarballProvider != nil {
		return f.tarballProvider
	}

	tarballCacheBasePath := filepath.Join(f.workspaceRootPath, "downloads")
	tarballCache := bitarball.NewCache(tarballCacheBasePath, f.fs, f.logger)
	httpClient := bihttpclient.NewHTTPClient(bitarball.HTTPClient, f.logger)
	sha1Calculator := bicrypto.NewSha1Calculator(f.fs)
	f.tarballProvider = bitarball.NewProvider(tarballCache, f.fs, httpClient, sha1Calculator, 3, 500*time.Millisecond, f.logger)
	return f.tarballProvider
}
func (f *agentClientFactory) NewAgentClient(directorID, mbusURL string) agentclient.AgentClient {
	httpClient := httpclient.NewHTTPClient(httpclient.DefaultClient, f.logger)
	return NewAgentClient(mbusURL, directorID, f.getTaskDelay, 10, httpClient, f.logger)
}
Exemple #3
0
				mockCloud.EXPECT().AttachDisk(newVMCID, newDiskCID),
				mockAgentClient.EXPECT().MountDisk(newDiskCID),
				mockAgentClient.EXPECT().MigrateDisk(),
				mockCloud.EXPECT().DetachDisk(newVMCID, oldDiskCID),
				mockCloud.EXPECT().DeleteDisk(oldDiskCID),

				// start jobs & wait for running
				mockAgentClient.EXPECT().Stop(),
				mockAgentClient.EXPECT().Apply(applySpec),
				mockAgentClient.EXPECT().Start(),
				mockAgentClient.EXPECT().GetState().Return(agentRunningState, nil),
			)
		}

		var expectRegistryToWork = func() {
			httpClient := bihttp.NewHTTPClient(bihttp.DefaultClient, logger)

			endpoint := "http://*****:*****@127.0.0.1:6901/instances/fake-director-id/settings"

			settingsBytes := []byte("fake-registry-contents") //usually json, but not required to be
			response, err := httpClient.Put(endpoint, settingsBytes)
			Expect(err).ToNot(HaveOccurred())
			Expect(response.StatusCode).To(Equal(http.StatusCreated))

			response, err = httpClient.Get(endpoint)
			Expect(err).ToNot(HaveOccurred())
			Expect(response.StatusCode).To(Equal(http.StatusOK))
			responseBytes, err := ioutil.ReadAll(response.Body)
			Expect(err).ToNot(HaveOccurred())
			Expect(responseBytes).To(Equal([]byte("{\"settings\":\"fake-registry-contents\",\"status\":\"ok\"}")))