Skip to content
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

Standardizing Logging Level Strings, Fixed do_kafka_test.sh script #31

Merged
merged 38 commits into from
Oct 30, 2023

Conversation

dmccoystephenson
Copy link
Contributor

@dmccoystephenson dmccoystephenson commented Sep 15, 2023

Logging Level Strings

The logging level strings have been made uppercase to align with the logging level strings used in the other submodules.

Fixed do_kafka_test.sh Script

The do_kafka_test.sh was created six years ago, but it was discovered last year that it was not functioning properly due to inconsistencies in container name references and issues with dependent scripts.

The script has been refactored and thoroughly tested to ensure its functionality when executed in WSL.

Additional Changes

  • The dockerfile.testing file has been added to the project for testing purposes. This includes a python installation.
  • The majority of the code has been moved into methods in do_kafka_test.sh
  • Color has been added to the do_kafka_test.sh, do_bsm_test.sh and do_tim_test.sh scripts.
  • The standalone.sh and standalone-multi.sh scripts have been refactored.
  • Descriptions as comments have been added to a number of scripts.
  • The DOCKER_HOST_IP environment variable is now required to be set for the do_kafka_test.sh script to run.
  • The docker-compose-kafka.yml file has been added for testing purposes.
  • The default logging level has been changed to 'ERROR' instead of 'TRACE'.

Testing

These changes have been verified to be working when the script is run locally in WSL.

… PPM logs is above 100 instead of waiting a fixed amount of time for PPM readiness.
@dmccoystephenson dmccoystephenson changed the title Standardizing Logging Level Strings Standardizing Logging Level Strings, Fixed do_kafka_test.sh script Sep 27, 2023
@@ -19,6 +19,13 @@
"ms-vscode.cmake-tools"
],

"features": {
"docker-from-docker": {
Copy link
Contributor

@dan-du-car dan-du-car Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which repository does this feature reference to?

Copy link
Contributor

@dan-du-car dan-du-car Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

There is a warning for this feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it is just my local environment. Sometimes the code take some time to run with the feature on and the terminal does not return control to user.
image

ADD ./docker-test /cvdi-stream/docker-test

# Run the tool.
RUN chmod 7777 /cvdi-stream/docker-test/ppm_no_map.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this typo "7777"?

ADD ./config /cvdi-stream/config

# Do the build.
RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this /cvdi-stream-build folder or a build folder inside /cvdi-stream? like /cvdi-stream/build mkdir -p /cvdi-stream/build && cd /cvdi-stream/build && cmake /cvdi-stream

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse the ./devcontainer and replace the Dockerfile.testing with the vscode test task for the testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project files are stored in /cvdi-stream and are used to build executables in /cvdi-stream-build.

Copy link
Contributor Author

@dmccoystephenson dmccoystephenson Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dockerfile.testing file is used by scripts involved in the execution of the do_kafka_test.sh script, which is an integration test between the PPM & Kafka. The primary difference is that python is included so that the 'test_in.py' and 'test_out.py' scripts are usable.

I don't think this should be replaced by using the dev container, since the dev container is meant for development and the Dockerfile.testing file is meant for integration testing.

@@ -245,19 +245,19 @@ void PPM::print_configuration() const
bool PPM::configure() {

if ( optIsSet('v') ) {
if ( "trace" == optString('v') ) {
if ( "TRACE" == optString('v') ) {
Copy link
Contributor

@dan-du-car dan-du-car Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this log level string case insensitive? I see the configuration doc mentioned

-v | --log-level : The info log level [trace,debug,info,warning,error,critical,off]

They are all lower case. The code only compare the upper case.

docker-compose rm -f -v
docker-compose up --build -d
docker ps
./stop_kafka.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that 'chmod 777' needs to be executed on stop_kafka.sh prior to using the start_kafka.sh script here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, adding 777 works for me.

/cvdi-stream-build/kafka-test/kafka_tool -C -b $broker -p 0 -t topic.FilteredOdeBsmJson -e -o $offset 2> con.err | /cvdi-stream/docker-test/test_out.py > tmp.out
attempts=$((attempts+1))

timeout 5 /cvdi-stream-build/kafka-test/kafka_tool -C -b $broker -p 0 -t topic.FilteredOdeBsmJson -e -o $offset 2> con.err | /cvdi-stream/docker-test/test_out.py > tmp.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
The pipe break and it is not sending data to Kafka.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The do_bsm_test.sh script isn't intended to be run directly. I believe it is used by the standalone.sh and standalone_multi.sh scripts, which are in turn used by the do_kafka_test.sh script. Do you experience this behavior when running the do_kafka_test.sh script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to finish running the do_kafka_test.sh as some data are missing below (or I do not have those data in my ubuntu):

/ppm_data/road_file.csv
/tmp/docker-test/data


CURRENT_DIR_NAME=${PWD##*/}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Scenario 1:
I started Zookeeper and Kafka container first, then run this do_kafka_test.sh script. This script is going to start kafka again in the setup() func, and waitForKafkaToCreateTopics() complain that Kafka is not up.
image

Test Scenario 2:
Stop Kafka and zookeeper. Run the do_kafka_test.sh script.
image

IT will start the containers and then stop them at step 2. Should we remove the stop_kafka.sh from the start_kafka.sh script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Zookeeper and Kafka are already running, the do_kafka_test.sh script should restart them prior to building the PPM image and running the tests.

If Zookeeper and Kafka are not running, the do_kafka_test.sh script should start them.

Another comment of yours mentions that the kafka container name uses an underscore, not a hyphen. It's possible that this is why the container is not being found in Step 2. Interestingly, when I run the script the container name uses a hyphen, not an underscore. I wonder if this could be due to differences in docker versions. I am using Docker Desktop 4.17.0, what are you using?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using ubuntu 18.04 and docker version 20.10.6

# print setup info
echo "=== Setup Info ==="
echo "DOCKER_HOST_IP: $DOCKER_HOST_IP"
echo "KAFKA_CONTAINER_NAME: $KAFKA_CONTAINER_NAME"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
The kafka container name is separated by underscore not hyphen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine, the kafka container name is separated by a hyphen. This may have to do with differences in Docker Desktop versions. I am using v4.17.0, what are you using?

We may want to consider modifying the script to check for container names separated by an underscore and a hyphen, just to cover all of our bases.

fi
done
echo "Starting PPM in new container '$PPM_CONTAINER_NAME'"
docker run --name $PPM_CONTAINER_NAME --env DOCKER_HOST_IP=$dockerHostIp --env PPM_LOG_TO_CONSOLE=true --env PPM_LOG_TO_FILE=true -v /tmp/docker-test/data:/ppm_data -d -p '8080:8080' $PPM_IMAGE_NAME:$PPM_IMAGE_TAG /cvdi-stream/docker-test/ppm_standalone.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Can we use relative path for testing? The container is created but not running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the standalone.sh script in intended to run inside of a freshly-spun-up docker container, I believe using an absolute path here is the way to go.

The reason that you are experiencing stalling is because the script is expecting the container to have a number of logs before it is deemed 'ready'. Recently, we switched the default logging level to ERROR instead of TRACE, so the container is not spitting out any logs. This should be resolved by CDOT-CV#36. It should be noted that CDOT#36 is not merged into develop yet, so I suggest trying this again once it has been merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense as /cvdi-stream is inside container. Would like to clarify that I am not referring to /cvdi-stream/. I am running the standalone.sh inside my ubuntu, and I do not have this /tmp/docker-test/data directory. I am wandering if we could reuse the data directory in this repository.

if [ $4 = "BSM" ]; then
docker exec ppm_kafka /cvdi-stream/docker-test/do_bsm_test.sh $OFFSET
# Produce the test data.
docker exec $PPM_CONTAINER_NAME /cvdi-stream/docker-test/do_bsm_test.sh $OFFSET
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here. It might be helpful to use relative path rather than absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the command is intended to run inside of a docker container, an absolute path should be a fine method for referencing the script. I don't think this is a problem.

@dan-du-car dan-du-car merged commit 74e24f7 into usdot-jpo-ode:develop Oct 30, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants