Skip to content

Commit 5e1da8e

Browse files
Merge pull request #155 from openbase/bugfix/154-colorstate-comparison-fails-when-comparing-with-null-values
Bugfix/154 colorstate comparison fails when comparing with null values
2 parents f830380 + 356119a commit 5e1da8e

27 files changed

Lines changed: 915 additions & 214 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 168 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,66 @@ jobs:
9191
path: "**/build/reports"
9292

9393

94-
test:
95-
name: "Test"
96-
timeout-minutes: 120
94+
test_registry_unit:
95+
name: "Test Registry Unit"
9796
needs: build
98-
if: |
99-
(github.event.pull_request.draft == false)
100-
&& (needs.check.outputs.testing_needed == 'true')
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: "Checkout Branch"
100+
uses: actions/checkout@v4
101+
102+
- name: "Setup Java"
103+
uses: actions/setup-java@v4
104+
with:
105+
distribution: 'temurin'
106+
java-version: 21
107+
cache: 'gradle'
101108

109+
- name: Setup Gradle cache
110+
uses: actions/cache@v4
111+
with:
112+
path: ~/.gradle
113+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
114+
115+
- name: "Prepare libs for tests"
116+
run: ./prepare.sh
117+
118+
- name: "Run Tests"
119+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.registry.unit.test:check
120+
121+
122+
test_registry_message:
123+
name: "Test Registry Message"
124+
needs: build
102125
runs-on: ubuntu-latest
126+
steps:
127+
- name: "Checkout Branch"
128+
uses: actions/checkout@v4
129+
130+
- name: "Setup Java"
131+
uses: actions/setup-java@v4
132+
with:
133+
distribution: 'temurin'
134+
java-version: 21
135+
cache: 'gradle'
103136

137+
- name: Setup Gradle cache
138+
uses: actions/cache@v4
139+
with:
140+
path: ~/.gradle
141+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
142+
143+
- name: "Prepare libs for tests"
144+
run: ./prepare.sh
145+
146+
- name: "Run Tests"
147+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.registry.message.test:check
148+
149+
150+
test_registry_class:
151+
name: "Test Registry Class"
152+
needs: build
153+
runs-on: ubuntu-latest
104154
steps:
105155
- name: "Checkout Branch"
106156
uses: actions/checkout@v4
@@ -118,16 +168,120 @@ jobs:
118168
path: ~/.gradle
119169
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
120170

121-
- name: "prepare libs for tests"
171+
- name: "Prepare libs for tests"
122172
run: ./prepare.sh
123173

124-
- name: "test backend"
125-
run: ./gradlew --build-cache check
174+
- name: "Run Tests"
175+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.registry.class.test:check
126176

127-
- name: Upload test reports
128-
uses: actions/upload-artifact@v4
129-
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'force reports') }}
177+
178+
test_authentication:
179+
name: "Test Authentication"
180+
needs: build
181+
runs-on: ubuntu-latest
182+
steps:
183+
- name: "Checkout Branch"
184+
uses: actions/checkout@v4
185+
186+
- name: "Setup Java"
187+
uses: actions/setup-java@v4
130188
with:
131-
name: Test Reports
132-
path: "**/build/reports"
189+
distribution: 'temurin'
190+
java-version: 21
191+
cache: 'gradle'
192+
193+
- name: Setup Gradle cache
194+
uses: actions/cache@v4
195+
with:
196+
path: ~/.gradle
197+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
198+
199+
- name: "Prepare libs for tests"
200+
run: ./prepare.sh
201+
202+
- name: "Run Tests"
203+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.authentication.test:check
204+
205+
206+
test_dal:
207+
name: "Test DAL"
208+
needs: build
209+
runs-on: ubuntu-latest
210+
steps:
211+
- name: "Checkout Branch"
212+
uses: actions/checkout@v4
213+
214+
- name: "Setup Java"
215+
uses: actions/setup-java@v4
216+
with:
217+
distribution: 'temurin'
218+
java-version: 21
219+
cache: 'gradle'
220+
221+
- name: Setup Gradle cache
222+
uses: actions/cache@v4
223+
with:
224+
path: ~/.gradle
225+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
226+
227+
- name: "Prepare libs for tests"
228+
run: ./prepare.sh
229+
230+
- name: "Run Tests"
231+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.dal.test:check
232+
233+
234+
test_app:
235+
name: "Test App"
236+
needs: build
237+
runs-on: ubuntu-latest
238+
steps:
239+
- name: "Checkout Branch"
240+
uses: actions/checkout@v4
241+
242+
- name: "Setup Java"
243+
uses: actions/setup-java@v4
244+
with:
245+
distribution: 'temurin'
246+
java-version: 21
247+
cache: 'gradle'
248+
249+
- name: Setup Gradle cache
250+
uses: actions/cache@v4
251+
with:
252+
path: ~/.gradle
253+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
254+
255+
- name: "Prepare libs for tests"
256+
run: ./prepare.sh
257+
258+
- name: "Run Tests"
259+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.app.test:check
260+
261+
262+
test_app_preset:
263+
name: "Test App Preset"
264+
needs: build
265+
runs-on: ubuntu-latest
266+
steps:
267+
- name: "Checkout Branch"
268+
uses: actions/checkout@v4
269+
270+
- name: "Setup Java"
271+
uses: actions/setup-java@v4
272+
with:
273+
distribution: 'temurin'
274+
java-version: 21
275+
cache: 'gradle'
276+
277+
- name: Setup Gradle cache
278+
uses: actions/cache@v4
279+
with:
280+
path: ~/.gradle
281+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
282+
283+
- name: "Prepare libs for tests"
284+
run: ./prepare.sh
133285

