-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement basic support for Neo4j container Fixes #921 * Qualify image name * Add minimal documentation
- Loading branch information
Showing
11 changed files
with
689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Neo4j module pipeline | ||
|
||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test-neo4j: | ||
strategy: | ||
matrix: | ||
go-version: [1.19.x, 1.x] | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: modVerify | ||
working-directory: ./modules/neo4j | ||
run: go mod verify | ||
|
||
- name: modTidy | ||
working-directory: ./modules/neo4j | ||
run: make tools-tidy | ||
|
||
- name: gotestsum | ||
working-directory: ./modules/neo4j | ||
run: make test-unit | ||
|
||
- name: Run checker | ||
run: | | ||
./scripts/check_environment.sh | ||
- name: Test Summary | ||
uses: test-summary/action@4ee9ece4bca777a38f05c8fc578ac2007fe266f7 | ||
with: | ||
paths: "**/TEST-neo4j*.xml" | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Neo4j | ||
|
||
The Testcontainers module for [Neo4j](https://neo4j.com/), the leading graph platform. | ||
|
||
## Adding this module to your project dependencies | ||
|
||
Please run the following command to add the LocalStack module to your Go dependencies: | ||
|
||
``` | ||
go get github.com/testcontainers/testcontainers-go/modules/neo4j | ||
``` | ||
|
||
## Usage example | ||
|
||
Running Neo4j as a single-instance server, with the [APOC plugin](https://neo4j.com/developer/neo4j-apoc/) enabled: | ||
|
||
<!--codeinclude--> | ||
[Creating a Neo4j container](../../modules/neo4j/neo4j_test.go) inside_block:neo4jCreateContainer | ||
<!--/codeinclude--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include ../../commons-test.mk | ||
|
||
.PHONY: test | ||
test: | ||
$(MAKE) test-neo4j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package neo4j | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type Option func(*config) | ||
|
||
type config struct { | ||
imageCoordinates string | ||
adminPassword string | ||
labsPlugins []string | ||
} | ||
|
||
type LabsPlugin string | ||
|
||
const ( | ||
Apoc LabsPlugin = "apoc" | ||
ApocCore LabsPlugin = "apoc-core" | ||
Bloom LabsPlugin = "bloom" | ||
GraphDataScience LabsPlugin = "graph-data-science" | ||
NeoSemantics LabsPlugin = "n10s" | ||
Streams LabsPlugin = "streams" | ||
) | ||
|
||
// WithoutAuthentication disables authentication. | ||
func WithoutAuthentication() Option { | ||
return WithAdminPassword("") | ||
} | ||
|
||
// WithAdminPassword sets the admin password for the default account | ||
// An empty string disables authentication. | ||
// The default password is "password". | ||
func WithAdminPassword(adminPassword string) Option { | ||
return func(c *config) { | ||
c.adminPassword = adminPassword | ||
} | ||
} | ||
|
||
// WithImageCoordinates sets the image coordinates of the Neo4j container. | ||
func WithImageCoordinates(imageCoordinates string) Option { | ||
return func(c *config) { | ||
c.imageCoordinates = imageCoordinates | ||
} | ||
} | ||
|
||
// WithLabsPlugin registers one or more Neo4jLabsPlugin for download and server startup. | ||
// There might be plugins not supported by your selected version of Neo4j. | ||
func WithLabsPlugin(plugins ...LabsPlugin) Option { | ||
return func(c *config) { | ||
rawPluginValues := make([]string, len(plugins)) | ||
for i := 0; i < len(plugins); i++ { | ||
rawPluginValues[i] = string(plugins[i]) | ||
} | ||
c.labsPlugins = rawPluginValues | ||
} | ||
} | ||
|
||
func (c config) exportEnv() map[string]string { | ||
env := make(map[string]string) | ||
env["NEO4J_AUTH"] = c.authEnvVar() | ||
if len(c.labsPlugins) > 0 { | ||
env["NEO4JLABS_PLUGINS"] = c.labsPluginsEnvVar() | ||
} | ||
return env | ||
} | ||
|
||
func (c config) authEnvVar() string { | ||
if c.adminPassword == "" { | ||
return "none" | ||
} | ||
return fmt.Sprintf("neo4j/%s", c.adminPassword) | ||
} | ||
|
||
func (c config) labsPluginsEnvVar() string { | ||
return fmt.Sprintf(`["%s"]`, strings.Join(c.labsPlugins, `","`)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module github.com/testcontainers/testcontainers-go/modules/neo4j | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/docker/go-connections v0.4.0 | ||
github.com/neo4j/neo4j-go-driver/v5 v5.6.0 | ||
github.com/stretchr/testify v1.8.2 | ||
github.com/testcontainers/testcontainers-go v0.19.0 | ||
gotest.tools/gotestsum v1.9.0 | ||
) | ||
|
||
require ( | ||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | ||
github.com/Microsoft/go-winio v0.5.2 // indirect | ||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect | ||
github.com/containerd/containerd v1.6.19 // indirect | ||
github.com/cpuguy83/dockercfg v0.3.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/dnephin/pflag v1.0.7 // indirect | ||
github.com/docker/distribution v2.8.1+incompatible // indirect | ||
github.com/docker/docker v23.0.1+incompatible // indirect | ||
github.com/docker/go-units v0.5.0 // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/fsnotify/fsnotify v1.5.4 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/klauspost/compress v1.15.9 // indirect | ||
github.com/magiconair/properties v1.8.7 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
github.com/moby/patternmatcher v0.5.0 // indirect | ||
github.com/moby/sys/sequential v0.5.0 // indirect | ||
github.com/moby/term v0.0.0-20221128092401-c43b287e0e0f // indirect | ||
github.com/morikuni/aec v1.0.0 // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect | ||
github.com/opencontainers/runc v1.1.3 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/sirupsen/logrus v1.9.0 // indirect | ||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect | ||
golang.org/x/net v0.7.0 // indirect | ||
golang.org/x/sync v0.1.0 // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
golang.org/x/term v0.5.0 // indirect | ||
golang.org/x/tools v0.1.12 // indirect | ||
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect | ||
google.golang.org/grpc v1.47.0 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
gotest.tools/v3 v3.4.0 // indirect | ||
) | ||
|
||
replace github.com/testcontainers/testcontainers-go => ../.. |
Oops, something went wrong.