Skip to content

Commit

Permalink
Fix CI workflows and checkstyle errors (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash1in committed Apr 16, 2024
1 parent b6b17a2 commit afebaad
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci-jfrog-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ name: Publish to LinkedIn JFrog

on:
release:
branches:
- 'li-dev/**'
types: [published]
jobs:
deploy:
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
Expand All @@ -15,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# This workflow will build a Java project with Maven
# See also:
Expand All @@ -25,11 +23,9 @@ name: CI

on:
push:
branches:
- 'li-dev/**'
branches: [ '*' ]
pull_request:
branches:
- 'li-dev/**'
branches: [ '*' ]

jobs:
mvn:
Expand All @@ -52,13 +48,14 @@ jobs:
timeout-minutes: 360
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.profile.jdk }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.profile.jdk }}
distribution: temurin
- name: Cache local maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.m2/repository/
Expand All @@ -68,22 +65,24 @@ jobs:
- name: Show the first log message
run: git log -n1
- name: Install C Dependencies
run: sudo apt-get install libcppunit-dev libsasl2-dev
run: |
sudo apt update
sudo apt install -y libcppunit-dev libsasl2-dev
- name: Build with Maven (${{ matrix.profile.name }})
run: mvn -B -V -e -ntp "-Dstyle.color=always" ${{ matrix.profile.args }}
env:
MAVEN_OPTS: -Djansi.force=true
- name: Upload unit test results
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: surefire-reports-${{ matrix.profile.name }}
path: ./**/target/surefire-reports/
if-no-files-found: ignore
- name: Upload integration test results
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: failsafe-reports-${{ matrix.profile.name }}
path: ./**/target/failsafe-reports/
if-no-files-found: ignore
if-no-files-found: ignore
13 changes: 8 additions & 5 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ jobs:
timeout-minutes: 360
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
distribution: temurin
- name: Cache local maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.m2/repository/
Expand All @@ -47,7 +48,9 @@ jobs:
- name: Show the first log message
run: git log -n1
- name: Install C Dependencies
run: sudo apt-get install libcppunit-dev libsasl2-dev
run: |
sudo apt update
sudo apt install -y libcppunit-dev libsasl2-dev
- name: Build with Maven
run: mvn -B -V -e -ntp "-Dstyle.color=always" package -DskipTests
env:
Expand All @@ -71,4 +74,4 @@ jobs:
if: matrix.zk == 'nightly'
run: tools/ci/test-connectivity.py --server . --client .
env:
ZOOCFG: zoo_sample.cfg
ZOOCFG: zoo_sample.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

import java.util.Scanner;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.DefaultParser;
import org.apache.zookeeper.server.backup.RestoreFromBackupTool;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import org.apache.jute.*;
import org.apache.jute.BinaryInputArchive;
import org.apache.jute.BinaryOutputArchive;
import org.apache.jute.InputArchive;
import org.apache.jute.OutputArchive;
import org.apache.jute.Record;
import org.apache.zookeeper.DigestWatcher;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.Code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.io.StringReader;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
LOG.info("{} = {}", CLOSE_SESSION_TXN_ENABLED, closeSessionTxnEnabled);

ephemeralNodesTotalByteLimit = Integer.getInteger(EPHEMERAL_NODES_TOTAL_BYTE_LIMIT_KEY, DEFAULT_EPHEMERAL_NODES_TOTAL_BYTE_LIMIT);
LOG.info("{} = {}",EPHEMERAL_NODES_TOTAL_BYTE_LIMIT_KEY, ephemeralNodesTotalByteLimit);
LOG.info("{} = {}", EPHEMERAL_NODES_TOTAL_BYTE_LIMIT_KEY, ephemeralNodesTotalByteLimit);
}

// @VisibleForTesting
Expand All @@ -169,7 +169,9 @@ public static void setCloseSessionTxnEnabled(boolean enabled) {
ZooKeeperServer.closeSessionTxnEnabled);
}

public static int getEphemeralNodesTotalByteLimit() {return ephemeralNodesTotalByteLimit;}
public static int getEphemeralNodesTotalByteLimit() {
return ephemeralNodesTotalByteLimit;
}

protected ZooKeeperServerBean jmxServerBean;
protected DataTreeBean jmxDataTreeBean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

package org.apache.zookeeper.server.quorum;

import static org.junit.Assert.assertEquals;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.jute.BinaryOutputArchive;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
Expand All @@ -9,12 +31,6 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;

public class EphemeralNodeThrottlingMultithreadTest extends QuorumPeerTestBase {

public static final String EPHEMERAL_BYTE_LIMIT_KEY = "zookeeper.ephemeralNodes.total.byte.limit";
Expand Down Expand Up @@ -51,13 +67,13 @@ public void multithreadedRequestsTest() throws Exception {
leaderSessionEphemeralsByteSum += BinaryOutputArchive.getSerializedStringByteSize(nodePath);
}
// TODO: What % delta do we want to allow here?
assertEquals(totalEphemeralNodesByteLimit, leaderSessionEphemeralsByteSum, totalEphemeralNodesByteLimit/20d);
assertEquals(totalEphemeralNodesByteLimit, leaderSessionEphemeralsByteSum, totalEphemeralNodesByteLimit / 20d);

int followerSessionEphemeralsByteSum = 0;
for (String nodePath : leaderServer.getEphemerals()) {
followerSessionEphemeralsByteSum += BinaryOutputArchive.getSerializedStringByteSize(nodePath);
}
assertEquals(totalEphemeralNodesByteLimit, followerSessionEphemeralsByteSum, totalEphemeralNodesByteLimit/20d);
assertEquals(totalEphemeralNodesByteLimit, followerSessionEphemeralsByteSum, totalEphemeralNodesByteLimit / 20d);

servers.shutDownAllServers();
}
Expand All @@ -74,7 +90,7 @@ private void runMultithreadedRequests(ZooKeeper server) {
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < 10000) {
try {
server.create(TEST_PATH +"_"+threadID+"_", new byte[512], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
server.create(TEST_PATH + "_" + threadID + "_", new byte[512], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
} catch (KeeperException.TotalEphemeralLimitExceeded expectedException) {
// Ignore Ephemeral Count exceeded exception, as this is expected to occur
} catch (Exception e) {
Expand Down Expand Up @@ -108,7 +124,7 @@ private void runMultithreadedRequests(ZooKeeper server) {

executor.shutdown();
try {
if(!executor.awaitTermination(12000, TimeUnit.MILLISECONDS)) {
if (!executor.awaitTermination(12000, TimeUnit.MILLISECONDS)) {
LOG.warn("Threads did not finish in the given time!");
executor.shutdownNow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@

package org.apache.zookeeper.server.quorum;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.jute.BinaryOutputArchive;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.metrics.MetricsUtils;
import org.junit.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.*;

public class EphemeralNodeThrottlingTest extends QuorumPeerTestBase {

Expand Down Expand Up @@ -67,7 +72,7 @@ public void byteSizeTest() {
int cumulativeBytes = 0;
int i = 0;
while (cumulativeBytes <= DEFAULT_EPHEMERALNODES_TOTAL_BYTE_LIMIT) {
cumulativeBytes += BinaryOutputArchive.getSerializedStringByteSize(TEST_PATH +i);
cumulativeBytes += BinaryOutputArchive.getSerializedStringByteSize(TEST_PATH + i);
try {
leaderServer.create(TEST_PATH + i++, new byte[512], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
} catch (Exception e) {
Expand Down

0 comments on commit afebaad

Please sign in to comment.