MCPcopy
hub / github.com/moby/moby / TestCreateWithCustomMACs

Function TestCreateWithCustomMACs

integration/container/create_test.go:763–800  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

761}
762
763func TestCreateWithCustomMACs(t *testing.T) {
764 skip.If(t, testEnv.DaemonInfo.OSType == "windows")
765 skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.44"), "requires API v1.44")
766
767 ctx := setupTest(t)
768 apiClient := testEnv.APIClient()
769
770 net.CreateNoError(ctx, t, apiClient, "testnet")
771
772 attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
773 defer cancel()
774 res := testContainer.RunAttach(attachCtx, t, apiClient,
775 testContainer.WithCmd("ip", "-o", "link", "show"),
776 testContainer.WithNetworkMode("bridge"),
777 testContainer.WithMacAddress("bridge", "02:32:1c:23:00:04"))
778
779 assert.Equal(t, res.ExitCode, 0)
780 assert.Equal(t, res.Stderr.String(), "")
781
782 scanner := bufio.NewScanner(res.Stdout)
783 for scanner.Scan() {
784 fields := strings.Fields(scanner.Text())
785 // The expected output is:
786 // 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
787 // 134: eth0@if135: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1400 qdisc noqueue \ link/ether 02:42:ac:11:00:04 brd ff:ff:ff:ff:ff:ff
788 if len(fields) < 11 {
789 continue
790 }
791
792 ifaceName := fields[1]
793 if ifaceName[:3] != "eth" {
794 continue
795 }
796
797 mac := fields[len(fields)-3]
798 assert.Equal(t, mac, "02:32:1c:23:00:04")
799 }
800}
801
802// Tests that when using containerd backed storage the containerd container has the image referenced stored.
803func TestContainerdContainerImageInfo(t *testing.T) {

Callers

nothing calls this directly

Calls 7

DaemonAPIVersionMethod · 0.80
APIClientMethod · 0.80
WithTimeoutMethod · 0.80
EqualMethod · 0.80
setupTestFunction · 0.70
StringMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…