Created
October 21, 2022 11:47
-
-
Save msrijita18/3d5fb8d624ade74f7eee7c3e30d54f83 to your computer and use it in GitHub Desktop.
xk6 script sr
This file contains 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
import { check } from "k6"; | |
import { | |
Writer, | |
Reader, | |
Connection, | |
SchemaRegistry, | |
KEY, | |
VALUE, | |
SASL_SCRAM_SHA512, | |
TLS_1_2, | |
TOPIC_NAME_STRATEGY, | |
RECORD_NAME_STRATEGY, | |
SCHEMA_TYPE_AVRO, | |
} from "k6/x/kafka"; // import kafka extension | |
const brokers = ["pp.net:443"]; | |
const topic = "msr.dedicated.v1"; | |
const saslConfig = { | |
username: "padmin", | |
password: "xTxxxxxxxxxx", | |
algorithm: SASL_SCRAM_SHA512, | |
}; | |
const tlsConfig = { | |
enableTls: true, | |
insecureSkipTlsVerify: false, | |
minVersion: TLS_1_2, | |
clientCertPem: "/client-cert.pem", | |
clientKeyPem: "/client-key.pem", | |
serverCaPem: "/server-ca.pem", | |
}; | |
const connection = new Connection({ | |
address:brokers[0], | |
sasl:saslConfig, | |
tls:tlsConfig, | |
}); | |
const schemaRegistry = new SchemaRegistry({ | |
url:"https://pp.digital.net", | |
tls:{ | |
enableTls:true, | |
insecureSkipTlsVerify:false, | |
minVersion:TLS_1_2, | |
clientCertPem:"/SR/client-cert.pem", | |
clientKeyPem:"/SR/client-key.pem", | |
serverCertPem:"/SR/server-cert.pem", | |
}, | |
}); | |
const valueSchema = `{ | |
"type": "record", | |
"name": "AlertWebhookDTO", | |
"fields": [] | |
}`; | |
const valueSubjectName = schemaRegistry.getSubjectName({ | |
topic: topic, | |
element: VALUE, | |
subjectNameStrategy: RECORD_NAME_STRATEGY, | |
schema: valueSchema, | |
}); | |
const valueSchemaObject = schemaRegistry.getSchema({ | |
data: VALUE, | |
schema: valueSchema, | |
schemaType: SCHEMA_TYPE_AVRO, | |
}); | |
export default function () { | |
console.log(valueSchemaObject) | |
console.log(valueSubjectName) | |
console.log(connection) | |
console.log(schemaRegistry) | |
} | |
export function teardown(data) { | |
connection.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment