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

JVM: support inject fault to MySQL Java client #106

Merged
merged 15 commits into from
Feb 21, 2022

Conversation

WangXiangUSTC
Copy link
Collaborator

@WangXiangUSTC WangXiangUSTC commented Dec 1, 2021

  1. close issue JVM attack support inject fault to MySQL #104
  2. update stress and gc in JVM, use https://github.com/chaos-mesh/byteman-helper

Usage

chaosd attack jvm mysql --help
inject fault into MySQL client

Usage:
  chaosd attack jvm mysql [options] [flags]

Flags:
  -d, --database string               the match database
      --exception string              the exception message needs to throw
  -h, --help                          help for mysql
      --latency int                   the latency duration, unit ms
  -v, --mysql-connector-version int   the version of mysql-connector-java, only support 5.X.X(set to 5) and 8.X.X(set to 8) (default 5)
  -t, --table string                  the match table

Global Flags:
      --log-level string   the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
      --pid int            the pid of Java process which need to attach
      --port int           the port of agent server (default 9288)
      --uid string         the experiment ID

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 1, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Andrewmatilde
  • cwen0

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@WangXiangUSTC WangXiangUSTC changed the title JVM: support inject fault to MySQL Java client [WIP]JVM: support inject fault to MySQL Java client Dec 1, 2021
@WangXiangUSTC WangXiangUSTC changed the title [WIP]JVM: support inject fault to MySQL Java client JVM: support inject fault to MySQL Java client Jan 6, 2022
Copy link
Member

@Andrewmatilde Andrewmatilde left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -83,13 +60,25 @@ func (j jvmAttack) Attack(options core.AttackConfig, env Environment) (err error
log.Debug(string(output), zap.Error(err))
}

// submit helper jar
bmSubmitCmd := fmt.Sprintf(bmSubmitCommand, attack.Port, "b", fmt.Sprintf("%s/lib/byteman-helper.jar", os.Getenv("BYTEMAN_HOME")))
Copy link
Member

Choose a reason for hiding this comment

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

I think we may add this into docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why need to do this, I think it's the internal implementation logic

@Andrewmatilde
Copy link
Member

PTAL @cwen0

@Andrewmatilde
Copy link
Member

Andrewmatilde commented Jan 24, 2022

I think we should add e2e-test for JVM test.

Signed-off-by: xiang <[email protected]>
@WangXiangUSTC
Copy link
Collaborator Author

I think we should add e2e-test for JVM test.

You are right, I add a integration test, PTAL again @Andrewmatilde

Copy link
Member

@Andrewmatilde Andrewmatilde left a comment

Choose a reason for hiding this comment

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

LGTM

@cwen0 cwen0 added the documentation Improvements or additions to documentation label Feb 10, 2022
@cwen0 cwen0 removed the documentation Improvements or additions to documentation label Feb 10, 2022
@cwen0
Copy link
Member

cwen0 commented Feb 10, 2022

@WangXiangUSTC We need a new document to guide users on how to use it.

@WangXiangUSTC
Copy link
Collaborator Author

@WangXiangUSTC We need a new document to guide users on how to use it.

chaos-mesh/website#245 create an issue for it @cwen0

@cwen0
Copy link
Member

cwen0 commented Feb 10, 2022

@WangXiangUSTC How about split to two pr? You can update stress and gc in JVM by using https://github.com/chaos-mesh/byteman-helper in a single pr.

@WangXiangUSTC
Copy link
Collaborator Author

@WangXiangUSTC How about split to two pr? You can update stress and gc in JVM by using https://github.com/chaos-mesh/byteman-helper in a single pr.

OK

Signed-off-by: xiang <[email protected]>
@cwen0 cwen0 removed the WIP label Feb 16, 2022
pkg/core/jvm.go Outdated
@@ -123,6 +137,24 @@ type JVMStressSpec struct {
MemoryType string `json:"mem-type,omitempty"`
}

// only when SQL match the Database, Table, SQLType, chaosd will inject fault
Copy link
Member

Choose a reason for hiding this comment

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

This comment is incomplete and irregular.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It passed the check with the Grammarly 🥲

Copy link
Member

Choose a reason for hiding this comment

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

It is customary for go comments to begin with the "JVMMySQLSpec" and introduce the general information about this strcut.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Table string

// the match sql type
SQLType string
Copy link
Member

Choose a reason for hiding this comment

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

Is this field required? If I want to inject delay on all SQL of a specific table, do this feature supported?

Copy link
Collaborator Author

@WangXiangUSTC WangXiangUSTC Feb 18, 2022

Choose a reason for hiding this comment

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

Both Database, Table and SQLType are not required, the default value is "". For example:

  • select * from test.t1 can match config Database="test", Table='", SQLType=""
  • select * from test.t1 can match config Database="", Table="t1", SQLType=""
  • select * from test.t1 can match config Database="test", Table='", SQLType="select"
  • all sql can match Database="", Table='", SQLType=""

There is a unit test for this https://github.com/chaos-mesh/byteman-helper/blob/main/BytemanHelper/src/test/java/org/chaos_mesh/byteman/helper/SQLParserTest.java

@WangXiangUSTC
Copy link
Collaborator Author

I updated the comment, PTAL again @cwen0

Signed-off-by: xiang <[email protected]>
Copy link
Member

@cwen0 cwen0 left a comment

Choose a reason for hiding this comment

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

LGTM

@cwen0
Copy link
Member

cwen0 commented Feb 21, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 4a87c28

@ti-chi-bot ti-chi-bot merged commit 90f7f9b into chaos-mesh:main Feb 21, 2022
@STRRL STRRL mentioned this pull request Mar 2, 2022
51 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants