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

fix(CI): fix test suite and add CI steps #1808

Merged
merged 25 commits into from
Oct 13, 2022
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
36 changes: 36 additions & 0 deletions .github/workflows/ci-badger-bank-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci-badger-bank-tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "*/30 * * * *"
jobs:
badger-bank:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Go Version
run: |
#!/bin/bash
DEFAULT_VERSION="1.18"
GOVERSION=$({ [ -f .go-version ] && cat .go-version; } || echo $DEFAULT_VERSION)
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
run: make dependency
- name: Install jemalloc
run: make jemalloc
- name: Install Badger
run: cd badger && go install --race --tags=jemalloc .
- name: Run Badger Bank Test
run: |
#!/bin/bash
mkdir bank && cd bank
badger bank test -v --dir=. -d=20m
29 changes: 29 additions & 0 deletions .github/workflows/ci-badger-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci-badger-tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "*/30 * * * *"
jobs:
badger-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Go Version
run: |
#!/bin/bash
DEFAULT_VERSION="1.18"
GOVERSION=$({ [ -f .go-version ] && cat .go-version; } || echo $DEFAULT_VERSION)
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVERSION }}
- name: Install Dependencies
run: make dependency
- name: Run Badger Tests
run: make test
27 changes: 27 additions & 0 deletions .github/workflows/ci-golang-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci-golang-lint
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "*/30 * * * *"
jobs:
go-lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golang-lint
env:
# prevent OOM
GOGC: 10
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.36
only-new-issues: true
args: --timeout=10m
skip-go-installation: true
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.18
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright 2022 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

USER_ID = $(shell id -u)
HAS_JEMALLOC = $(shell test -f /usr/local/lib/libjemalloc.a && echo "jemalloc")
JEMALLOC_URL = "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2"


.PHONY: all test jemalloc dependency

test: jemalloc
@echo "Running Badger tests..."
@./test.sh

jemalloc:
@if [ -z "$(HAS_JEMALLOC)" ] ; then \
mkdir -p /tmp/jemalloc-temp && cd /tmp/jemalloc-temp ; \
echo "Downloading jemalloc..." ; \
curl -s -L ${JEMALLOC_URL} -o jemalloc.tar.bz2 ; \
tar xjf ./jemalloc.tar.bz2 ; \
cd jemalloc-5.2.1 ; \
./configure --with-jemalloc-prefix='je_' --with-malloc-conf='background_thread:true,metadata_thp:auto'; \
make ; \
if [ "$(USER_ID)" -eq "0" ]; then \
make install ; \
else \
echo "==== Need sudo access to install jemalloc" ; \
sudo make install ; \
fi \
fi

dependency:
@echo "Installing dependencies..."
@sudo apt-get update
@sudo apt-get -y upgrade
@sudo apt-get -y install \
ca-certificates \
curl \
gnupg \
lsb-release \
build-essential \
protobuf-compiler \
3 changes: 1 addition & 2 deletions pb/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
# Run this script from its directory, so that badgerpb2.proto is where it's expected to
# be.

# You might need to go get -v github.com/gogo/protobuf/...
go get -v github.com/gogo/protobuf/protoc-gen-gogofaster
go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
protoc --gogofaster_out=. --gogofaster_opt=paths=source_relative -I=. badgerpb3.proto
39 changes: 8 additions & 31 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,13 @@ go version
# export packages because the test will run in a sub process.
export packages=$(go list ./... | grep "github.com/dgraph-io/badger/v3/")

if [[ ! -z "$TEAMCITY_VERSION" ]]; then
export GOFLAGS="-json"
fi

function InstallJemalloc() {
pushd .
if [ ! -f /usr/local/lib/libjemalloc.a ]; then
USER_ID=`id -u`
JEMALLOC_URL="https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2"

mkdir -p /tmp/jemalloc-temp && cd /tmp/jemalloc-temp ;
echo "Downloading jemalloc" ;
curl -s -L ${JEMALLOC_URL} -o jemalloc.tar.bz2 ;
tar xjf ./jemalloc.tar.bz2 ;
cd jemalloc-5.2.1 ;
./configure --with-jemalloc-prefix='je_' ;
make ;
if [ "$USER_ID" -eq "0" ]; then
make install ;
else
echo "==== Need sudo access to install jemalloc" ;
sudo make install ;
fi
fi
popd
}

tags="-tags=jemalloc"

# Ensure that we can compile the binary.
pushd badger
go build -v $tags .
popd

# tags=""
InstallJemalloc

# Run the memory intensive tests first.
manual() {
timeout="-timeout 2m"
Expand Down Expand Up @@ -110,11 +80,18 @@ stream() {
return 1
fi
echo "==> DONE stream test"
popd
return 0
}

export -f stream
export -f manual
export -f root

parallel --halt now,fail=1 --progress --line-buffer ::: stream manual root
# parallel tests currently not working
# parallel --halt now,fail=1 --progress --line-buffer ::: stream manual root

# run tests in sequence
root
stream
manual