當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testutil.QemuCompatible函數代碼示例

本文整理匯總了Golang中github.com/hashicorp/nomad/client/testutil.QemuCompatible函數的典型用法代碼示例。如果您正苦於以下問題:Golang QemuCompatible函數的具體用法?Golang QemuCompatible怎麽用?Golang QemuCompatible使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了QemuCompatible函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestQemuDriver_Fingerprint

// The fingerprinter test should always pass, even if QEMU is not installed.
func TestQemuDriver_Fingerprint(t *testing.T) {
	ctestutils.QemuCompatible(t)
	task := &structs.Task{
		Name:      "foo",
		Resources: structs.DefaultResources(),
	}
	driverCtx, execCtx := testDriverContexts(task)
	defer execCtx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)
	node := &structs.Node{
		Attributes: make(map[string]string),
	}
	apply, err := d.Fingerprint(&config.Config{}, node)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if !apply {
		t.Fatalf("should apply")
	}
	if node.Attributes["driver.qemu"] == "" {
		t.Fatalf("Missing Qemu driver")
	}
	if node.Attributes["driver.qemu.version"] == "" {
		t.Fatalf("Missing Qemu driver version")
	}
}
開發者ID:achanda,項目名稱:nomad,代碼行數:27,代碼來源:qemu_test.go

示例2: TestQemuDriver_RequiresMemory

func TestQemuDriver_RequiresMemory(t *testing.T) {
	ctestutils.QemuCompatible(t)
	// TODO: use test server to load from a fixture
	task := &structs.Task{
		Name: "linux",
		Config: map[string]string{
			"image_source": "https://dl.dropboxusercontent.com/u/47675/jar_thing/linux-0.2.img",
			"accelerator":  "tcg",
			"host_port":    "8080",
			"guest_port":   "8081",
			"checksum":     "a5e836985934c3392cbbd9b26db55a7d35a8d7ae1deb7ca559dd9c0159572544",
			// ssh u/p would be here
		},
	}

	driverCtx := testDriverContext(task.Name)
	ctx := testDriverExecContext(task, driverCtx)
	defer ctx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	_, err := d.Start(ctx, task)
	if err == nil {
		t.Fatalf("Expected error when not specifying memory")
	}
}
開發者ID:riddopic,項目名稱:nomad,代碼行數:25,代碼來源:qemu_test.go

示例3: TestQemuDriver_RequiresMemory

func TestQemuDriver_RequiresMemory(t *testing.T) {
	t.Parallel()
	ctestutils.QemuCompatible(t)
	// TODO: use test server to load from a fixture
	task := &structs.Task{
		Name: "linux",
		Config: map[string]interface{}{
			"artifact_source": "https://dl.dropboxusercontent.com/u/47675/jar_thing/linux-0.2.img",
			"accelerator":     "tcg",
			"host_port":       "8080",
			"guest_port":      "8081",
			"checksum":        "sha256:a5e836985934c3392cbbd9b26db55a7d35a8d7ae1deb7ca559dd9c0159572544",
			// ssh u/p would be here
		},
		LogConfig: &structs.LogConfig{
			MaxFiles:      10,
			MaxFileSizeMB: 10,
		},
	}

	driverCtx, execCtx := testDriverContexts(task)
	defer execCtx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	_, err := d.Start(execCtx, task)
	if err == nil {
		t.Fatalf("Expected error when not specifying memory")
	}
}
開發者ID:stigkj,項目名稱:nomad,代碼行數:29,代碼來源:qemu_test.go

示例4: TestQemuDriver_StartOpen_Wait

func TestQemuDriver_StartOpen_Wait(t *testing.T) {
	ctestutils.QemuCompatible(t)
	task := &structs.Task{
		Name: "linux",
		Config: map[string]interface{}{
			"image_path":  "linux-0.2.img",
			"accelerator": "tcg",
			"port_map": []map[string]int{{
				"main": 22,
				"web":  8080,
			}},
			"args": []string{"-nodefconfig", "-nodefaults"},
		},
		LogConfig: &structs.LogConfig{
			MaxFiles:      10,
			MaxFileSizeMB: 10,
		},
		Resources: &structs.Resources{
			CPU:      500,
			MemoryMB: 512,
			Networks: []*structs.NetworkResource{
				&structs.NetworkResource{
					ReservedPorts: []structs.Port{{"main", 22000}, {"web", 80}},
				},
			},
		},
	}

	driverCtx, execCtx := testDriverContexts(task)
	defer execCtx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	// Copy the test image into the task's directory
	dst, _ := execCtx.AllocDir.TaskDirs[task.Name]
	copyFile("./test-resources/qemu/linux-0.2.img", filepath.Join(dst, "linux-0.2.img"), t)

	handle, err := d.Start(execCtx, task)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle == nil {
		t.Fatalf("missing handle")
	}

	// Attempt to open
	handle2, err := d.Open(execCtx, handle.ID())
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle2 == nil {
		t.Fatalf("missing handle")
	}

	// Clean up
	if err := handle.Kill(); err != nil {
		fmt.Printf("\nError killing Qemu test: %s", err)
	}
}
開發者ID:achanda,項目名稱:nomad,代碼行數:58,代碼來源:qemu_test.go

示例5: TestQemuDriver_StartOpen_Wait

func TestQemuDriver_StartOpen_Wait(t *testing.T) {
	t.Parallel()
	ctestutils.QemuCompatible(t)
	// TODO: use test server to load from a fixture
	task := &structs.Task{
		Name: "linux",
		Config: map[string]interface{}{
			"artifact_source": "https://dl.dropboxusercontent.com/u/47675/jar_thing/linux-0.2.img",
			"checksum":        "sha256:a5e836985934c3392cbbd9b26db55a7d35a8d7ae1deb7ca559dd9c0159572544",
			"accelerator":     "tcg",
			"port_map": []map[string]int{{
				"main": 22,
				"web":  8080,
			}},
		},
		LogConfig: &structs.LogConfig{
			MaxFiles:      10,
			MaxFileSizeMB: 10,
		},
		Resources: &structs.Resources{
			CPU:      500,
			MemoryMB: 512,
			Networks: []*structs.NetworkResource{
				&structs.NetworkResource{
					ReservedPorts: []structs.Port{{"main", 22000}, {"web", 80}},
				},
			},
		},
	}

	driverCtx, execCtx := testDriverContexts(task)
	defer execCtx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	handle, err := d.Start(execCtx, task)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle == nil {
		t.Fatalf("missing handle")
	}

	// Attempt to open
	handle2, err := d.Open(execCtx, handle.ID())
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle2 == nil {
		t.Fatalf("missing handle")
	}

	// Clean up
	if err := handle.Kill(); err != nil {
		fmt.Printf("\nError killing Qemu test: %s", err)
	}
}
開發者ID:stigkj,項目名稱:nomad,代碼行數:56,代碼來源:qemu_test.go

示例6: TestQemuDriver_Start

func TestQemuDriver_Start(t *testing.T) {
	ctestutils.QemuCompatible(t)
	// TODO: use test server to load from a fixture
	task := &structs.Task{
		Name: "linux",
		Config: map[string]string{
			"image_source": "https://dl.dropboxusercontent.com/u/47675/jar_thing/linux-0.2.img",
			"checksum":     "a5e836985934c3392cbbd9b26db55a7d35a8d7ae1deb7ca559dd9c0159572544",
			"accelerator":  "tcg",
			"guest_ports":  "22,8080",
		},
		Resources: &structs.Resources{
			MemoryMB: 512,
			Networks: []*structs.NetworkResource{
				&structs.NetworkResource{
					ReservedPorts: []int{22000, 80},
				},
			},
		},
	}

	driverCtx := testDriverContext(task.Name)
	ctx := testDriverExecContext(task, driverCtx)
	defer ctx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	handle, err := d.Start(ctx, task)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle == nil {
		t.Fatalf("missing handle")
	}

	// Attempt to open
	handle2, err := d.Open(ctx, handle.ID())
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if handle2 == nil {
		t.Fatalf("missing handle")
	}

	// Clean up
	if err := handle.Kill(); err != nil {
		fmt.Printf("\nError killing Qemu test: %s", err)
	}
}
開發者ID:riddopic,項目名稱:nomad,代碼行數:48,代碼來源:qemu_test.go

示例7: TestQemuDriverUser

func TestQemuDriverUser(t *testing.T) {
	ctestutils.QemuCompatible(t)
	task := &structs.Task{
		Name: "linux",
		User: "alice",
		Config: map[string]interface{}{
			"image_path":  "linux-0.2.img",
			"accelerator": "tcg",
			"port_map": []map[string]int{{
				"main": 22,
				"web":  8080,
			}},
			"args": []string{"-nodefconfig", "-nodefaults"},
		},
		LogConfig: &structs.LogConfig{
			MaxFiles:      10,
			MaxFileSizeMB: 10,
		},
		Resources: &structs.Resources{
			CPU:      500,
			MemoryMB: 512,
			Networks: []*structs.NetworkResource{
				&structs.NetworkResource{
					ReservedPorts: []structs.Port{{"main", 22000}, {"web", 80}},
				},
			},
		},
	}

	driverCtx, execCtx := testDriverContexts(task)
	defer execCtx.AllocDir.Destroy()
	d := NewQemuDriver(driverCtx)

	handle, err := d.Start(execCtx, task)
	if err == nil {
		handle.Kill()
		t.Fatalf("Should've failed")
	}
	msg := "unknown user alice"
	if !strings.Contains(err.Error(), msg) {
		t.Fatalf("Expecting '%v' in '%v'", msg, err)
	}
}
開發者ID:achanda,項目名稱:nomad,代碼行數:43,代碼來源:qemu_test.go

示例8: TestQemuDriver_Fingerprint

// The fingerprinter test should always pass, even if QEMU is not installed.
func TestQemuDriver_Fingerprint(t *testing.T) {
	ctestutils.QemuCompatible(t)
	d := NewQemuDriver(testDriverContext(""))
	node := &structs.Node{
		Attributes: make(map[string]string),
	}
	apply, err := d.Fingerprint(&config.Config{}, node)
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if !apply {
		t.Fatalf("should apply")
	}
	if node.Attributes["driver.qemu"] == "" {
		t.Fatalf("Missing Qemu driver")
	}
	if node.Attributes["driver.qemu.version"] == "" {
		t.Fatalf("Missing Qemu driver version")
	}
}
開發者ID:ranjib,項目名稱:nomad,代碼行數:21,代碼來源:qemu_test.go


注:本文中的github.com/hashicorp/nomad/client/testutil.QemuCompatible函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。