Skip to content

Commit 025ff61

Browse files
committed
Init...
1 parent 801ec48 commit 025ff61

File tree

300 files changed

+172527
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+172527
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea

Gopkg.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[prune]
29+
go-tests = true
30+
unused-packages = true

Makefile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
##################### CARAVELA's MAKEFILE #########################
2+
GOCMD=go
3+
4+
######### Builtin GO tools #########
5+
GOBUILD=$(GOCMD) build
6+
GOINSTALL=$(GOCMD) install
7+
GOCLEAN=$(GOCMD) clean
8+
GOTEST=$(GOCMD) test
9+
GOVET=$(GOCMD) vet
10+
11+
GOGET=$(GOCMD) get
12+
13+
######### External GO tools #########
14+
GOLINT=golint
15+
GOCOV=gocov
16+
GOCOVHTML=gocov-html
17+
GODEPGRAPH=godepgraph
18+
19+
############ Output Files ###########
20+
EXE=.exe
21+
BINARY_NAME=caravela$(EXE)
22+
BINARY_NAME_LINUX=$(BINARY_NAME)_linux$(EXE)
23+
BINARY_NAME_WIN=$(BINARY_NAME)_win$(EXE)
24+
25+
############################## COMMANDS ############################
26+
27+
all: test build
28+
29+
build:
30+
@echo Building for the current machine settings...
31+
$(GOBUILD) -o $(BINARY_NAME) -v
32+
33+
build-linux:
34+
@echo Building for linux...
35+
env GOOS=linux $(GOBUILD) -o $(BINARY_NAME) -v
36+
37+
build-windows:
38+
@echo Building for windows...
39+
env GOOS=windows $(GOBUILD) -o $(BINARY_NAME) -v
40+
41+
clean:
42+
@echo Cleaning project...
43+
$(GOCLEAN)
44+
rm -f $(BINARY_NAME)
45+
rm -f $(BINARY_NAME_LINUX)
46+
rm -f $(BINARY_NAME_WIN)
47+
48+
install:
49+
@echo Installing CARAVELA in the local GO environment...
50+
$(GOINSTALL) -v -gcflags "-N -l" .
51+
52+
test:
53+
@echo Testing...
54+
$(GOTEST) -v ./...
55+
56+
test-cov:
57+
@echo Testing and coverage report generation...
58+
$(GOCOV) test ./... | $(GOCOVHTML) > coverage.html
59+
60+
test-verify:
61+
$(MAKE) test
62+
@echo Running vet tool to static analyze the code
63+
$(GOVET) -v ./...
64+
@echo Running lint tool to static analyze the code style
65+
66+
dep-graph:
67+
@echo Generating package import dependency graph...
68+
$(GODEPGRAPH) -s -p github.com/docker github.com/strabox/caravela | dot -Tpng -o importsGraph.png
69+
70+
docker-build:
71+
@echo Building Docker container...
72+
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
73+
74+
docker-upload:
75+
@echo Building Docker container and uploading to DockerHub...
76+
docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest .
77+
docker push strabox/caravela:latest
78+
79+
install-external-tools:
80+
@echo Installing external tools...
81+
@echo Installing lint - Code style analyzer (from google)
82+
$(GOGET) github.com/golang/lint
83+
@echo Installing gocov - Code coverage generator
84+
$(GOGET) github.com/axw/gocov/gocov
85+
@echo Installing gocov-html - Code coverage html generator
86+
$(GOGET) -u gopkg.in/matm/v1/gocov-html
87+
@echo Installing godepgraph - Code package dependency graph generator
88+
$(GOGET) github.com/kisielk/godepgraph
89+

caravela/api_client_mock.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package caravela
2+
3+
import (
4+
"github.com/strabox/caravela/api/rest"
5+
"github.com/strabox/caravela/configuration"
6+
nodeAPI "github.com/strabox/caravela/node/api"
7+
)
8+
9+
type RemoteClientMock struct {
10+
// TODO
11+
}
12+
13+
func NewRemoteClientMock() *RemoteClientMock {
14+
return &RemoteClientMock{}
15+
}
16+
17+
func (mock *RemoteClientMock) CreateOffer(fromSupplierIP string, fromSupplierGUID string, toTraderIP string,
18+
toTraderGUID string, offerID int64, amount int, cpus int, ram int) error {
19+
// Do Nothing
20+
return nil
21+
}
22+
23+
func (mock *RemoteClientMock) RefreshOffer(toSupplierIP string, fromTraderGUID string, offerID int64) (bool, error) {
24+
// Do Nothing
25+
return false, nil
26+
}
27+
28+
func (mock *RemoteClientMock) RemoveOffer(fromSupplierIP string, fromSupplierGUID, toTraderIP string,
29+
toTraderGUID string, offerID int64) error {
30+
// Do Nothing
31+
return nil
32+
}
33+
34+
func (mock *RemoteClientMock) GetOffers(toTraderIP string, toTraderGUID string, relay bool,
35+
fromNodeGUID string) ([]nodeAPI.Offer, error) {
36+
// Do Nothing
37+
return nil, nil
38+
}
39+
40+
func (mock *RemoteClientMock) AdvertiseOffersNeighbor(toNeighborTraderIP string, toNeighborTraderGUID string,
41+
fromTraderGUID string, traderOfferingGUID string, traderOfferingIP string) error {
42+
// Do Nothing
43+
return nil
44+
}
45+
46+
func (mock *RemoteClientMock) LaunchContainer(toSupplierIP string, fromBuyerIP string, offerID int64, containerImageKey string,
47+
portMappings []rest.PortMapping, containerArgs []string, cpus int, ram int) error {
48+
// Do Nothing
49+
return nil
50+
}
51+
52+
func (mock *RemoteClientMock) ObtainConfiguration(systemsNodeIP string) (*configuration.Configuration, error) {
53+
// Do Nothing
54+
return nil, nil
55+
}

