Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade go mod #9115

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cd-dgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
go-version: ${{ env.GOVERSION }}
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
with:
go-version: ${{ env.GOVERSION }}
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci-dgraph-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Make Linux Build and Docker Image with coverage enabled
run: make coverage-docker-image
- name: Build Test Binary
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci-dgraph-ldbc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Make Linux Build and Docker Image
run: make docker-image
- name: Build Test Binary
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci-dgraph-load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Make Linux Build and Docker Image
run: make docker-image # this internally builds dgraph binary
- name: Build Test Binary
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ci-dgraph-tests-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ci-dgraph-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install protobuf-compiler
run: sudo apt-get install -y protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
Expand Down
74 changes: 13 additions & 61 deletions dgraphtest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (c *LocalCluster) destroyContainers() error {
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
defer cancel()

ro := types.ContainerRemoveOptions{RemoveVolumes: true, Force: true}
ro := container.RemoveOptions{RemoveVolumes: true, Force: true}
for _, zo := range c.zeros {
if err := c.dcli.ContainerRemove(ctx, zo.cid(), ro); err != nil {
return errors.Wrapf(err, "error removing zero [%v]", zo.cname())
Expand All @@ -284,38 +284,21 @@ func (c *LocalCluster) destroyContainers() error {
return nil
}

// CheckRunningServices checks open ports using lsof and returns the output as a string
func CheckRunningServices() (string, error) {
lsofCmd := exec.Command("lsof", "-i", "-n")
output, err := runCommand(lsofCmd)
func (c *LocalCluster) printPortMappings() error {
containers, err := c.dcli.ContainerList(context.Background(), container.ListOptions{})
if err != nil {
return "", fmt.Errorf("error running lsof command: %v", err)
}
return output, nil
}

// ListRunningContainers lists running Docker containers using the Docker Go client
func (c *LocalCluster) listRunningContainers() (string, error) {
containers, err := c.dcli.ContainerList(context.Background(), types.ContainerListOptions{})
if err != nil {
return "", fmt.Errorf("error listing Docker containers: %v", err)
return errors.Wrap(err, "error listing docker containers")
}

var result bytes.Buffer
for _, container := range containers {
result.WriteString(fmt.Sprintf("ID: %s, Image: %s, Command: %s, Status: %s\n",
container.ID[:10], container.Image, container.Command, container.Status))

result.WriteString("Port Mappings:\n")
for _, port := range container.Ports {
result.WriteString(fmt.Sprintf(" %s:%d -> %d\n", port.IP, port.PublicPort, port.PrivatePort))
}
result.WriteString("\n")

result.WriteString("Port Mappings:\n")
info, err := c.dcli.ContainerInspect(context.Background(), container.ID)
if err != nil {
return "", errors.Wrap(err, "error inspecting container")
return errors.Wrapf(err, "error inspecting container [%v]", container.ID)
}

for port, bindings := range info.NetworkSettings.Ports {
Expand All @@ -327,42 +310,9 @@ func (c *LocalCluster) listRunningContainers() (string, error) {
result.WriteString("\n")
}

return result.String(), nil
}

// runCommand executes a command and returns its output or an error
func runCommand(cmd *exec.Cmd) (string, error) {
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return "", fmt.Errorf("%v: %v", err, stderr.String())
}
return out.String(), nil
}

func (c *LocalCluster) printNetworkStuff() {
log.Printf("Checking running services and ports using lsof, netstat, and Docker...\n")

// Check running services using lsof
lsofOutput, err := CheckRunningServices()
if err != nil {
fmt.Printf("Error checking running services: %v\n", err)
} else {
log.Printf("Output of lsof -i:")
log.Println(lsofOutput)
}

// List running Docker containers
dockerOutput, err := c.listRunningContainers()
if err != nil {
fmt.Printf("Error listing Docker containers: %v\n", err)
} else {
log.Printf("Running Docker containers:")
log.Println(dockerOutput)
}
log.Printf("[INFO] ======== CONTAINERS' PORT MAPPINGS ========")
log.Println(result.String())
return nil
}

func (c *LocalCluster) Cleanup(verbose bool) {
Expand All @@ -377,6 +327,9 @@ func (c *LocalCluster) Cleanup(verbose bool) {
if err := c.printInspectContainers(); err != nil {
log.Printf("[WARNING] error printing inspect container output: %v", err)
}
if err := c.printPortMappings(); err != nil {
log.Printf("[WARNING] error printing port mappings: %v", err)
}
}

log.Printf("[INFO] cleaning up cluster with prefix [%v]", c.conf.prefix)
Expand Down Expand Up @@ -489,7 +442,7 @@ func (c *LocalCluster) StartAlpha(id int) error {
func (c *LocalCluster) startContainer(dc dnode) error {
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
defer cancel()
if err := c.dcli.ContainerStart(ctx, dc.cid(), types.ContainerStartOptions{}); err != nil {
if err := c.dcli.ContainerStart(ctx, dc.cid(), container.StartOptions{}); err != nil {
return errors.Wrapf(err, "error starting container [%v]", dc.cname())
}
dc.changeStatus(true)
Expand Down Expand Up @@ -641,7 +594,6 @@ func (c *LocalCluster) containerHealthCheck(url func(c *LocalCluster) (string, e
return nil
}

c.printNetworkStuff()
return fmt.Errorf("health failed, cluster took too long to come up [%v]", endpoint)
}

Expand Down Expand Up @@ -1044,7 +996,7 @@ func (c *LocalCluster) getLogs(containerID string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
defer cancel()

opts := types.ContainerLogsOptions{
opts := container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Details: true,
Expand Down
3 changes: 2 additions & 1 deletion edgraph/access_ee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ func TestGetRefreshJwt(t *testing.T) {
}

func TestMain(m *testing.M) {
worker.Config.AclJwtAlg = jwt.SigningMethodHS256
x.WorkerConfig.AclJwtAlg = jwt.SigningMethodHS256
x.WorkerConfig.AclPublicKey = x.Sensitive("6ABBAA2014CFF00289D20D20DA296F67")

worker.Config.AccessJwtTtl = 20 * time.Second
worker.Config.RefreshJwtTtl = 20 * time.Second
worker.Config.AclSecretKey = x.Sensitive("6ABBAA2014CFF00289D20D20DA296F67")
m.Run()
}
Loading