mirror of https://github.com/docker/compose.git
Merge pull request #212 from rumpl/chore-remove-node
Remove node test, node-sdk has these tests
This commit is contained in:
commit
667cdfcbf8
|
@ -51,15 +51,6 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make -f builder.Makefile cli
|
run: make -f builder.Makefile cli
|
||||||
|
|
||||||
- name: Install Protoc
|
|
||||||
uses: arduino/setup-protoc@master
|
|
||||||
with:
|
|
||||||
version: "3.9.1"
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: "10.x"
|
|
||||||
|
|
||||||
- name: E2E Test
|
- name: E2E Test
|
||||||
run: make e2e-local
|
run: make e2e-local
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
node_modules
|
|
|
@ -1,20 +0,0 @@
|
||||||
node_modules/.bin/grpc_tools_node_protoc \
|
|
||||||
--js_out=import_style=commonjs,binary:./grpc \
|
|
||||||
--grpc_out=grpc_js:./grpc \
|
|
||||||
-I ../../protos/contexts/v1 \
|
|
||||||
-I ../../protos/containers/v1 \
|
|
||||||
-I ../../protos/streams/v1 \
|
|
||||||
../../protos/contexts/v1/*.proto \
|
|
||||||
../../protos/containers/v1/*.proto \
|
|
||||||
../../protos/streams/v1/*.proto
|
|
||||||
|
|
||||||
# generate d.ts codes
|
|
||||||
protoc \
|
|
||||||
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
|
|
||||||
--ts_out=generate_package_definition:./grpc \
|
|
||||||
-I ../../protos/contexts/v1 \
|
|
||||||
-I ../../protos/containers/v1 \
|
|
||||||
-I ../../protos/streams/v1 \
|
|
||||||
../../protos/contexts/v1/*.proto \
|
|
||||||
../../protos/containers/v1/*.proto \
|
|
||||||
../../protos/streams/v1/*.proto
|
|
|
@ -1,85 +0,0 @@
|
||||||
import * as grpc from "@grpc/grpc-js";
|
|
||||||
import * as readline from "readline";
|
|
||||||
import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb.js";
|
|
||||||
|
|
||||||
import * as continersPb from "./grpc/containers_grpc_pb";
|
|
||||||
import { IContainersClient } from "./grpc/containers_grpc_pb";
|
|
||||||
import { ExecRequest, ExecResponse, LogsRequest } from "./grpc/containers_pb";
|
|
||||||
|
|
||||||
import * as streamsPb from "./grpc/streams_grpc_pb";
|
|
||||||
import { IStreamingClient } from "./grpc/streams_grpc_pb";
|
|
||||||
import { BytesMessage } from "./grpc/streams_pb";
|
|
||||||
|
|
||||||
let address = process.argv[3] || "unix:///tmp/backend.sock";
|
|
||||||
|
|
||||||
const ContainersServiceClient = grpc.makeClientConstructor(
|
|
||||||
continersPb["com.docker.api.protos.containers.v1.Containers"],
|
|
||||||
"ContainersClient"
|
|
||||||
);
|
|
||||||
|
|
||||||
const client = (new ContainersServiceClient(
|
|
||||||
address,
|
|
||||||
grpc.credentials.createInsecure()
|
|
||||||
) as unknown) as IContainersClient;
|
|
||||||
|
|
||||||
const StreamsServiceClient = grpc.makeClientConstructor(
|
|
||||||
streamsPb["com.docker.api.protos.streams.v1.Streaming"],
|
|
||||||
"StreamsClient"
|
|
||||||
);
|
|
||||||
|
|
||||||
let streamClient = (new StreamsServiceClient(
|
|
||||||
address,
|
|
||||||
grpc.credentials.createInsecure()
|
|
||||||
) as unknown) as IStreamingClient;
|
|
||||||
|
|
||||||
let backend = process.argv[2] || "moby";
|
|
||||||
let containerId = process.argv[3];
|
|
||||||
const meta = new grpc.Metadata();
|
|
||||||
meta.set("CONTEXT_KEY", backend);
|
|
||||||
|
|
||||||
// Get the stream
|
|
||||||
const stream = streamClient.newStream();
|
|
||||||
|
|
||||||
stream.on("metadata", (m: grpc.Metadata) => {
|
|
||||||
let req = new ExecRequest();
|
|
||||||
req.setCommand("/bin/bash");
|
|
||||||
req.setStreamId(m.get("id")[0] as string);
|
|
||||||
req.setId(containerId);
|
|
||||||
req.setTty(true);
|
|
||||||
|
|
||||||
client.exec(req, meta, (err: any, _: ExecResponse) => {
|
|
||||||
if (err != null) {
|
|
||||||
console.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
process.exit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
readline.emitKeypressEvents(process.stdin);
|
|
||||||
process.stdin.setRawMode(true);
|
|
||||||
|
|
||||||
process.stdin.on("keypress", (str, key) => {
|
|
||||||
const mess = new BytesMessage();
|
|
||||||
const a = new Uint8Array(key.sequence.length);
|
|
||||||
for (let i = 0; i <= key.sequence.length; i++) {
|
|
||||||
a[i] = key.sequence.charCodeAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
mess.setValue(a);
|
|
||||||
|
|
||||||
const any = new google_protobuf_any_pb.Any();
|
|
||||||
any.pack(
|
|
||||||
mess.serializeBinary(),
|
|
||||||
"type.googleapis.com/com.docker.api.protos.streams.v1.BytesMessage"
|
|
||||||
);
|
|
||||||
stream.write(any);
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.on("data", (chunk: any) => {
|
|
||||||
const m = chunk.unpack(
|
|
||||||
BytesMessage.deserializeBinary,
|
|
||||||
"com.docker.api.protos.streams.v1.BytesMessage"
|
|
||||||
) as BytesMessage;
|
|
||||||
process.stdout.write(m.getValue());
|
|
||||||
});
|
|
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
|
@ -1,30 +0,0 @@
|
||||||
import * as grpc from "@grpc/grpc-js";
|
|
||||||
import { ContainersClient } from "./grpc/containers_grpc_pb";
|
|
||||||
import { ContextsClient } from "./grpc/contexts_grpc_pb";
|
|
||||||
import { ListRequest, ListResponse } from "./grpc/containers_pb";
|
|
||||||
import { SetCurrentRequest } from "./grpc/contexts_pb";
|
|
||||||
|
|
||||||
let address = process.argv[3] || "unix:///tmp/backend.sock";
|
|
||||||
|
|
||||||
const client = new ContainersClient(address, grpc.credentials.createInsecure());
|
|
||||||
const contextsClient = new ContextsClient(
|
|
||||||
address,
|
|
||||||
grpc.credentials.createInsecure()
|
|
||||||
);
|
|
||||||
|
|
||||||
let backend = process.argv[2] || "moby";
|
|
||||||
|
|
||||||
contextsClient.setCurrent(new SetCurrentRequest().setName(backend), () => {
|
|
||||||
client.list(new ListRequest(), (err: any, response: ListResponse) => {
|
|
||||||
if (err != null) {
|
|
||||||
console.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const containers = response.getContainersList();
|
|
||||||
|
|
||||||
containers.forEach((container) => {
|
|
||||||
console.log(container.getId(), container.getImage());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ts-test-api",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "index.js",
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"start": "ts-node -O '{\"module\": \"CommonJS\"}' index.ts",
|
|
||||||
"prestart": "./build.sh"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@grpc/grpc-js": "^1.0.5",
|
|
||||||
"google-protobuf": "^3.12.2",
|
|
||||||
"grpc": "^1.24.3",
|
|
||||||
"grpc-tools": "^1.9.0",
|
|
||||||
"grpc_tools_node_protoc_ts": "^4.0.0",
|
|
||||||
"readline": "^1.3.0",
|
|
||||||
"ts-node": "^8.10.2",
|
|
||||||
"typescript": "^3.9.5"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
declare module "google-protobuf/google/protobuf/any_pb.js";
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,11 +28,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -80,49 +77,6 @@ RUN sleep 100`), 0644)).To(Succeed())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NonWinCIE2eSuite) TestAPIServer() {
|
|
||||||
_, err := exec.LookPath("yarn")
|
|
||||||
if err != nil || os.Getenv("SKIP_NODE") != "" {
|
|
||||||
s.T().Skip("skipping, yarn not installed")
|
|
||||||
}
|
|
||||||
It("can run 'serve' command", func() {
|
|
||||||
cName := "test-example"
|
|
||||||
s.NewDockerCommand("context", "create", cName, "example").ExecOrDie()
|
|
||||||
|
|
||||||
//sPath := fmt.Sprintf("unix:///%s/docker.sock", s.ConfigDir)
|
|
||||||
sPath, cliAddress := s.getGrpcServerAndCLientAddress()
|
|
||||||
server, err := serveAPI(s.ConfigDir, sPath)
|
|
||||||
Expect(err).To(BeNil())
|
|
||||||
defer killProcess(server)
|
|
||||||
|
|
||||||
s.NewCommand("yarn", "install").WithinDirectory("../node-client").ExecOrDie()
|
|
||||||
output := s.NewCommand("yarn", "run", "start", cName, cliAddress).WithinDirectory("../node-client").ExecOrDie()
|
|
||||||
Expect(output).To(ContainSubstring("nginx"))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *NonWinCIE2eSuite) getGrpcServerAndCLientAddress() (string, string) {
|
|
||||||
if IsWindows() {
|
|
||||||
return "npipe:////./pipe/clibackend", "unix:////./pipe/clibackend"
|
|
||||||
}
|
|
||||||
socketName := fmt.Sprintf("unix:///%s/docker.sock", s.ConfigDir)
|
|
||||||
return socketName, socketName
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNonWinCIE2(t *testing.T) {
|
func TestNonWinCIE2(t *testing.T) {
|
||||||
suite.Run(t, new(NonWinCIE2eSuite))
|
suite.Run(t, new(NonWinCIE2eSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func killProcess(process *os.Process) {
|
|
||||||
err := process.Kill()
|
|
||||||
Expect(err).To(BeNil())
|
|
||||||
}
|
|
||||||
|
|
||||||
func serveAPI(configDir string, address string) (*os.Process, error) {
|
|
||||||
cmd := exec.Command("../../bin/docker", "--config", configDir, "serve", "--address", address)
|
|
||||||
err := cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return cmd.Process, nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue