-
Notifications
You must be signed in to change notification settings - Fork 7
Updated Couchbase version within the tests
#1587
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
Open
danielfeismann
wants to merge
8
commits into
dev
Choose a base branch
from
df/#1586-bum-couchbase-version-in-tests
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd8b1cc
Updated `Couchbase` version within the tests
danielfeismann b9c9bbc
Merge branch 'dev' into df/#1586-bum-couchbase-version-in-tests
sebastian-peter d6975e7
include feedback from review
danielfeismann d49ac44
Merge branch 'dev' into df/#1586-bum-couchbase-version-in-tests
danielfeismann 75eb5ac
build gradle
danielfeismann ef3739b
abstract couchbase test setup
danielfeismann d657cee
Merge branch 'dev' into df/#1586-bum-couchbase-version-in-tests
danielfeismann 56038d5
include feedback from review
danielfeismann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
115 changes: 115 additions & 0 deletions
115
...test/groovy/edu/ie3/datamodel/io/source/couchbase/AbstractCouchbaseWeatherSourceIT.groovy
This file contains hidden or 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,115 @@ | ||
| /* | ||
| * © 2026. TU Dortmund University, | ||
| * Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
| * Research group Distribution grid planning and operation | ||
| */ | ||
| package edu.ie3.datamodel.io.source.couchbase | ||
|
|
||
| import edu.ie3.datamodel.io.connectors.CouchbaseConnector | ||
| import edu.ie3.test.helper.TestContainerHelper | ||
| import edu.ie3.test.helper.WeatherSourceTestHelper | ||
| import groovy.json.JsonSlurper | ||
| import org.testcontainers.couchbase.BucketDefinition | ||
| import org.testcontainers.couchbase.CouchbaseContainer | ||
| import org.testcontainers.spock.Testcontainers | ||
| import spock.lang.Shared | ||
| import spock.lang.Specification | ||
|
|
||
| import java.time.Duration | ||
|
|
||
| @Testcontainers | ||
| abstract class AbstractCouchbaseWeatherSourceIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper { | ||
|
|
||
| @Shared | ||
| BucketDefinition bucketDefinition = new BucketDefinition("ie3_in") | ||
|
|
||
| @Shared | ||
| CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:8.0.0") | ||
| .withBucket(bucketDefinition) | ||
| .withExposedPorts(8091, 8092, 8093, 8094, 11210) | ||
| .withStartupAttempts(3) | ||
|
|
||
| @Shared | ||
| CouchbaseWeatherSource source | ||
|
|
||
| static String coordinateIdColumnName = "coordinateid" | ||
|
|
||
| abstract String getJsonResourcePath() | ||
| abstract Object getWeatherFactory() | ||
| abstract Object getCoordinateSource() | ||
| String getDtfPattern() { | ||
| return "yyyy-MM-dd'T'HH:mm:ssxxx" | ||
| } | ||
|
|
||
| def setupSpec() { | ||
| // create an index for the document keys | ||
| couchbaseContainer.execInContainer("cbq", | ||
| "-e", "http://localhost:8093", | ||
| "-u", couchbaseContainer.username, | ||
| "-p", couchbaseContainer.password, | ||
| "-s", "CREATE index id_idx ON `" + bucketDefinition.name + "` (META().id);") | ||
|
|
||
| // Create connector to import the data from json document | ||
| def connector = new CouchbaseConnector( | ||
| couchbaseContainer.connectionString, | ||
| bucketDefinition.name, | ||
| couchbaseContainer.username, | ||
| couchbaseContainer.password, | ||
| Duration.ofSeconds(30)) | ||
|
|
||
| // Wait for bucket to be ready | ||
| println "Waiting for Couchbase bucket to be ready..." | ||
| int maxTries = 10 | ||
| boolean ready = false | ||
| for (int i = 0; i < maxTries; i++) { | ||
| try { | ||
| connector.getSourceFields() | ||
| ready = true | ||
| println "Couchbase bucket ready" | ||
| break | ||
| } catch (Exception ignored) { | ||
| if (i % 10 == 0) { | ||
| println "Waiting for bucket... (try ${i+1})" | ||
| } | ||
| sleep(1000) | ||
| } | ||
| } | ||
|
|
||
| if (!ready) { | ||
| println "Couchbase bucket did not become ready in time!" | ||
| System.out.flush() | ||
| throw new RuntimeException("Couchbase bucket did not become ready in time!") | ||
| } | ||
|
|
||
| // Insert test data from JSON file | ||
| println "Inserting test data from JSON file..." | ||
| def jsonFile = new File(getJsonResourcePath()) | ||
| def jsonSlurper = new JsonSlurper() | ||
| def weatherDocs = jsonSlurper.parse(jsonFile) as List | ||
| def insertCount = 0 | ||
| weatherDocs.each { doc -> | ||
| try { | ||
| def coordinateId = doc[coordinateIdColumnName] | ||
| def time = doc["time"] | ||
| def key = "weather::${coordinateId}::${time}" | ||
| connector.persist(key, doc).join() | ||
| insertCount++ | ||
| } catch (Exception ex) { | ||
| println "WARNING: Failed to insert document for coordinateid ${doc[coordinateIdColumnName]} and time ${doc["time"]}: ${ex.message}" | ||
| } | ||
| } | ||
| println "Inserted ${insertCount}/${weatherDocs.size()} test documents from JSON file" | ||
|
|
||
| source = new CouchbaseWeatherSource(connector, getCoordinateSource(), coordinateIdColumnName, getWeatherFactory(), getDtfPattern()) | ||
| println "setupSpec completed" | ||
| System.out.flush() | ||
| } | ||
|
|
||
| def "The test container can establish a valid connection"() { | ||
| when: | ||
| def connector = new CouchbaseConnector(couchbaseContainer.connectionString, bucketDefinition.name, couchbaseContainer.username, couchbaseContainer.password) | ||
|
|
||
| then: | ||
| connector.connectionValid | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.