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

More Fuzzy Features #41

Merged
merged 11 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ for more.

### Kitchen Sink Workflow

The idea here was to strike a balance between a generic workflow implementation that would work for 99% of scenarios
while maintaining code simplicity and debuggability.
The Kitchen Sink workflows accepts a DSL generated by the `kitchen-sink-gen` Rust tool, allowing us
to test a wide variety of scenarios without having to imagine all possible edge cases that could
come up in workflows. Input may be saved for regression testing, or hand written for specific cases.

### Scenario Failure

Expand All @@ -129,3 +130,7 @@ workflow that waits for a signal for a configurable amount of time.

- Nicer output that includes resource utilization for the worker (when running all-in-one)
- More lang workers

## Fuzzer trophy case

* Python upsert SA with no initial attributes: [PR](https://github.com/temporalio/sdk-python/pull/440)
50 changes: 50 additions & 0 deletions cmd/cmdoptions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package cmdoptions
import (
"context"
"crypto/tls"
"encoding/base64"
"errors"
"fmt"
"os"

"github.com/golang/protobuf/proto"
"github.com/spf13/pflag"
"go.temporal.io/api/common/v1"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/converter"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -94,6 +98,16 @@ func (c *ClientOptions) Dial(metrics *Metrics, logger *zap.SugaredLogger) (clien
})
}

dataConverter := converter.NewCompositeDataConverter(
converter.NewNilPayloadConverter(),
converter.NewByteSlicePayloadConverter(),
&PassThroughPayloadConverter{},
converter.NewProtoJSONPayloadConverter(),
converter.NewProtoPayloadConverter(),
converter.NewJSONPayloadConverter(),
)
clientOptions.DataConverter = dataConverter

client, err := client.Dial(clientOptions)
if err != nil {
return nil, fmt.Errorf("failed to dial: %w", err)
Expand Down Expand Up @@ -135,3 +149,39 @@ func (c *ClientOptions) ToFlags() (flags []string) {
}
return
}

type PassThroughPayloadConverter struct{}

func (p *PassThroughPayloadConverter) ToPayload(value interface{}) (*common.Payload, error) {
if valuePayload, ok := value.(*common.Payload); ok {
asBytes, err := proto.Marshal(valuePayload)
if err != nil {
return nil, fmt.Errorf("unable to encode raw payload: %w", err)
}

return &common.Payload{
Metadata: map[string][]byte{
"encoding": []byte(p.Encoding()),
},
Data: asBytes,
}, nil
}
return nil, nil
}

func (p *PassThroughPayloadConverter) FromPayload(payload *common.Payload, valuePtr interface{}) error {
innerPayload := &common.Payload{}
err := proto.Unmarshal(payload.GetData(), innerPayload)
if err != nil {
return fmt.Errorf("unable to decode raw payload: %w", err)
}
return converter.GetDefaultDataConverter().FromPayload(innerPayload, valuePtr)
}

func (p *PassThroughPayloadConverter) ToString(payload *common.Payload) string {
return base64.RawStdEncoding.EncodeToString(payload.GetData())
}

func (p *PassThroughPayloadConverter) Encoding() string {
return "_passthrough"
}
45 changes: 45 additions & 0 deletions loadgen/kitchen-sink-gen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions loadgen/kitchen-sink-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ derive_more = "0.99"
prost = "0.12"
prost-types = "0.12"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[build-dependencies]
prost-build = "0.12"
4 changes: 2 additions & 2 deletions loadgen/kitchen-sink-gen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
cmd.arg(format!("--python_out={out_dir}"));
cmd.arg(format!("--pyi_out={out_dir}"));
} else if lang == "go" {
cmd.arg(format!("--go_opt=paths=source_relative"));
cmd.arg("--go_opt=paths=source_relative");
cmd.arg(format!("--go_out={out_dir}"));
}

Expand All @@ -78,7 +78,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let new_data = content.replace("from temporal.api", "from temporalio.api");

let mut dst = fs::File::create(&fpath)?;
dst.write(new_data.as_bytes())?;
dst.write_all(new_data.as_bytes())?;
}
}
}
Expand Down
Loading
Loading