286+
- name: "Run Tests"
287+
run: ./gradlew --build-cache --continue --rerun-tasks :bco.app.preset:check

.github/workflows/deploy-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616

1717
jobs:
1818
docker:
19-
# if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'preview') }}
19+
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'preview') }}
2020
runs-on: ubuntu-latest
2121
outputs:
2222
bco-tags: ${{ steps.bco-meta.outputs.tags }}

.github/workflows/update-addon-version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
git config user.name "$GIT_USERNAME"
9696
git config user.email "$GIT_EMAIL"
9797
git add config.yaml
98-
git commit -m "Update add-on $ADDONS_DIR version to $VERSION" || {
98+
git commit -m "Update add-on $ADDON_DIR version to $VERSION" || {
9999
echo "No changes to commit"
100100
exit 0
101101
}

buildSrc/src/main/kotlin/org.openbase.bco.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ tasks.withType<Test> {
5353
logging.captureStandardOutput(LogLevel.WARN)
5454
maxHeapSize = "7G"
5555
failFast = false
56-
setForkEvery(1)
5756
}
5857

5958
publishing {

lib/jul

Submodule jul updated 18 files

module/app/test/src/main/java/org/openbase/app/test/agent/BCOAppTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public static void tearDownBCOApp() throws Throwable {
101101
if (deviceManagerLauncher != null) {
102102
deviceManagerLauncher.shutdown();
103103
}
104+
if (messageManagerLauncher != null) {
105+
messageManagerLauncher.shutdown();
106+
}
104107
LOGGER.info("App tests finished!");
105108
} catch (Throwable ex) {
106109
throw ExceptionPrinter.printHistoryAndReturnThrowable(ex, LOGGER);

module/authentication/lib/src/main/java/org/openbase/bco/authentication/lib/future/AuthenticationFutureList.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,13 @@ object AuthenticationFutureList {
8181
notificationCondition.await()
8282
}
8383
}
84+
85+
fun reset() {
86+
synchronized(authenticatedFuturesLock) {
87+
synchronized(incomingFuturesLock) {
88+
incomingFutures.clear()
89+
authenticatedFutures.clear()
90+
}
91+
}
92+
}
8493
}

module/authentication/test/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ plugins {
22
id("org.openbase.bco")
33
}
44

5-
configurations {
6-
7-
}
8-
95
dependencies {
106
api(project(":bco.authentication.core"))
117
api(project(":bco.authentication.lib"))

module/authentication/test/src/test/java/org/openbase/bco/authentication/test/AuthenticationFutureListTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class AuthenticationFutureListTest {
4545
@Timeout(5)
4646
@Test
4747
fun testScheduledTask() {
48+
AuthenticationFutureList.reset()
4849
val lock = ReentrantLock()
4950
val condition: Condition = lock.newCondition()
5051

module/dal/control/src/main/java/org/openbase/bco/dal/control/layer/unit/AbstractUnitController.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public abstract class AbstractUnitController<D extends AbstractMessage & Seriali
157157
private final ArrayList<SchedulableAction> scheduledActionList;
158158
private final Timeout scheduleTimeout;
159159
private boolean infrastructure = false;
160+
private String cachedId;
161+
private String cachedLabel;
160162

161163
public AbstractUnitController(final DB builder) throws InstantiationException {
162164
super(builder);
@@ -377,6 +379,10 @@ public UnitConfig applyConfigUpdate(final UnitConfig config) throws CouldNotPerf
377379
logger.trace("Unit config change check failed because config is not available yet.");
378380
}
379381

382+
// clear caches
383+
cachedId = null;
384+
cachedLabel = null;
385+
380386
try {
381387
classDescription = getClass().getSimpleName() + "[" + config.getUnitType() + "[" + LabelProcessor.getBestMatch(config.getLabel()) + "]]";
382388
} catch (NullPointerException | NotAvailableException ex) {
@@ -439,6 +445,9 @@ public UnitConfig applyConfigUpdate(final UnitConfig config) throws CouldNotPerf
439445

440446
@Override
441447
public final String getId() throws NotAvailableException {
448+
if (cachedId != null) {
449+
return cachedId;
450+
}
442451
try {
443452
UnitConfig tmpConfig = getConfig();
444453
if (!tmpConfig.hasId()) {
@@ -449,14 +458,18 @@ public final String getId() throws NotAvailableException {
449458
throw new InvalidStateException("unitconfig.id is empty");
450459
}
451460

452-
return tmpConfig.getId();
461+
cachedId = tmpConfig.getId();
462+
return cachedId;
453463
} catch (CouldNotPerformException ex) {
454464
throw new NotAvailableException("Unit", "id", ex);
455465
}
456466
}
457467

458468
@Override
459469
public String getLabel() throws NotAvailableException {
470+
if (cachedLabel != null) {
471+
return cachedLabel;
472+
}
460473
try {
461474
UnitConfig tmpConfig = getConfig();
462475
if (!tmpConfig.hasLabel()) {
@@ -466,7 +479,8 @@ public String getLabel() throws NotAvailableException {
466479
if (LabelProcessor.isEmpty(tmpConfig.getLabel())) {
467480
throw new InvalidStateException("unitconfig.label is empty");
468481
}
469-
return LabelProcessor.getBestMatch(getConfig().getLabel());
482+
cachedLabel = LabelProcessor.getBestMatch(getConfig().getLabel());
483+
return cachedLabel;
470484
} catch (CouldNotPerformException ex) {
471485
throw new NotAvailableException("Unit", "label", ex);
472486
}

0 commit comments

Comments
 (0)