configuration.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[ImagesStorage]
2+
Backend = "DockerHub"
3+
4+
[Caravela]
5+
APIPort = 8001
6+
APITimeout = "5s"
7+
CheckContainersInterval = "30s"
8+
SupplyingInterval = "30s"
9+
SpreadOffersInterval = "30s"
10+
RefreshesCheckInterval = "30s"
11+
RefreshingInterval = "30s"
12+
MaxRefreshesFailed = 3
13+
MaxRefreshesMissed = 2
14+
RefreshMissedTimeout = "20s"
15+
ResourcesOvercommit = 50
16+
# Cpu Cores Partitions
17+
[[Caravela.CpuCoresPartitions]]
18+
Cores = 1
19+
Percentage = 50
20+
[[Caravela.CpuCoresPartitions]]
21+
Cores = 2
22+
Percentage = 50
23+
# Ram Partitions
24+
[[Caravela.RamPartitions]]
25+
Ram = 256
26+
Percentage = 50
27+
[[Caravela.RamPartitions]]
28+
Ram = 512
29+
Percentage = 50
30+
31+
[Overlay]
32+
OverlayPort = 8000
33+
ChordTimeout = "3s"
34+
ChordVirtualNodes = 12
35+
ChordNumSuccessors = 4
36+
ChordHashSizeBits = 128

docker/client_mock.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package docker
2+
3+
import (
4+
"github.com/strabox/caravela/api/rest"
5+
dockerAPI "github.com/strabox/caravela/docker"
6+
)
7+
8+
type ClientMock struct {
9+
// TODO
10+
}
11+
12+
func NewClientMock() *ClientMock {
13+
return &ClientMock{}
14+
}
15+
16+
func (cli *ClientMock) GetDockerCPUAndRAM() (int, int) {
17+
// TODO
18+
return 0, 0
19+
}
20+
21+
func (cli *ClientMock) CheckContainerStatus(containerID string) (dockerAPI.ContainerStatus, error) {
22+
// TODO
23+
return dockerAPI.NewContainerStatus(0), nil
24+
}
25+
26+
func (cli *ClientMock) RunContainer(imageKey string, portMappings []rest.PortMapping, args []string, cpus int64,
27+
ram int) (string, error) {
28+
// TODO
29+
return "", nil
30+
}
31+
32+
func (cli *ClientMock) RemoveContainer(containerID string) {
33+
// TODO
34+
return
35+
}

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("Caravela Simulator")
7+
}

overlay/chord_mock.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package overlay
2+
3+
import (
4+
nodeAPI "github.com/strabox/caravela/node/api"
5+
"github.com/strabox/caravela/overlay"
6+
)
7+
8+
type ChordMock struct {
9+
// TODO
10+
}
11+
12+
func NewChordMock() *ChordMock {
13+
return &ChordMock{}
14+
}
15+
16+
func (chord *ChordMock) Create(thisNode nodeAPI.OverlayMembership) error {
17+
// Do Nothing
18+
return nil
19+
}
20+
21+
func (chord *ChordMock) Join(overlayNodeIP string, overlayNodePort int, thisNode nodeAPI.OverlayMembership) error {
22+
// Do Nothing
23+
return nil
24+
}
25+
26+
func (chord *ChordMock) Lookup(key []byte) ([]*overlay.Node, error) {
27+
// Do Nothing
28+
return nil, nil
29+
}
30+
31+
func (chord *ChordMock) Neighbors(nodeID []byte) ([]*overlay.Node, error) {
32+
// Do Nothing
33+
return nil, nil
34+
}
35+
36+
func (chord *ChordMock) NodeID() ([]byte, error) {
37+
// Do Nothing
38+
return nil, nil
39+
}
40+
41+
func (chord *ChordMock) Leave() error {
42+
// Do Nothing
43+
return nil
44+
}

vendor/github.com/Sirupsen/logrus/.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)