-
Notifications
You must be signed in to change notification settings - Fork 0
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
Run integration test with GCS mock #55
Conversation
README.md
Outdated
Use the following command to run the integration tests: | ||
|
||
bash``` | ||
STORAGE_EMULATOR_HOST=http://0.0.0.0:4443 go test ./pkg/cmd/cli/... -run="TestCmd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically all our tests are more or less a form of it-test, so I'll remove this part in the command: 'run="TestCmd"'
pkg/cmd/cli/run_it_test.go
Outdated
// test parameters for each test | ||
cleanroomName string | ||
expireTime time.Time | ||
emailsSource []string | ||
tmpDir string | ||
salt string | ||
publisherPairKey *pair.PrivateKey | ||
advertiserInputFilePath string | ||
advertiserKeyConfigFilePath string | ||
publisherPAIRIDsFolderPath string | ||
advertiserOutputFolderPath string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be part of a different struct? to me these do not belong to the "test-suite" struct
pkg/cmd/cli/run_it_test.go
Outdated
// STORAGE_EMULATOR_HOST is required to run this test | ||
bucketURL := os.Getenv("STORAGE_EMULATOR_HOST") | ||
if bucketURL == "" { | ||
t.Skip("STORAGE_EMULATOR_HOST is required to run this test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of skipping, this test should fail IMO
pkg/cmd/cli/run_it_test.go
Outdated
shaEncoder := sha256.New() | ||
for i := range genEmailsSourceNumber { | ||
shaEncoder.Write([]byte(fmt.Sprintf("%d@gmail.com", i))) | ||
hem := shaEncoder.Sum(nil) | ||
s.emailsSource[i] = fmt.Sprintf("%x", hem) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you already have a helper function to generate emails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I have one in pair package. I cannot import it from _test.go
file.
pkg/cmd/cli/run_it_test.go
Outdated
} | ||
} | ||
|
||
func (s *cmdTestSuite) requireGenPublisherTripleEncryptedData() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you have this? publisher-triple-encrypted data is generated by the CLI, so you should not be creating it yourself. You probably need requireGenAdvertiserTripleEncryptedData (which is created by the publisher)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it actually writes into advertiser triple encrypted folder
s.requireGenPublisherTripleEncryptedData() | ||
} | ||
|
||
nextPuplisherState = v1.Cleanroom_Participant_SUCCEEDED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the cleanroom service side, this will only happen if the CLI has pushed triple-encrypted-publisher data and called the advance-state the second time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is called two times. I change variables "nextPuplisherState" and "nextAdvertiserState".
pkg/cmd/cli/run_it_test.go
Outdated
|
||
if cleanroom.Participants[0].State == v1.Cleanroom_Participant_DATA_TRANSFORMED { | ||
// add publisher triple encrypted data on this step | ||
s.requireGenPublisherTripleEncryptedData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not understanding this, why do we do it here? or the function name should requireGenAdvertiserTripleEncryptedData?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it for match: https://github.com/Optable/optable-pair-cli/blob/main/pkg/cmd/cli/run.go#L200
Oh, you will also need to pass the two options: --output=... So it does check the actual match, and uses the locally stored publisher data. THat will make the coverage data almost 100% |
It is already done and checked here: https://github.com/Optable/optable-pair-cli/pull/55/files#diff-68235dad6501edbd1da912df01435e618628c88dfdf962f4d4facb483fc8c093R325-R326 |
README.md
Outdated
Use the following command to run the integration tests: | ||
|
||
bash``` | ||
STORAGE_EMULATOR_HOST=http://0.0.0.0:4443 go test ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amanjpro suggested to add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what he says is in the README, we no longer this detail, because we already have the Make target, and I agree
We probably just need to tell you cannot run the tests under a windows machine
pkg/bucket/bucket.go
Outdated
@@ -56,6 +57,8 @@ type ( | |||
Option func(*bucketOptions) | |||
) | |||
|
|||
var HTTPClient = &http.Client{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't set global variable, pass it instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other way is to pass it in the cli context, what do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or as an optional value, and the constructor can check if it is nil or not, and sets it accordingly?
pkg/cmd/cli/run_it_test.go
Outdated
|
||
func (s *cmdTestSuite) requireGenAdvertiserTripleEncryptedData() { | ||
s.T().Helper() | ||
ctx := context.Background() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
pkg/cmd/cli/run_it_test.go
Outdated
s.Require().NoError(err, "must close GCS writer") | ||
}() | ||
tripleEncryptedCsvWriter := csv.NewWriter(tripleEncryptedWriter) | ||
defer tripleEncryptedCsvWriter.Flush() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to defer this, and you call writer.Error() to check write errors.
Flush writes any buffered data to the underlying io.Writer. To check if an error occurred during Flush, call Writer.Error.
pkg/cmd/cli/run_it_test.go
Outdated
|
||
func (s *cmdTestSuite) requireLocalContentEqualToGCSContent(localFolder, gcsFolder string) { | ||
s.T().Helper() | ||
ctx := context.Background() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx := context.Background() |
pkg/cmd/cli/run_it_test.go
Outdated
}() | ||
|
||
w := csv.NewWriter(tmpInputFile) | ||
defer w.Flush() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check w.Error()
Co-authored-by: Justin Li <justin.li@optable.co>
Co-authored-by: Justin Li <justin.li@optable.co>
Co-authored-by: Justin Li <justin.li@optable.co>
This PR introduces integration tests to ensure the proper functioning of key components with fake-gcs-server as a dependency.
These tests provide a more comprehensive validation by simulating interactions with a Google Cloud Storage-like environment.
Key Changes: