MCPcopy Create free account
hub / github.com/encodeous/nylon / StartNode

Method StartNode

e2e/harness.go:135–191  ·  view source on GitHub ↗
(name string, ip string, centralConfigPath, nodeConfigPath string, extraArgs ...string)

Source from the content-addressed store, hash-verified

133 wg.Wait()
134}
135func (h *Harness) StartNode(name string, ip string, centralConfigPath, nodeConfigPath string, extraArgs ...string) testcontainers.Container {
136 h.t.Logf("Starting node %s at %s", name, ip)
137 req := testcontainers.ContainerRequest{
138 Image: ImageName,
139 Networks: []string{h.Network.Name},
140 NetworkAliases: map[string][]string{
141 h.Network.Name: {name},
142 },
143 Files: []testcontainers.ContainerFile{
144 {
145 HostFilePath: centralConfigPath,
146 ContainerFilePath: "/app/config/central.yaml",
147 FileMode: 0644,
148 },
149 {
150 HostFilePath: nodeConfigPath,
151 ContainerFilePath: "/app/config/node.yaml",
152 FileMode: 0644,
153 },
154 },
155 Cmd: extraArgs,
156 Env: map[string]string{
157 "NYLON_LOG_LEVEL": "debug",
158 },
159 WaitingFor: wait.ForLog("Nylon has been initialized").WithStartupTimeout(30 * time.Second),
160 HostConfigModifier: func(hostConfig *container.HostConfig) {
161 hostConfig.Privileged = true
162 hostConfig.CapAdd = []string{"NET_ADMIN"}
163 },
164 EndpointSettingsModifier: func(m map[string]*network.EndpointSettings) {
165 if ip != "" {
166 if s, ok := m[h.Network.Name]; ok {
167 s.IPAMConfig = &network.EndpointIPAMConfig{
168 IPv4Address: netip.MustParseAddr(ip),
169 }
170 }
171 }
172 },
173 LogConsumerCfg: &testcontainers.LogConsumerConfig{
174 Consumers: []testcontainers.LogConsumer{
175 &UnifiedLogConsumer{Node: name, Manager: h.LogManager},
176 },
177 },
178 Name: h.t.Name() + "-" + name,
179 }
180 cont, err := testcontainers.GenericContainer(h.ctx, testcontainers.GenericContainerRequest{
181 ContainerRequest: req,
182 Started: true,
183 })
184 if err != nil {
185 h.t.Fatalf("failed to start container %s: %v", name, err)
186 }
187 h.mu.Lock()
188 h.Nodes[name] = cont
189 h.mu.Unlock()
190 return cont
191}
192

Callers 3

StartNodesMethod · 0.95
TestEndpointResolutionFunction · 0.95
TestDynamicResolutionFunction · 0.95

Calls 1

NameMethod · 0.65

Tested by 2

TestEndpointResolutionFunction · 0.76
TestDynamicResolutionFunction · 0.76